From 128f0bae32770a46b21aae66dd982f476e3ef3ab Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Fri, 19 Dec 2014 14:45:14 +0200 Subject: [PATCH 01/29] MAGETWO-31111: Plugins configuration caching - prototype implemented in singletenant compiler - plugin definitions generation added - added task manager for compiler - added operations per each compilation process --- .../ObjectManager/DefinitionFactoryTest.php | 8 +- dev/tools/Magento/Tools/Di/App/Compiler.php | 129 +++++------------- .../Magento/Tools/Di/App/Task/Manager.php | 53 +++++++ .../Tools/Di/App/Task/Operation/Area.php | 114 ++++++++++++++++ .../Di/App/Task/Operation/Interception.php | 60 ++++++++ .../Tools/Di/App/Task/Operation/Plugins.php | 68 +++++++++ .../Tools/Di/App/Task/Operation/Relations.php | 69 ++++++++++ .../Tools/Di/App/Task/OperationException.php | 15 ++ .../Tools/Di/App/Task/OperationFactory.php | 71 ++++++++++ .../Tools/Di/App/Task/OperationInterface.php | 17 +++ .../Tools/Di/Compiler/Config/Reader.php | 5 + .../Di/Compiler/Config/Writer/Filesystem.php | 11 +- .../Di/Compiler/Config/WriterInterface.php | 4 +- dev/tools/Magento/Tools/Di/compiler.php | 4 +- .../ObjectManager/DefinitionFactory.php | 4 +- 15 files changed, 520 insertions(+), 112 deletions(-) create mode 100644 dev/tools/Magento/Tools/Di/App/Task/Manager.php create mode 100644 dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php create mode 100644 dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php create mode 100644 dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php create mode 100644 dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php create mode 100644 dev/tools/Magento/Tools/Di/App/Task/OperationException.php create mode 100644 dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php create mode 100644 dev/tools/Magento/Tools/Di/App/Task/OperationInterface.php diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/DefinitionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/DefinitionFactoryTest.php index 4715bfb025875..1f334a9541df1 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/DefinitionFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/DefinitionFactoryTest.php @@ -91,12 +91,12 @@ public function createPluginsAndRelationsReadableDataProvider() { return [ 'relations' => [ - 'DefinitionDir/relations.php', + 'DefinitionDir/relations.ser', 'createRelations', '\Magento\Framework\ObjectManager\Relations\Compiled', ], 'plugins' => [ - 'DefinitionDir/plugins.php', + 'DefinitionDir/plugins.ser', 'createPluginDefinition', '\Magento\Framework\Interception\Definition\Compiled', ], @@ -121,12 +121,12 @@ public function createPluginsAndRelationsNotReadableDataProvider() { return [ 'relations' => [ - 'DefinitionDir/relations.php', + 'DefinitionDir/relations.ser', 'createRelations', '\Magento\Framework\ObjectManager\Relations\Runtime', ], 'plugins' => [ - 'DefinitionDir/plugins.php', + 'DefinitionDir/plugins.ser', 'createPluginDefinition', '\Magento\Framework\Interception\Definition\Runtime', ], diff --git a/dev/tools/Magento/Tools/Di/App/Compiler.php b/dev/tools/Magento/Tools/Di/App/Compiler.php index 4951f5a0c738d..ace248e873144 100644 --- a/dev/tools/Magento/Tools/Di/App/Compiler.php +++ b/dev/tools/Magento/Tools/Di/App/Compiler.php @@ -6,64 +6,34 @@ namespace Magento\Tools\Di\App; use Magento\Framework\App; -use Magento\Framework\Interception\Code\Generator\Interceptor; -use Magento\Tools\Di\Code\Generator\InterceptionConfigurationBuilder; -use Magento\Tools\Di\Code\Reader\ClassesScanner; -use Magento\Tools\Di\Compiler\Config; -use Magento\Tools\Di\Definition\Collection as DefinitionsCollection; /** * Class Compiler * @package Magento\Tools\Di\App * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Compiler implements \Magento\Framework\AppInterface { /** - * @var App\AreaList + * @var \Magento\Framework\ObjectManagerInterface */ - private $areaList; + private $objectManager; /** - * @var ClassesScanner + * @var Task\Manager */ - private $classesScanner; + private $taskManager; /** - * @var InterceptionConfigurationBuilder - */ - private $interceptionConfigurationBuilder; - - /** - * @var Config\Reader - */ - private $configReader; - - /** - * @var Config\Writer\Filesystem - */ - private $configWriter; - - /** - * @param App\AreaList $areaList - * @param ClassesScanner $classesScanner - * @param InterceptionConfigurationBuilder $interceptionConfigurationBuilder - * @param Config\Reader $configReader - * @param Config\Writer\Filesystem $configWriter + * @param Task\Manager $taskManager + * @param \Magento\Framework\ObjectManagerInterface $objectManager */ public function __construct( - App\AreaList $areaList, - ClassesScanner $classesScanner, - InterceptionConfigurationBuilder $interceptionConfigurationBuilder, - Config\Reader $configReader, - Config\Writer\Filesystem $configWriter + Task\Manager $taskManager, + \Magento\Framework\ObjectManagerInterface $objectManager ) { - $this->areaList = $areaList; - $this->classesScanner = $classesScanner; - $this->interceptionConfigurationBuilder = $interceptionConfigurationBuilder; - $this->configReader = $configReader; - $this->configWriter = $configWriter; + $this->taskManager = $taskManager; + $this->objectManager = $objectManager; } /** @@ -73,26 +43,33 @@ public function __construct( */ public function launch() { - $paths = ['app/code', 'lib/internal/Magento/Framework', 'var/generation']; - $definitionsCollection = new DefinitionsCollection(); - foreach ($paths as $path) { - $definitionsCollection->addCollection($this->getDefinitionsCollection(BP . '/' . $path)); - } - - $this->configWriter->write( - App\Area::AREA_GLOBAL, - $this->configReader->generateCachePerScope($definitionsCollection, App\Area::AREA_GLOBAL) + $this->objectManager->configure( + [ + 'preferences' => + [ + 'Magento\Tools\Di\Compiler\Config\WriterInterface' => + 'Magento\Tools\Di\Compiler\Config\Writer\Filesystem' + ] + ] ); - $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL); - foreach ($this->areaList->getCodes() as $areaCode) { - $this->interceptionConfigurationBuilder->addAreaCode($areaCode); - $this->configWriter->write( - $areaCode, - $this->configReader->generateCachePerScope($definitionsCollection, $areaCode, true) - ); - } - $this->generateInterceptors(); + $this->taskManager->addOperation( + Task\OperationFactory::AREA, + [BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation'] + ); + $this->taskManager->addOperation( + Task\OperationFactory::INTERCEPTION, + BP . '/var/generation' + ); + $this->taskManager->addOperation( + Task\OperationFactory::RELATIONS, + [BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation'] + ); + $this->taskManager->addOperation( + Task\OperationFactory::PLUGINS, + BP . '/app' + ); + $this->taskManager->process(); $response = new \Magento\Framework\App\Console\Response(); $response->setCode(0); @@ -116,40 +93,4 @@ public function catchException(App\Bootstrap $bootstrap, \Exception $exception) { return false; } - - /** - * Returns definitions collection - * - * @param string $path - * @return DefinitionsCollection - */ - protected function getDefinitionsCollection($path) - { - $definitions = new DefinitionsCollection(); - foreach ($this->classesScanner->getList($path) as $className => $constructorArguments) { - $definitions->addDefinition($className, $constructorArguments); - } - return $definitions; - } - - /** - * Creates interceptors configuration and generates code - * - * @return void - */ - private function generateInterceptors() - { - $generatorIo = new \Magento\Framework\Code\Generator\Io( - new \Magento\Framework\Filesystem\Driver\File(), - BP . '/var/generation' - ); - $generator = new \Magento\Tools\Di\Code\Generator( - $generatorIo, - [ - Interceptor::ENTITY_TYPE => 'Magento\Tools\Di\Code\Generator\Interceptor', - ] - ); - $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration(get_declared_classes()); - $generator->generateList($configuration); - } } diff --git a/dev/tools/Magento/Tools/Di/App/Task/Manager.php b/dev/tools/Magento/Tools/Di/App/Task/Manager.php new file mode 100644 index 0000000000000..940e539691660 --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/Manager.php @@ -0,0 +1,53 @@ +operationFactory = $operationFactory; + } + + /** + * Adds operations to task + * + * @param string $operationCode + * @param mixed $arguments + * @return void + */ + public function addOperation($operationCode, $arguments = null) + { + $this->operationsList[] = $this->operationFactory->create($operationCode, $arguments); + } + + /** + * Processes list of operations + * + * @return void + */ + public function process() + { + /** @var OperationInterface $operation */ + foreach ($this->operationsList as $operation) { + $operation->doOperation(); + } + } +} diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php new file mode 100644 index 0000000000000..b2d208c0a9d4a --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php @@ -0,0 +1,114 @@ +areaList = $areaList; + $this->classesScanner = $classesScanner; + $this->configReader = $configReader; + $this->configWriter = $configWriter; + $this->interceptionConfigurationBuilder = $interceptionConfigurationBuilder; + $this->data = $data; + } + + /** + * {@inheritdoc} + */ + public function doOperation() + { + if (empty($this->data)) { + return; + } + + $definitionsCollection = new DefinitionsCollection(); + foreach ($this->data as $path) { + $definitionsCollection->addCollection($this->getDefinitionsCollection($path)); + } + + $this->configWriter->write( + App\Area::AREA_GLOBAL, + $this->configReader->generateCachePerScope($definitionsCollection, App\Area::AREA_GLOBAL) + ); + $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL); + foreach ($this->areaList->getCodes() as $areaCode) { + $this->interceptionConfigurationBuilder->addAreaCode($areaCode); + $this->configWriter->write( + $areaCode, + $this->configReader->generateCachePerScope($definitionsCollection, $areaCode, true) + ); + } + } + + /** + * Returns definitions collection + * + * @param string $path + * @return DefinitionsCollection + */ + protected function getDefinitionsCollection($path) + { + $definitions = new DefinitionsCollection(); + foreach ($this->classesScanner->getList($path) as $className => $constructorArguments) { + $definitions->addDefinition($className, $constructorArguments); + } + return $definitions; + } +} diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php new file mode 100644 index 0000000000000..33ce2ebbc9a5b --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php @@ -0,0 +1,60 @@ +interceptionConfigurationBuilder = $interceptionConfigurationBuilder; + $this->data = $data; + } + + /** + * {@inheritdoc} + */ + public function doOperation() + { + if (empty($this->data)) { + return; + } + + $generatorIo = new \Magento\Framework\Code\Generator\Io( + new \Magento\Framework\Filesystem\Driver\File(), + $this->data + ); + $generator = new \Magento\Tools\Di\Code\Generator( + $generatorIo, + [ + Interceptor::ENTITY_TYPE => 'Magento\Tools\Di\Code\Generator\Interceptor', + ] + ); + $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration(get_declared_classes()); + $generator->generateList($configuration); + } + +} diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php new file mode 100644 index 0000000000000..5ce0cea72cf9e --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php @@ -0,0 +1,68 @@ +configWriter = $configWriter; + $this->data = $data; + } + + /** + * {@inheritdoc} + */ + public function doOperation() + { + if (empty($this->data)) { + return; + } + + $filePatterns = ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/']; + + $directoryScanner = new \Magento\Tools\Di\Code\Scanner\DirectoryScanner(); + $files = $directoryScanner->scan($this->data, $filePatterns); + + $pluginScanner = new \Magento\Tools\Di\Code\Scanner\CompositeScanner(); + $pluginScanner->addChild(new \Magento\Tools\Di\Code\Scanner\PluginScanner(), 'di'); + $pluginDefinitions = []; + $pluginList = $pluginScanner->collectEntities($files); + $pluginDefinitionList = new \Magento\Framework\Interception\Definition\Runtime(); + foreach ($pluginList as $type => $entityList) { + foreach ($entityList as $entity) { + $pluginDefinitions[$entity] = $pluginDefinitionList->getMethodList($entity); + } + } + + $this->configWriter->write(self::CODE, $pluginDefinitions); + } +} diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php new file mode 100644 index 0000000000000..bf35ac068ee7a --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php @@ -0,0 +1,69 @@ +configWriter = $configWriter; + $this->data = $data; + } + + /** + * {@inheritdoc} + */ + public function doOperation() + { + if (empty($this->data)) { + return; + } + + $logWriter = new \Magento\Tools\Di\Compiler\Log\Writer\Quiet(); + $errorWriter = new \Magento\Tools\Di\Compiler\Log\Writer\Console(); + + $log = new \Magento\Tools\Di\Compiler\Log\Log($logWriter, $errorWriter); + + $validator = new \Magento\Framework\Code\Validator(); + $validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity()); + $validator->add(new \Magento\Framework\Code\Validator\ContextAggregation()); + + $directoryCompiler = new \Magento\Tools\Di\Compiler\Directory($log, $validator); + foreach ($this->data as $path) { + if (is_readable($path)) { + $directoryCompiler->compile($path); + } + } + + list(, $relations) = $directoryCompiler->getResult(); + $this->configWriter->write(self::CODE, $relations); + } +} diff --git a/dev/tools/Magento/Tools/Di/App/Task/OperationException.php b/dev/tools/Magento/Tools/Di/App/Task/OperationException.php new file mode 100644 index 0000000000000..19229fb781715 --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/OperationException.php @@ -0,0 +1,15 @@ + 'Magento\Tools\Di\App\Task\Operation\Area', + self::INTERCEPTION => 'Magento\Tools\Di\App\Task\Operation\Interception', + self::RELATIONS => 'Magento\Tools\Di\App\Task\Operation\Relations', + self::PLUGINS => 'Magento\Tools\Di\App\Task\Operation\Plugins', + ]; + + /** + * @param \Magento\Framework\ObjectManagerInterface $objectManager + */ + public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Creates operation + * + * @param string $operationAlias + * @param mixed $arguments + * @return OperationInterface + * @throws OperationException + */ + public function create($operationAlias, $arguments = null) + { + if (!array_key_exists($operationAlias, $this->operationsDefinitions)) { + throw new OperationException('Unrecognized operation', OperationException::UNAVAILABLE_OPERATION); + } + return $this->objectManager->create($this->operationsDefinitions[$operationAlias], ['data' => $arguments]); + } +} diff --git a/dev/tools/Magento/Tools/Di/App/Task/OperationInterface.php b/dev/tools/Magento/Tools/Di/App/Task/OperationInterface.php new file mode 100644 index 0000000000000..47d8da3e921d3 --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/OperationInterface.php @@ -0,0 +1,17 @@ +getConfigForScope($definitionsCollection, $areaConfig); + foreach ($config['arguments'] as $key => $value) { + if ($value !== null) { + $config['arguments'][$key] = serialize($value); + } + } foreach ($definitionsCollection->getInstancesNamesList() as $instanceName) { if (!$areaConfig->isShared($instanceName)) { $config['nonShared'][$instanceName] = true; diff --git a/dev/tools/Magento/Tools/Di/Compiler/Config/Writer/Filesystem.php b/dev/tools/Magento/Tools/Di/Compiler/Config/Writer/Filesystem.php index 37a48d7931e96..3909c772db0fd 100644 --- a/dev/tools/Magento/Tools/Di/Compiler/Config/Writer/Filesystem.php +++ b/dev/tools/Magento/Tools/Di/Compiler/Config/Writer/Filesystem.php @@ -13,21 +13,16 @@ class Filesystem implements WriterInterface /** * Writes config in storage * - * @param string $areaCode + * @param string $key * @param array $config * @return void */ - public function write($areaCode, array $config) + public function write($key, array $config) { $this->initialize(); - foreach ($config['arguments'] as $key => $value) { - if ($value !== null) { - $config['arguments'][$key] = serialize($value); - } - } $serialized = serialize($config); - file_put_contents(BP . '/var/di/' . $areaCode . '.ser', $serialized); + file_put_contents(BP . '/var/di/' . $key . '.ser', $serialized); } /** diff --git a/dev/tools/Magento/Tools/Di/Compiler/Config/WriterInterface.php b/dev/tools/Magento/Tools/Di/Compiler/Config/WriterInterface.php index cafa106c3dc0e..c9da6e3ba420b 100644 --- a/dev/tools/Magento/Tools/Di/Compiler/Config/WriterInterface.php +++ b/dev/tools/Magento/Tools/Di/Compiler/Config/WriterInterface.php @@ -11,9 +11,9 @@ interface WriterInterface /** * Writes config in storage * - * @param string $areaCode + * @param string $key * @param array $config * @return void */ - public function write($areaCode, array $config); + public function write($key, array $config); } diff --git a/dev/tools/Magento/Tools/Di/compiler.php b/dev/tools/Magento/Tools/Di/compiler.php index f838a21987b9a..fb52eba6e74c9 100644 --- a/dev/tools/Magento/Tools/Di/compiler.php +++ b/dev/tools/Magento/Tools/Di/compiler.php @@ -39,8 +39,8 @@ $generationDir = $opt->getOption('generation') ? $opt->getOption('generation') : $rootDir . '/var/generation'; $diDir = $opt->getOption('di') ? $opt->getOption('di') : $rootDir . '/var/di'; $compiledFile = $diDir . '/definitions.php'; - $relationsFile = $diDir . '/relations.php'; - $pluginDefFile = $diDir . '/plugins.php'; + $relationsFile = $diDir . '/relations.ser'; + $pluginDefFile = $diDir . '/plugins.ser'; $compilationDirs = [ $rootDir . '/app/code', diff --git a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php index c4297dd6e9f2e..7f22f832d6880 100644 --- a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php @@ -133,7 +133,7 @@ public function createClassDefinition($definitions, $useCompiled = true) */ public function createPluginDefinition() { - $path = $this->_definitionDir . '/plugins.php'; + $path = $this->_definitionDir . '/plugins.ser'; if ($this->_filesystemDriver->isReadable($path)) { return new \Magento\Framework\Interception\Definition\Compiled( $this->_unpack($this->_filesystemDriver->fileGetContents($path)) @@ -150,7 +150,7 @@ public function createPluginDefinition() */ public function createRelations() { - $path = $this->_definitionDir . '/' . 'relations.php'; + $path = $this->_definitionDir . '/' . 'relations.ser'; if ($this->_filesystemDriver->isReadable($path)) { return new \Magento\Framework\ObjectManager\Relations\Compiled( $this->_unpack($this->_filesystemDriver->fileGetContents($path)) From 2470e6df689e60d952f216144723513c19462de1 Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Mon, 22 Dec 2014 15:19:29 +0200 Subject: [PATCH 02/29] MAGETWO-31111: Plugins configuration caching - operations usage refactored - exception handle added - tests added --- .../Magento/Tools/Di/App/CompilerTest.php | 149 +++++++++++------- .../Magento/Tools/Di/App/Task/AreaTest.php | 107 +++++++++++++ .../Di/App/Task/OperationFactoryTest.php | 74 +++++++++ .../Tools/Di/Compiler/Config/ReaderTest.php | 35 ++-- dev/tools/Magento/Tools/Di/App/Compiler.php | 65 +++++--- .../Magento/Tools/Di/App/Task/Manager.php | 1 + .../Tools/Di/App/Task/Operation/Area.php | 20 +-- .../Di/App/Task/Operation/Interception.php | 13 ++ .../Tools/Di/App/Task/Operation/Plugins.php | 12 +- .../Tools/Di/App/Task/OperationFactory.php | 5 +- .../Tools/Di/Compiler/Config/Reader.php | 6 +- .../Framework/App/Console/Response.php | 10 ++ 12 files changed, 366 insertions(+), 131 deletions(-) create mode 100644 dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/AreaTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php diff --git a/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php b/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php index 151c14e4a9be0..e518db722a548 100644 --- a/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php +++ b/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php @@ -7,93 +7,124 @@ class CompilerTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Di\App\Compiler + * @var Compiler */ private $model; /** - * @var \Magento\Framework\App\AreaList | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject */ - private $areaList; + private $objectManagerMock; /** - * @var \Magento\Tools\Di\Code\Reader\ClassesScanner | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Tools\Di\App\Task\Manager | \PHPUnit_Framework_MockObject_MockObject */ - private $classesScanner; + private $taskManagerMock; /** - * @var \Magento\Tools\Di\Code\Generator\InterceptionConfigurationBuilder | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Console\Response | \PHPUnit_Framework_MockObject_MockObject */ - private $interceptionConfigurationBuilder; - - /** - * @var \Magento\Tools\Di\Compiler\Config\Reader | \PHPUnit_Framework_MockObject_MockObject - */ - private $configReader; - - /** - * @var \Magento\Tools\Di\Compiler\Config\Writer\Filesystem | \PHPUnit_Framework_MockObject_MockObject - */ - private $configWriter; + private $responseMock; protected function setUp() { - $this->areaList = $this->getMockBuilder('\Magento\Framework\App\AreaList') - ->disableOriginalConstructor() + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->setMethods([]) ->getMock(); - - $this->classesScanner = $this->getMockBuilder('\Magento\Tools\Di\Code\Reader\ClassesScanner') + $this->taskManagerMock = $this->getMockBuilder('Magento\Tools\Di\App\Task\Manager') ->disableOriginalConstructor() - ->setMethods(['getList']) + ->setMethods([]) ->getMock(); - - $this->interceptionConfigurationBuilder = $this->getMockBuilder( - '\Magento\Tools\Di\Code\Generator\InterceptionConfigurationBuilder' - )->disableOriginalConstructor()->getMock(); - - $this->configReader = $this->getMockBuilder('\Magento\Tools\Di\Compiler\Config\Reader') + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Console\Response') ->disableOriginalConstructor() + ->setMethods([]) ->getMock(); - - $this->configWriter = $this->getMockBuilder('\Magento\Tools\Di\Compiler\Config\Writer\Filesystem') - ->setMethods(['write']) - ->getMock(); - - $this->model = new \Magento\Tools\Di\App\Compiler( - $this->areaList, - $this->classesScanner, - $this->interceptionConfigurationBuilder, - $this->configReader, - $this->configWriter + $this->model = new Compiler( + $this->taskManagerMock, + $this->objectManagerMock, + $this->responseMock ); } - public function testLaunch() + public function testLaunchSuccess() { - $this->classesScanner->expects($this->exactly(3)) - ->method('getList') - ->willReturn([]); - - $this->configReader->expects($this->any()) - ->method('generateCachePerScope') - ->willReturn([]); + $this->objectManagerMock->expects($this->once()) + ->method('configure') + ->with($this->getPreferences()); + $index = 0; + foreach ($this->getOptions() as $code => $arguments) { + $this->taskManagerMock->expects($this->at($index)) + ->method('addOperation') + ->with($code, $arguments); + $index++; + } + $this->taskManagerMock->expects($this->at($index))->method('process'); + $this->responseMock->expects($this->once()) + ->method('setCode') + ->with(\Magento\Framework\App\Console\Response::SUCCESS); - $areaListResult = ['global', 'frontend', 'admin']; - $this->areaList->expects($this->once()) - ->method('getCodes') - ->willReturn($areaListResult); + $this->assertInstanceOf('\Magento\Framework\App\Console\Response', $this->model->launch()); + } - $count = count($areaListResult) + 1; - $this->configWriter->expects($this->exactly($count)) - ->method('write'); + public function testLaunchException() + { + $this->objectManagerMock->expects($this->once()) + ->method('configure') + ->with($this->getPreferences()); + $code = key($this->getOptions()); + $arguments = current($this->getOptions()); + $exception = new Task\OperationException( + 'Unrecognized operation', + Task\OperationException::UNAVAILABLE_OPERATION + ); - $this->interceptionConfigurationBuilder->expects($this->exactly($count)) - ->method('addAreaCode'); + $this->taskManagerMock->expects($this->once()) + ->method('addOperation') + ->with($code, $arguments) + ->willThrowException($exception); - $this->interceptionConfigurationBuilder->expects($this->once()) - ->method('getInterceptionConfiguration') - ->willReturn([]); + $this->taskManagerMock->expects($this->never())->method('process'); + $this->responseMock->expects($this->once()) + ->method('setCode') + ->with(\Magento\Framework\App\Console\Response::ERROR); $this->assertInstanceOf('\Magento\Framework\App\Console\Response', $this->model->launch()); } + + /** + * Returns configured preferences + * + * @return array + */ + private function getPreferences() + { + return [ + 'preferences' => + [ + 'Magento\Tools\Di\Compiler\Config\WriterInterface' => + 'Magento\Tools\Di\Compiler\Config\Writer\Filesystem' + ] + ]; + } + + /** + * Returns options + * + * @return array + */ + private function getOptions() + { + return [ + Task\OperationFactory::AREA => [ + BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' + ], + Task\OperationFactory::INTERCEPTION => + BP . '/var/generation', + Task\OperationFactory::RELATIONS => [ + BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' + ], + Task\OperationFactory::PLUGINS => + BP . '/app' + ]; + } } diff --git a/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/AreaTest.php b/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/AreaTest.php new file mode 100644 index 0000000000000..6cc532ab20f30 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/AreaTest.php @@ -0,0 +1,107 @@ +areaListMock = $this->getMockBuilder('Magento\Framework\App\AreaList') + ->disableOriginalConstructor() + ->getMock(); + $this->classesScannerMock = $this->getMockBuilder('Magento\Tools\Di\Code\Reader\ClassesScanner') + ->disableOriginalConstructor() + ->getMock(); + $this->configReaderMock = $this->getMockBuilder('Magento\Tools\Di\Compiler\Config\Reader') + ->disableOriginalConstructor() + ->getMock(); + $this->configWriterMock = $this->getMockBuilder('Magento\Tools\Di\Compiler\Config\WriterInterface') + ->disableOriginalConstructor() + ->getMock(); + } + + public function testDoOperationEmptyPath() + { + $areaOperation = new Area( + $this->areaListMock, + $this->classesScannerMock, + $this->configReaderMock, + $this->configWriterMock + ); + + $this->assertNull($areaOperation->doOperation()); + } + + public function testDoOperationGlobalArea() + { + $path = 'path/to/codebase/'; + $generatedConfig = [ + 'arguments' => [], + 'nonShared' => [], + 'preferences' => [], + 'instanceTypes' => [] + ]; + $definitions = new DefinitionsCollection(); + $definitions->addDefinition('class', []); + $areaOperation = new Area( + $this->areaListMock, + $this->classesScannerMock, + $this->configReaderMock, + $this->configWriterMock, + [$path] + ); + + $this->areaListMock->expects($this->once()) + ->method('getCodes') + ->willReturn([]); + $this->classesScannerMock->expects($this->once()) + ->method('getList') + ->with($path) + ->willReturn(['class' => []]); + $this->configReaderMock->expects($this->once()) + ->method('generateCachePerScope') + ->with( + $this->isInstanceOf('Magento\Tools\Di\Definition\Collection'), + App\Area::AREA_GLOBAL + ) + ->willReturn($generatedConfig); + $this->configWriterMock->expects($this->once()) + ->method('write') + ->with( + App\Area::AREA_GLOBAL, + $generatedConfig + ); + + $areaOperation->doOperation(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php b/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php new file mode 100644 index 0000000000000..2f2d7ffd507b1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php @@ -0,0 +1,74 @@ +objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->setMethods([]) + ->getMock(); + $this->factory = new OperationFactory( + $this->objectManagerMock + ); + } + + /** + * @param string $alias + * @param mixed $arguments + * @dataProvider aliasesDataProvider + */ + public function testCreateSuccess($alias, $arguments, $instanceName) + { + $operationInstance = $this->getMockBuilder('Magento\Tools\Di\App\Task\OperationInterface') + ->getMock(); + + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with($instanceName, ['data' => $arguments]) + ->willReturn($operationInstance); + + $this->assertSame($operationInstance, $this->factory->create($alias, $arguments)); + } + + public function testCreateException() + { + $notRegisteredOperation = 'coffee'; + $this->setExpectedException( + 'Magento\Tools\Di\App\Task\OperationException', + sprintf('Unrecognized operation "%s"', $notRegisteredOperation), + OperationException::UNAVAILABLE_OPERATION + ); + $this->factory->create($notRegisteredOperation); + } + + /** + * @return array + */ + public function aliasesDataProvider() + { + return [ + [OperationFactory::AREA, [], 'Magento\Tools\Di\App\Task\Operation\Area'], + [OperationFactory::INTERCEPTION, null, 'Magento\Tools\Di\App\Task\Operation\Interception'], + [OperationFactory::RELATIONS, 1, 'Magento\Tools\Di\App\Task\Operation\Relations'], + [OperationFactory::PLUGINS, 'argument', 'Magento\Tools\Di\App\Task\Operation\Plugins'], + ]; + } + +} diff --git a/dev/tests/unit/testsuite/Magento/Tools/Di/Compiler/Config/ReaderTest.php b/dev/tests/unit/testsuite/Magento/Tools/Di/Compiler/Config/ReaderTest.php index 315c04b30c663..04fcfe2846851 100644 --- a/dev/tests/unit/testsuite/Magento/Tools/Di/Compiler/Config/ReaderTest.php +++ b/dev/tests/unit/testsuite/Magento/Tools/Di/Compiler/Config/ReaderTest.php @@ -71,21 +71,17 @@ protected function setUp() ); } - /** - * @dataProvider generateCachePerScopeDataProvider - */ - public function testGenerateCachePerScope($extendConfig) + public function testGenerateCachePerScopeExtends() { $definitionsCollection = $this->getMock('Magento\Tools\Di\Definition\Collection', [], [], '', false); - if ($extendConfig) { - $this->diContainerConfig->expects($this->once()) - ->method('extend') - ->with([]); - $this->configLoader->expects($this->once()) - ->method('load') - ->with('areaCode') - ->willReturn([]); - } + $this->diContainerConfig->expects($this->once()) + ->method('extend') + ->with([]); + $this->configLoader->expects($this->once()) + ->method('load') + ->with('areaCode') + ->willReturn([]); + $this->argumentsResolverFactory->expects($this->once()) ->method('create') ->with($this->diContainerConfig) @@ -140,17 +136,6 @@ public function testGenerateCachePerScope($extendConfig) ['instanceType1', 'instanceType1ss'], ['instanceType2', 'instanceType2'], ]); - $this->model->generateCachePerScope($definitionsCollection, 'areaCode', $extendConfig); - } - - /** - * @return array - */ - public function generateCachePerScopeDataProvider() - { - return [ - [true], - [false] - ]; + $this->model->generateCachePerScope($definitionsCollection, 'areaCode'); } } diff --git a/dev/tools/Magento/Tools/Di/App/Compiler.php b/dev/tools/Magento/Tools/Di/App/Compiler.php index ace248e873144..215d5b42c6427 100644 --- a/dev/tools/Magento/Tools/Di/App/Compiler.php +++ b/dev/tools/Magento/Tools/Di/App/Compiler.php @@ -6,6 +6,8 @@ namespace Magento\Tools\Di\App; use Magento\Framework\App; +use Magento\Framework\App\Console\Response; +use Magento\Framework\ObjectManagerInterface; /** * Class Compiler @@ -15,7 +17,7 @@ class Compiler implements \Magento\Framework\AppInterface { /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManagerInterface */ private $objectManager; @@ -24,16 +26,24 @@ class Compiler implements \Magento\Framework\AppInterface */ private $taskManager; + /** + * @var Response + */ + private $response; + /** * @param Task\Manager $taskManager - * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param ObjectManagerInterface $objectManager + * @param Response $response */ public function __construct( Task\Manager $taskManager, - \Magento\Framework\ObjectManagerInterface $objectManager + ObjectManagerInterface $objectManager, + Response $response ) { $this->taskManager = $taskManager; $this->objectManager = $objectManager; + $this->response = $response; } /** @@ -53,27 +63,36 @@ public function launch() ] ); - $this->taskManager->addOperation( - Task\OperationFactory::AREA, - [BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation'] - ); - $this->taskManager->addOperation( - Task\OperationFactory::INTERCEPTION, - BP . '/var/generation' - ); - $this->taskManager->addOperation( - Task\OperationFactory::RELATIONS, - [BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation'] - ); - $this->taskManager->addOperation( - Task\OperationFactory::PLUGINS, - BP . '/app' - ); - $this->taskManager->process(); + $operations = [ + Task\OperationFactory::AREA => [ + BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' + ], + Task\OperationFactory::INTERCEPTION => + BP . '/var/generation', + Task\OperationFactory::RELATIONS => [ + BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' + ], + Task\OperationFactory::PLUGINS => + BP . '/app' + ]; + + $responseCode = Response::SUCCESS; + try { + foreach ($operations as $operationCode => $arguments) { + $this->taskManager->addOperation( + $operationCode, + $arguments + ); + } + $this->taskManager->process(); - $response = new \Magento\Framework\App\Console\Response(); - $response->setCode(0); - return $response; + } catch (Task\OperationException $e) { + $responseCode = Response::ERROR; + $this->response->setBody($e->getMessage()); + } finally { + $this->response->setCode($responseCode); + return $this->response; + } } /** diff --git a/dev/tools/Magento/Tools/Di/App/Task/Manager.php b/dev/tools/Magento/Tools/Di/App/Task/Manager.php index 940e539691660..b37e87b2510a1 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Manager.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Manager.php @@ -49,5 +49,6 @@ public function process() foreach ($this->operationsList as $operation) { $operation->doOperation(); } + $this->operationsList = []; } } diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php index b2d208c0a9d4a..001db59c8bf62 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php @@ -11,7 +11,6 @@ use Magento\Tools\Di\Code\Reader\ClassesScanner; use Magento\Tools\Di\Compiler\Config; use Magento\Tools\Di\Definition\Collection as DefinitionsCollection; -use Magento\Tools\Di\Code\Generator\InterceptionConfigurationBuilder; class Area implements OperationInterface { @@ -30,11 +29,6 @@ class Area implements OperationInterface */ private $configReader; - /** - * @var InterceptionConfigurationBuilder - */ - private $interceptionConfigurationBuilder; - /** * @var Config\WriterInterface */ @@ -49,7 +43,6 @@ class Area implements OperationInterface * @param App\AreaList $areaList * @param ClassesScanner $classesScanner * @param Config\Reader $configReader - * @param InterceptionConfigurationBuilder $interceptionConfigurationBuilder * @param Config\WriterInterface $configWriter * @param array $data */ @@ -57,7 +50,6 @@ public function __construct( App\AreaList $areaList, ClassesScanner $classesScanner, Config\Reader $configReader, - InterceptionConfigurationBuilder $interceptionConfigurationBuilder, Config\WriterInterface $configWriter, $data = [] ) { @@ -65,7 +57,6 @@ public function __construct( $this->classesScanner = $classesScanner; $this->configReader = $configReader; $this->configWriter = $configWriter; - $this->interceptionConfigurationBuilder = $interceptionConfigurationBuilder; $this->data = $data; } @@ -83,16 +74,11 @@ public function doOperation() $definitionsCollection->addCollection($this->getDefinitionsCollection($path)); } - $this->configWriter->write( - App\Area::AREA_GLOBAL, - $this->configReader->generateCachePerScope($definitionsCollection, App\Area::AREA_GLOBAL) - ); - $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL); - foreach ($this->areaList->getCodes() as $areaCode) { - $this->interceptionConfigurationBuilder->addAreaCode($areaCode); + $areaCodes = [App\Area::AREA_GLOBAL] + $this->areaList->getCodes(); + foreach ($areaCodes as $areaCode) { $this->configWriter->write( $areaCode, - $this->configReader->generateCachePerScope($definitionsCollection, $areaCode, true) + $this->configReader->generateCachePerScope($definitionsCollection, $areaCode) ); } } diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php index 33ce2ebbc9a5b..99da5db890fec 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php @@ -9,9 +9,15 @@ use Magento\Tools\Di\App\Task\OperationInterface; use Magento\Tools\Di\Code\Generator\InterceptionConfigurationBuilder; use Magento\Framework\Interception\Code\Generator\Interceptor; +use Magento\Framework\App; class Interception implements OperationInterface { + /** + * @var App\AreaList + */ + private $areaList; + /** * @var InterceptionConfigurationBuilder */ @@ -28,9 +34,11 @@ class Interception implements OperationInterface */ public function __construct( InterceptionConfigurationBuilder $interceptionConfigurationBuilder, + App\AreaList $areaList, $data = '' ) { $this->interceptionConfigurationBuilder = $interceptionConfigurationBuilder; + $this->areaList = $areaList; $this->data = $data; } @@ -42,6 +50,11 @@ public function doOperation() if (empty($this->data)) { return; } + $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL); + + foreach ($this->areaList->getCodes() as $areaCode) { + $this->interceptionConfigurationBuilder->addAreaCode($areaCode); + } $generatorIo = new \Magento\Framework\Code\Generator\Io( new \Magento\Framework\Filesystem\Driver\File(), diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php index 5ce0cea72cf9e..b4972e47a9087 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php @@ -8,6 +8,7 @@ use Magento\Tools\Di\App\Task\OperationInterface; use Magento\Tools\Di\Compiler\Config; +use Magento\Framework\Interception; class Plugins implements OperationInterface { @@ -21,6 +22,11 @@ class Plugins implements OperationInterface */ private $data = ''; + /** + * @var Interception\Definition\Runtime + */ + private $definitionRuntime; + /** * Code */ @@ -28,13 +34,16 @@ class Plugins implements OperationInterface /** * @param Config\WriterInterface $configWriter + * @param Interception\Definition\Runtime $definitionRuntime * @param string $data */ public function __construct( Config\WriterInterface $configWriter, + Interception\Definition\Runtime $definitionRuntime, $data = '' ) { $this->configWriter = $configWriter; + $this->definitionRuntime = $definitionRuntime; $this->data = $data; } @@ -56,10 +65,9 @@ public function doOperation() $pluginScanner->addChild(new \Magento\Tools\Di\Code\Scanner\PluginScanner(), 'di'); $pluginDefinitions = []; $pluginList = $pluginScanner->collectEntities($files); - $pluginDefinitionList = new \Magento\Framework\Interception\Definition\Runtime(); foreach ($pluginList as $type => $entityList) { foreach ($entityList as $entity) { - $pluginDefinitions[$entity] = $pluginDefinitionList->getMethodList($entity); + $pluginDefinitions[$entity] = $this->definitionRuntime->getMethodList($entity); } } diff --git a/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php b/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php index a6d153984886b..79ec97ad52b59 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php +++ b/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php @@ -64,7 +64,10 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan public function create($operationAlias, $arguments = null) { if (!array_key_exists($operationAlias, $this->operationsDefinitions)) { - throw new OperationException('Unrecognized operation', OperationException::UNAVAILABLE_OPERATION); + throw new OperationException( + sprintf('Unrecognized operation "%s"', $operationAlias), + OperationException::UNAVAILABLE_OPERATION + ); } return $this->objectManager->create($this->operationsDefinitions[$operationAlias], ['data' => $arguments]); } diff --git a/dev/tools/Magento/Tools/Di/Compiler/Config/Reader.php b/dev/tools/Magento/Tools/Di/Compiler/Config/Reader.php index 1808cc7b987b4..dbaaa885a4f00 100644 --- a/dev/tools/Magento/Tools/Di/Compiler/Config/Reader.php +++ b/dev/tools/Magento/Tools/Di/Compiler/Config/Reader.php @@ -66,17 +66,15 @@ public function __construct( * * @param DefinitionsCollection $definitionsCollection * @param string $areaCode - * @param bool $extendConfig * * @return array */ public function generateCachePerScope( DefinitionsCollection $definitionsCollection, - $areaCode, - $extendConfig = false + $areaCode ) { $areaConfig = clone $this->diContainerConfig; - if ($extendConfig) { + if ($areaCode !== App\Area::AREA_GLOBAL) { $areaConfig->extend($this->configLoader->load($areaCode)); } diff --git a/lib/internal/Magento/Framework/App/Console/Response.php b/lib/internal/Magento/Framework/App/Console/Response.php index 1da4034b6038b..4d6d64482dc59 100644 --- a/lib/internal/Magento/Framework/App/Console/Response.php +++ b/lib/internal/Magento/Framework/App/Console/Response.php @@ -20,6 +20,16 @@ class Response implements \Magento\Framework\App\ResponseInterface */ protected $code = 0; + /** + * Success code + */ + const SUCCESS = 0; + + /** + * Error code + */ + const ERROR = 255; + /** * Text to output on send response * From 4fbb799fb6d72649d099c9fa208652a2a89201e5 Mon Sep 17 00:00:00 2001 From: Iryna Savchenko Date: Mon, 22 Dec 2014 16:27:09 +0200 Subject: [PATCH 03/29] MAGETWO-31559: [TD] Removing NominalItems usage --- .../Magento/Checkout/Block/Total/Nominal.php | 140 ------------------ app/code/Magento/Checkout/etc/sales.xml | 15 -- .../frontend/templates/total/nominal.phtml | 32 ---- .../Magento/Multishipping/Helper/Data.php | 3 +- .../Payment/Model/Cart/SalesModel/Quote.php | 2 +- .../Helper/Shortcut/CheckoutValidator.php | 4 +- .../Magento/Paypal/Model/Express/Checkout.php | 6 +- .../Sales/Api/Data/OrderItemInterface.php | 8 - app/code/Magento/Sales/Model/Config.php | 2 +- .../Magento/Sales/Model/Config/Converter.php | 2 +- .../Magento/Sales/Model/Config/Reader.php | 2 +- .../Magento/Sales/Model/ConfigInterface.php | 2 +- app/code/Magento/Sales/Model/Order.php | 15 -- app/code/Magento/Sales/Model/Order/Item.php | 11 -- .../Magento/Sales/Model/Order/Payment.php | 18 +-- app/code/Magento/Sales/Model/Quote.php | 51 ------- .../Magento/Sales/Model/Quote/Address.php | 82 +--------- .../Quote/Address/Total/AbstractTotal.php | 4 +- .../Model/Quote/Address/Total/Nominal.php | 92 ------------ .../Quote/Address/Total/Nominal/Collector.php | 26 ---- .../Quote/Address/Total/Nominal/Shipping.php | 97 ------------ .../Quote/Address/Total/Nominal/Subtotal.php | 58 -------- .../Sales/Model/Quote/Item/AbstractItem.php | 22 --- .../Magento/Sales/Model/Service/Quote.php | 43 +----- app/code/Magento/Sales/etc/fieldset.xml | 3 - app/code/Magento/Sales/etc/sales.xml | 5 - .../Sales/sql/sales_setup/install-2.0.0.php | 6 - .../Model/Quote/Nominal/Discount.php | 40 ----- app/code/Magento/SalesRule/etc/sales.xml | 3 - .../Sales/Total/Quote/Nominal/Subtotal.php | 41 ----- .../Model/Sales/Total/Quote/Nominal/Tax.php | 66 --------- app/code/Magento/Tax/etc/sales.xml | 4 - .../Weee/Model/Total/Quote/Nominal/Weee.php | 37 ----- app/code/Magento/Weee/etc/sales.xml | 3 - .../Core/Model/Fieldset/_files/fieldset.xml | 3 - .../Fieldset/_files/invalid_fieldset.xml | 3 - .../Test/Legacy/_files/obsolete_classes.php | 8 + .../Test/Legacy/_files/obsolete_methods.php | 4 + .../Test/Legacy/_files/obsolete_paths.php | 8 + .../Php/_files/phpcpd/blacklist/common.txt | 2 - .../Magento/Multishipping/Helper/DataTest.php | 21 +-- .../Model/Cart/SalesModel/QuoteTest.php | 15 +- .../Helper/Shortcut/CheckoutValidatorTest.php | 5 +- .../Config/_files/core_totals_config.php | 3 +- .../Config/_files/custom_totals_config.php | 6 +- .../Quote/Address/Total/SubtotalTest.php | 4 +- .../SalesRule/Model/Quote/DiscountTest.php | 16 +- .../Model/Quote/Nominal/DiscountTest.php | 134 ----------------- .../Magento/SalesRule/Model/ValidatorTest.php | 3 +- .../Model/_files/quote_item_downloadable.php | 1 - .../Model/_files/quote_item_simple.php | 1 - .../Model/Sales/Total/Quote/ShippingTest.php | 2 +- .../Model/Sales/Total/Quote/SubtotalTest.php | 6 +- .../Tax/Model/Sales/Total/Quote/TaxTest.php | 14 +- .../Weee/Model/Total/Quote/WeeeTaxTest.php | 4 +- .../Weee/Model/Total/Quote/WeeeTest.php | 4 +- 56 files changed, 86 insertions(+), 1126 deletions(-) delete mode 100644 app/code/Magento/Checkout/Block/Total/Nominal.php delete mode 100644 app/code/Magento/Checkout/etc/sales.xml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/total/nominal.phtml delete mode 100644 app/code/Magento/Sales/Model/Quote/Address/Total/Nominal.php delete mode 100644 app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php delete mode 100644 app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Shipping.php delete mode 100644 app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php delete mode 100644 app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php delete mode 100644 app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php delete mode 100644 app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Tax.php delete mode 100644 app/code/Magento/Weee/Model/Total/Quote/Nominal/Weee.php delete mode 100644 dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/Nominal/DiscountTest.php diff --git a/app/code/Magento/Checkout/Block/Total/Nominal.php b/app/code/Magento/Checkout/Block/Total/Nominal.php deleted file mode 100644 index e77ae71bb9e83..0000000000000 --- a/app/code/Magento/Checkout/Block/Total/Nominal.php +++ /dev/null @@ -1,140 +0,0 @@ -priceCurrency = $priceCurrency; - parent::__construct($context, $customerSession, $checkoutSession, $salesConfig, $data); - } - - /** - * Getter for a quote item name - * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $quoteItem - * @return string - */ - public function getItemName(\Magento\Sales\Model\Quote\Item\AbstractItem $quoteItem) - { - return $quoteItem->getName(); - } - - /** - * Getter for a quote item row total - * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $quoteItem - * @return float - */ - public function getItemRowTotal(\Magento\Sales\Model\Quote\Item\AbstractItem $quoteItem) - { - return $quoteItem->getNominalRowTotal(); - } - - /** - * Getter for nominal total item details - * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $quoteItem - * @return array - */ - public function getTotalItemDetails(\Magento\Sales\Model\Quote\Item\AbstractItem $quoteItem) - { - return $quoteItem->getNominalTotalDetails(); - } - - /** - * Getter for details row label - * - * @param \Magento\Framework\Object $row - * @return string - */ - public function getItemDetailsRowLabel(\Magento\Framework\Object $row) - { - return $row->getLabel(); - } - - /** - * Getter for details row amount - * - * @param \Magento\Framework\Object $row - * @return string - */ - public function getItemDetailsRowAmount(\Magento\Framework\Object $row) - { - return $row->getAmount(); - } - - /** - * Getter for details row compounded state - * - * @param \Magento\Framework\Object $row - * @return bool - */ - public function getItemDetailsRowIsCompounded(\Magento\Framework\Object $row) - { - return $row->getIsCompounded(); - } - - /** - * Format an amount without container - * - * @param float $amount - * @return string - */ - public function formatPrice($amount) - { - return $this->priceCurrency->format($amount, false); - } - - /** - * Import total data into the block, if there are items - * - * @return string - */ - protected function _toHtml() - { - $total = $this->getTotal(); - $items = $total->getItems(); - if ($items) { - foreach ($total->getData() as $key => $value) { - $this->setData("total_{$key}", $value); - } - return parent::_toHtml(); - } - return ''; - } -} diff --git a/app/code/Magento/Checkout/etc/sales.xml b/app/code/Magento/Checkout/etc/sales.xml deleted file mode 100644 index f4efacb1ebe70..0000000000000 --- a/app/code/Magento/Checkout/etc/sales.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - - - -
-
diff --git a/app/code/Magento/Checkout/view/frontend/templates/total/nominal.phtml b/app/code/Magento/Checkout/view/frontend/templates/total/nominal.phtml deleted file mode 100644 index cf2381900e9c0..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/total/nominal.phtml +++ /dev/null @@ -1,32 +0,0 @@ - - - - getRenderingArea() == $this->getTotalArea()) ? '%s' : '%s', $this->escapeHtml($this->getTotalTitle())) ?> - - -getTotalItems() as $i => $item): ?> - getTotalItemDetails($item) as $j => $row):?> - - - escapeHtml($this->getItemDetailsRowLabel($row)) ?> - - - formatPrice($this->getItemDetailsRowAmount($row)) ?> - - - - - -
escapeHtml($this->getItemName($item)); ?>
- - - helper('Magento\Checkout\Helper\Data')->formatPrice($this->getItemRowTotal($item)) ?> - - - diff --git a/app/code/Magento/Multishipping/Helper/Data.php b/app/code/Magento/Multishipping/Helper/Data.php index fe169a55d151f..80fd974f75c58 100644 --- a/app/code/Magento/Multishipping/Helper/Data.php +++ b/app/code/Magento/Multishipping/Helper/Data.php @@ -86,7 +86,6 @@ public function isMultishippingCheckoutAvailable() true ) && $quote->getItemsSummaryQty() - $quote->getItemVirtualQty() > 0 && - $quote->getItemsSummaryQty() <= $this->getMaximumQty() && - !$quote->hasNominalItems(); + $quote->getItemsSummaryQty() <= $this->getMaximumQty(); } } diff --git a/app/code/Magento/Payment/Model/Cart/SalesModel/Quote.php b/app/code/Magento/Payment/Model/Cart/SalesModel/Quote.php index e8ef392426b0c..6eb457ebf1a50 100644 --- a/app/code/Magento/Payment/Model/Cart/SalesModel/Quote.php +++ b/app/code/Magento/Payment/Model/Cart/SalesModel/Quote.php @@ -49,7 +49,7 @@ public function getAllItems() 'parent_item' => $item->getParentItem(), 'name' => $item->getName(), 'qty' => (int)$item->getTotalQty(), - 'price' => $item->isNominal() ? 0 : (double)$item->getBaseCalculationPrice(), + 'price' => (double)$item->getBaseCalculationPrice(), 'original_item' => $item, ] ); diff --git a/app/code/Magento/Paypal/Helper/Shortcut/CheckoutValidator.php b/app/code/Magento/Paypal/Helper/Shortcut/CheckoutValidator.php index 73488eddcea3d..bbebe198b8068 100644 --- a/app/code/Magento/Paypal/Helper/Shortcut/CheckoutValidator.php +++ b/app/code/Magento/Paypal/Helper/Shortcut/CheckoutValidator.php @@ -81,9 +81,7 @@ public function isQuoteSummaryValid($isInCatalog) { $quote = $isInCatalog ? null : $this->_checkoutSession->getQuote(); // validate minimum quote amount and validate quote for zero grandtotal - if (null !== $quote && (!$quote->validateMinimumAmount() || - !$quote->getGrandTotal() && !$quote->hasNominalItems()) - ) { + if (null !== $quote && (!$quote->validateMinimumAmount() || !$quote->getGrandTotal())) { return false; } return true; diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index f9eff10bbdb2f..d3b69790d47cd 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -485,7 +485,7 @@ public function start($returnUrl, $cancelUrl, $button = null) { $this->_quote->collectTotals(); - if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) { + if (!$this->_quote->getGrandTotal()) { throw new \Magento\Framework\Model\Exception( __( 'PayPal can\'t process orders with a zero balance due. ' @@ -563,7 +563,7 @@ public function start($returnUrl, $cancelUrl, $button = null) && $this->_config->getConfigValue('transferShippingOptions') && !empty($cartItems) ) { - if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) { + if (!$this->_quote->getIsVirtual()) { $options = $this->_prepareShippingOptions($address, true); if ($options) { $this->_api->setShippingOptionsCallbackUrl( @@ -959,7 +959,7 @@ protected function _setExportedAddressData($address, $exportedAddress) */ protected function _setBillingAgreementRequest() { - if (!$this->_customerId || $this->_quote->hasNominalItems()) { + if (!$this->_customerId) { return $this; } diff --git a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php index 30fa2b74033f8..277e4b5805427 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php @@ -74,7 +74,6 @@ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterf const BASE_HIDDEN_TAX_INVOICED = 'base_hidden_tax_invoiced'; const HIDDEN_TAX_REFUNDED = 'hidden_tax_refunded'; const BASE_HIDDEN_TAX_REFUNDED = 'base_hidden_tax_refunded'; - const IS_NOMINAL = 'is_nominal'; const TAX_CANCELED = 'tax_canceled'; const HIDDEN_TAX_CANCELED = 'hidden_tax_canceled'; const TAX_REFUNDED = 'tax_refunded'; @@ -464,13 +463,6 @@ public function getHiddenTaxInvoiced(); */ public function getHiddenTaxRefunded(); - /** - * Returns is_nominal - * - * @return int - */ - public function getIsNominal(); - /** * Returns is_qty_decimal * diff --git a/app/code/Magento/Sales/Model/Config.php b/app/code/Magento/Sales/Model/Config.php index 4c8fcbc65ab49..7a55441ac7a7a 100644 --- a/app/code/Magento/Sales/Model/Config.php +++ b/app/code/Magento/Sales/Model/Config.php @@ -48,7 +48,7 @@ public function getTotalsRenderer($section, $group, $code) /** * Retrieve totals for group - * e.g. quote, nominal_totals, etc + * e.g. quote, etc * * @param string $section * @param string $group diff --git a/app/code/Magento/Sales/Model/Config/Converter.php b/app/code/Magento/Sales/Model/Config/Converter.php index 508b547132ee0..be3cb7e2cf80f 100644 --- a/app/code/Magento/Sales/Model/Config/Converter.php +++ b/app/code/Magento/Sales/Model/Config/Converter.php @@ -4,7 +4,7 @@ */ /** - * Converts sales totals (incl. nominal, creditmemo, invoice) from \DOMDocument to array + * Converts sales totals (incl. creditmemo, invoice) from \DOMDocument to array */ namespace Magento\Sales\Model\Config; diff --git a/app/code/Magento/Sales/Model/Config/Reader.php b/app/code/Magento/Sales/Model/Config/Reader.php index 8f1c904e125d0..ffa12dac062e7 100644 --- a/app/code/Magento/Sales/Model/Config/Reader.php +++ b/app/code/Magento/Sales/Model/Config/Reader.php @@ -4,7 +4,7 @@ */ /** - * Sales configuration filesystem loader. Loads all totals (incl. nominal, creditmemo, invoice) + * Sales configuration filesystem loader. Loads all totals (incl. creditmemo, invoice) * configuration from XML file */ namespace Magento\Sales\Model\Config; diff --git a/app/code/Magento/Sales/Model/ConfigInterface.php b/app/code/Magento/Sales/Model/ConfigInterface.php index d571d71aa2421..f344fe1c949dd 100644 --- a/app/code/Magento/Sales/Model/ConfigInterface.php +++ b/app/code/Magento/Sales/Model/ConfigInterface.php @@ -18,7 +18,7 @@ public function getTotalsRenderer($section, $group, $code); /** * Retrieve totals for group - * e.g. quote, nominal_totals, etc + * e.g. quote, etc * * @param string $section * @param string $group diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 540409a35baf4..19e0bbdf877f7 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -1490,21 +1490,6 @@ public function addItem(\Magento\Sales\Model\Order\Item $item) return $this; } - /** - * Whether the order has nominal items only - * - * @return bool - */ - public function isNominal() - { - foreach ($this->getAllVisibleItems() as $item) { - if ('0' == $item->getIsNominal()) { - return false; - } - } - return true; - } - /*********************** PAYMENTS ***************************/ /** diff --git a/app/code/Magento/Sales/Model/Order/Item.php b/app/code/Magento/Sales/Model/Order/Item.php index dd313aff3eabb..04a79d7f8c848 100644 --- a/app/code/Magento/Sales/Model/Order/Item.php +++ b/app/code/Magento/Sales/Model/Order/Item.php @@ -87,7 +87,6 @@ * @method \Magento\Sales\Model\Order\Item setBaseHiddenTaxInvoiced(float $value) * @method \Magento\Sales\Model\Order\Item setHiddenTaxRefunded(float $value) * @method \Magento\Sales\Model\Order\Item setBaseHiddenTaxRefunded(float $value) - * @method \Magento\Sales\Model\Order\Item setIsNominal(int $value) * @method \Magento\Sales\Model\Order\Item setTaxCanceled(float $value) * @method \Magento\Sales\Model\Order\Item setHiddenTaxCanceled(float $value) * @method \Magento\Sales\Model\Order\Item setTaxRefunded(float $value) @@ -1271,16 +1270,6 @@ public function getHiddenTaxRefunded() return $this->getData(OrderItemInterface::HIDDEN_TAX_REFUNDED); } - /** - * Returns is_nominal - * - * @return int - */ - public function getIsNominal() - { - return $this->getData(OrderItemInterface::IS_NOMINAL); - } - /** * Returns is_qty_decimal * diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index d4ed96c547cbf..6061b644b1a3b 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -470,12 +470,9 @@ public function capture($invoice) $invoice->setIsPaid(true); $this->_updateTotals(['base_amount_paid_online' => $amountToCapture]); } - if ($order->isNominal()) { - $message = $this->_prependMessage(__('An order with subscription items was registered.')); - } else { - $message = $this->_prependMessage($message); - $message = $this->_appendTransactionToMessage($transaction, $message); - } + $message = $this->_prependMessage($message); + $message = $this->_appendTransactionToMessage($transaction, $message); + $order->setState($state, $status, $message); $this->getMethodInstance()->processInvoice($invoice, $this); return $this; @@ -1176,12 +1173,9 @@ protected function _authorize($isOnline, $amount) // update transactions, order state and add comments $transaction = $this->_addTransaction(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH); - if ($order->isNominal()) { - $message = $this->_prependMessage(__('An order with subscription items was registered.')); - } else { - $message = $this->_prependMessage($message); - $message = $this->_appendTransactionToMessage($transaction, $message); - } + $message = $this->_prependMessage($message); + $message = $this->_appendTransactionToMessage($transaction, $message); + $order->setState($state, $status, $message); return $this; diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index 1f94e48474048..fffd2246fa52d 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -1244,22 +1244,6 @@ public function removeAllItems() */ public function addItem(\Magento\Sales\Model\Quote\Item $item) { - /** - * Temporary workaround for purchase process: it is too dangerous to purchase more than one nominal item - * or a mixture of nominal and non-nominal items, although technically possible. - * - * The problem is that currently it is implemented as sequential submission of nominal items and order, - * by one click. It makes logically impossible to make the process of the purchase failsafe. - * Proper solution is to submit items one by one with customer confirmation each time. - */ - if ($item->isNominal() && $this->hasItems() || $this->hasNominalItems()) { - throw new \Magento\Framework\Model\Exception( - // @codingStandardsIgnoreStart - __('Sorry, but items with payment agreements must be ordered one at a time To continue, please remove or buy the other items in your cart, then order this item by itself.') - // @codingStandardsIgnoreEnd - ); - } - $item->setQuote($this); if (!$item->getId()) { $this->getItemsCollection()->addItem($item); @@ -2188,41 +2172,6 @@ public function merge(Quote $quote) return $this; } - /** - * Getter whether quote has nominal items - * Can bypass treating virtual items as nominal - * - * @param bool $countVirtual - * @return bool - */ - public function hasNominalItems($countVirtual = true) - { - foreach ($this->getAllVisibleItems() as $item) { - if ($item->isNominal()) { - if (!$countVirtual && $item->getProduct()->isVirtual()) { - continue; - } - return true; - } - } - return false; - } - - /** - * Whether quote has nominal items only - * - * @return bool - */ - public function isNominal() - { - foreach ($this->getAllVisibleItems() as $item) { - if (!$item->isNominal()) { - return false; - } - } - return true; - } - /** * @return $this */ diff --git a/app/code/Magento/Sales/Model/Quote/Address.php b/app/code/Magento/Sales/Model/Quote/Address.php index a362afd5ea134..e39b9e6b54391 100644 --- a/app/code/Magento/Sales/Model/Quote/Address.php +++ b/app/code/Magento/Sales/Model/Quote/Address.php @@ -181,13 +181,6 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress */ protected $_baseTotalAmounts = []; - /** - * Whether to segregate by nominal items only - * - * @var bool - */ - protected $_nominalOnly = null; - /** * Core store config * @@ -570,23 +563,14 @@ public function getItemsCollection() */ public function getAllItems() { - // We calculate item list once and cache it in three arrays - all items, nominal, non-nominal - $cachedItems = $this->_nominalOnly ? 'nominal' : ($this->_nominalOnly === false ? 'nonnominal' : 'all'); + // We calculate item list once and cache it in three arrays - all items + $cachedItems = 'all'; $key = 'cached_items_' . $cachedItems; if (!$this->hasData($key)) { - // For compatibility we will use $this->_filterNominal to divide nominal items from non-nominal - // (because it can be overloaded) - // So keep current flag $this->_nominalOnly and restore it after cycle - $wasNominal = $this->_nominalOnly; - $this->_nominalOnly = true; - // Now $this->_filterNominal() will return positive values for nominal items - $quoteItems = $this->getQuote()->getItemsCollection(); $addressItems = $this->getItemsCollection(); $items = []; - $nominalItems = []; - $nonNominalItems = []; if ($this->getQuote()->getIsMultiShipping() && $addressItems->count() > 0) { foreach ($addressItems as $aItem) { if ($aItem->isDeleted()) { @@ -600,11 +584,6 @@ public function getAllItems() } } $items[] = $aItem; - if ($this->_filterNominal($aItem)) { - $nominalItems[] = $aItem; - } else { - $nonNominalItems[] = $aItem; - } } } else { /* @@ -621,21 +600,12 @@ public function getAllItems() continue; } $items[] = $qItem; - if ($this->_filterNominal($qItem)) { - $nominalItems[] = $qItem; - } else { - $nonNominalItems[] = $qItem; - } } } } // Cache calculated lists $this->setData('cached_items_all', $items); - $this->setData('cached_items_nominal', $nominalItems); - $this->setData('cached_items_nonnominal', $nonNominalItems); - - $this->_nominalOnly = $wasNominal; // Restore original value before we changed it } $items = $this->getData($key); @@ -643,51 +613,6 @@ public function getAllItems() return $items; } - /** - * Getter for all non-nominal items - * - * @return array - */ - public function getAllNonNominalItems() - { - $this->_nominalOnly = false; - $result = $this->getAllItems(); - $this->_nominalOnly = null; - return $result; - } - - /** - * Getter for all nominal items - * - * @return array - */ - public function getAllNominalItems() - { - $this->_nominalOnly = true; - $result = $this->getAllItems(); - $this->_nominalOnly = null; - - return $result; - } - - /** - * Segregate by nominal criteria - * - * Returns - * true: get nominals only - * false: get non-nominals only - * null: get all - * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item - * @return \Magento\Sales\Model\Quote\Item\AbstractItem|false - */ - protected function _filterNominal($item) - { - return null === $this->_nominalOnly || - false === $this->_nominalOnly && !$item->isNominal() || - true === $this->_nominalOnly && $item->isNominal() ? $item : false; - } - /** * Retrieve all visible items * @@ -860,9 +785,6 @@ public function getShippingRatesCollection() { if (null === $this->_rates) { $this->_rates = $this->_rateCollectionFactory->create()->setAddressFilter($this->getId()); - if ($this->getQuote()->hasNominalItems(false)) { - $this->_rates->setFixedOnlyFilter(true); - } if ($this->getId()) { foreach ($this->_rates as $rate) { $rate->setAddress($this); diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php b/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php index c17e6a943032a..64f0ba12aad31 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/AbstractTotal.php @@ -187,14 +187,14 @@ protected function _addBaseAmount($baseAmount) } /** - * Get all items except nominals + * Get all items * * @param \Magento\Sales\Model\Quote\Address $address * @return array */ protected function _getAddressItems(\Magento\Sales\Model\Quote\Address $address) { - return $address->getAllNonNominalItems(); + return $address->getAllItems(); } /** diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal.php deleted file mode 100644 index f43a5a4da013a..0000000000000 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal.php +++ /dev/null @@ -1,92 +0,0 @@ -_collectorFactory = $collectorFactory; - } - - /** - * Invoke collector for nominal items - * - * @param \Magento\Sales\Model\Quote\Address $address - * @return $this - */ - public function collect(\Magento\Sales\Model\Quote\Address $address) - { - $collector = $this->_collectorFactory->create(['store' => $address->getQuote()->getStore()]); - - // invoke nominal totals - foreach ($collector->getCollectors() as $model) { - $model->collect($address); - } - - // aggregate collected amounts into one to have sort of grand total per item - foreach ($address->getAllNominalItems() as $item) { - $rowTotal = 0; - $baseRowTotal = 0; - $totalDetails = []; - foreach ($collector->getCollectors() as $model) { - $itemRowTotal = $model->getItemRowTotal($item); - if ($model->getIsItemRowTotalCompoundable($item)) { - $rowTotal += $itemRowTotal; - $baseRowTotal += $model->getItemBaseRowTotal($item); - $isCompounded = true; - } else { - $isCompounded = false; - } - if ((double)$itemRowTotal > 0 && ($label = $model->getLabel())) { - $totalDetails[] = new \Magento\Framework\Object( - ['label' => $label, 'amount' => $itemRowTotal, 'is_compounded' => $isCompounded] - ); - } - } - $item->setNominalRowTotal($rowTotal); - $item->setBaseNominalRowTotal($baseRowTotal); - $item->setNominalTotalDetails($totalDetails); - } - - return $this; - } - - /** - * Fetch collected nominal items - * - * @param \Magento\Sales\Model\Quote\Address $address - * @return $this - */ - public function fetch(\Magento\Sales\Model\Quote\Address $address) - { - $items = $address->getAllNominalItems(); - if ($items) { - $address->addTotal( - [ - 'code' => $this->getCode(), - 'title' => __('Subscription Items'), - 'items' => $items, - 'area' => 'footer', - ] - ); - } - return $this; - } -} diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php deleted file mode 100644 index 0e10b1658ccee..0000000000000 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php +++ /dev/null @@ -1,26 +0,0 @@ -getAllNominalItems(); - if (!count($items)) { - return $this; - } - - // estimate quote with all address items to get their row weights - $this->_shouldGetAllItems = true; - parent::collect($address); - $address->setCollectShippingRates(true); - $this->_shouldGetAllItems = false; - // now $items contains row weight information - - // collect shipping rates for each item individually - foreach ($items as $item) { - if (!$item->getProduct()->isVirtual()) { - $address->requestShippingRates($item); - $baseAmount = $item->getBaseShippingAmount(); - if ($baseAmount) { - $item->setShippingAmount( - $this->priceCurrency->convert($baseAmount, $address->getQuote()->getStore()) - ); - } - } - } - - return $this; - } - - /** - * Don't fetch anything - * - * @param \Magento\Sales\Model\Quote\Address $address - * @return array - */ - public function fetch(\Magento\Sales\Model\Quote\Address $address) - { - return \Magento\Sales\Model\Quote\Address\Total\AbstractTotal::fetch($address); - } - - /** - * Get nominal items only or indeed get all items, depending on current logic requirements - * - * @param \Magento\Sales\Model\Quote\Address $address - * @return array - */ - protected function _getAddressItems(\Magento\Sales\Model\Quote\Address $address) - { - if ($this->_shouldGetAllItems) { - return $address->getAllItems(); - } - return $address->getAllNominalItems(); - } -} diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php deleted file mode 100644 index d47bd5813191f..0000000000000 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Subtotal.php +++ /dev/null @@ -1,58 +0,0 @@ -getAllNominalItems(); - } -} diff --git a/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php b/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php index 796cbcda8abbc..d023eb5087733 100644 --- a/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php +++ b/app/code/Magento/Sales/Model/Quote/Item/AbstractItem.php @@ -483,28 +483,6 @@ public function getBaseCalculationPriceOriginal() return $this->_getData('base_calculation_price'); } - /** - * Get whether the item is nominal - * TODO: fix for multishipping checkout - * - * @return bool - */ - public function isNominal() - { - return false; - } - - /** - * Data getter for 'is_nominal' - * Used for converting item to order item - * - * @return int - */ - public function getIsNominal() - { - return (int)$this->isNominal(); - } - /** * Get original price (retrieved from product) for item. * Original price value is in quote selected currency diff --git a/app/code/Magento/Sales/Model/Service/Quote.php b/app/code/Magento/Sales/Model/Service/Quote.php index f2872f9cdf2ee..9b602f7ab7d40 100644 --- a/app/code/Magento/Sales/Model/Service/Quote.php +++ b/app/code/Magento/Sales/Model/Service/Quote.php @@ -39,7 +39,7 @@ class Quote protected $_order = null; /** - * If it is true, quote will be inactivate after submitting order or nominal items + * If it is true, quote will be inactivate after submitting order * * @var bool */ @@ -212,7 +212,6 @@ protected function prepareCustomerData(\Magento\Sales\Model\Quote $quote) */ public function submitOrderWithDataObject() { - $this->_deleteNominalItems(); $this->_validate(); $quote = $this->_quote; $isVirtual = $quote->isVirtual(); @@ -301,22 +300,6 @@ public function submitOrderWithDataObject() return $order; } - /** - * Submit nominal items - * - * @return void - */ - public function submitNominalItems() - { - $this->_validate(); - $this->_eventManager->dispatch( - 'sales_model_service_quote_submit_nominal_items', - ['quote' => $this->_quote] - ); - $this->_inactivateQuote(); - $this->_deleteNominalItems(); - } - /** * Submit all available items * All created items will be set to the object @@ -326,16 +309,6 @@ public function submitNominalItems() */ public function submitAllWithDataObject() { - // don't allow submitNominalItems() to inactivate quote - $inactivateQuoteOld = $this->_shouldInactivateQuote; - $this->_shouldInactivateQuote = false; - try { - $this->submitNominalItems(); - $this->_shouldInactivateQuote = $inactivateQuoteOld; - } catch (\Exception $e) { - $this->_shouldInactivateQuote = $inactivateQuoteOld; - throw $e; - } // no need to submit the order if there are no normal items remained if (!$this->_quote->getAllVisibleItems()) { $this->_inactivateQuote(); @@ -403,18 +376,4 @@ protected function _validate() return $this; } - - /** - * Get rid of all nominal items - * - * @return void - */ - protected function _deleteNominalItems() - { - foreach ($this->_quote->getAllVisibleItems() as $item) { - if ($item->isNominal()) { - $item->isDeleted(true); - } - } - } } diff --git a/app/code/Magento/Sales/etc/fieldset.xml b/app/code/Magento/Sales/etc/fieldset.xml index 253cc3e865f13..fdb65abac32fb 100644 --- a/app/code/Magento/Sales/etc/fieldset.xml +++ b/app/code/Magento/Sales/etc/fieldset.xml @@ -478,9 +478,6 @@ - - -
diff --git a/app/code/Magento/Sales/etc/sales.xml b/app/code/Magento/Sales/etc/sales.xml index db2705fcf755d..aecc952f5eb14 100644 --- a/app/code/Magento/Sales/etc/sales.xml +++ b/app/code/Magento/Sales/etc/sales.xml @@ -7,15 +7,10 @@
- - - - -
diff --git a/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php index 6c0e7fb3e6c0e..f5666e119b6d4 100644 --- a/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php +++ b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php @@ -1634,12 +1634,6 @@ '12,4', [], 'Base Hidden Tax Refunded' -)->addColumn( - 'is_nominal', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Is Nominal' )->addColumn( 'tax_canceled', \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, diff --git a/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php deleted file mode 100644 index 9fc4a49966109..0000000000000 --- a/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php +++ /dev/null @@ -1,40 +0,0 @@ -getAllNominalItems(); - } -} diff --git a/app/code/Magento/SalesRule/etc/sales.xml b/app/code/Magento/SalesRule/etc/sales.xml index d28df9b487f6b..0e9c357bf3c4b 100644 --- a/app/code/Magento/SalesRule/etc/sales.xml +++ b/app/code/Magento/SalesRule/etc/sales.xml @@ -9,8 +9,5 @@ - - -
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php deleted file mode 100644 index 856b36df7e4b3..0000000000000 --- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php +++ /dev/null @@ -1,41 +0,0 @@ -getAllNominalItems(); - } -} diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Tax.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Tax.php deleted file mode 100644 index 6859e3085763e..0000000000000 --- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Tax.php +++ /dev/null @@ -1,66 +0,0 @@ -getAllNominalItems(); - } - - /** - * Process model configuration array - * - * This method can be used for changing totals collect sort order - * - * @param array $config - * @param int|string|\Magento\Store\Model\Store $store - * @return array - */ - public function processConfigArray($config, $store) - { - /** - * Nominal totals use sort_order configuration node to define the order (not before or after nodes) - * If there is a requirement to change the order, in which nominal total is calculated, change sort_order - */ - return $config; - } -} diff --git a/app/code/Magento/Tax/etc/sales.xml b/app/code/Magento/Tax/etc/sales.xml index 6be998ca902d9..73a1150f39da8 100644 --- a/app/code/Magento/Tax/etc/sales.xml +++ b/app/code/Magento/Tax/etc/sales.xml @@ -30,9 +30,5 @@ - - - - diff --git a/app/code/Magento/Weee/Model/Total/Quote/Nominal/Weee.php b/app/code/Magento/Weee/Model/Total/Quote/Nominal/Weee.php deleted file mode 100644 index 508918585e7c9..0000000000000 --- a/app/code/Magento/Weee/Model/Total/Quote/Nominal/Weee.php +++ /dev/null @@ -1,37 +0,0 @@ -getAllNominalItems(); - } -} diff --git a/app/code/Magento/Weee/etc/sales.xml b/app/code/Magento/Weee/etc/sales.xml index 708423af2771e..9268e8479e58b 100644 --- a/app/code/Magento/Weee/etc/sales.xml +++ b/app/code/Magento/Weee/etc/sales.xml @@ -10,9 +10,6 @@ - - -
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml index 6f492a6bad34b..086c78e0cefc4 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml @@ -478,9 +478,6 @@ - - - diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/invalid_fieldset.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/invalid_fieldset.xml index 5aa5f124d96e4..d62216c3dc979 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/invalid_fieldset.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/invalid_fieldset.xml @@ -478,9 +478,6 @@ * - - * - * diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 68e501b6893bb..e6959d7555018 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -2829,4 +2829,12 @@ ['Magento\Rule\Model\Rule', 'Magento\Rule\Model\AbstractModel'], ['Magento\Framework\App\Cache\State\Options', 'Magento\Framework\App\Cache\State'], ['Magento\Framework\App\Cache\State\OptionsInterface', 'Magento\Framework\App\Cache\State'], + ['Magento\Weee\Model\Total\Quote\Nominal\Weee'], + ['Magento\Tax\Model\Sales\Total\Quote\Nominal\Tax'], + ['Magento\Tax\Model\Sales\Total\Quote\Nominal\Subtotal'], + ['Magento\SalesRule\Model\Quote\Nominal\Discount'], + ['Magento\Sales\Model\Quote\Address\Total\Nominal'], + ['Magento\Sales\Model\Quote\Address\Total\Nominal\Collector'], + ['Magento\Sales\Model\Quote\Address\Total\Nominal\Shipping'], + ['Magento\Sales\Model\Quote\Address\Total\Nominal\Subtotal'], ]; diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 4ffcca5607537..4d14b40318db5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2001,4 +2001,8 @@ ['getScriptTranslation', 'Magento\Framework\LocaleInterface'], ['getCountryTranslation', 'Magento\Framework\LocaleInterface'], ['getTerritoryTranslation', 'Magento\Framework\LocaleInterface'], + ['getAllNonNominalItems', 'Magento\Sales\Model\Quote\Address'], + ['getAllNominalItems', 'Magento\Sales\Model\Quote\Address'], + ['isNominal', 'Magento\Sales\Model\Order\Item'], + ['getIsNominal', 'Magento\Sales\Model\Quote\Item\AbbstractItem'] ]; diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php index 28ca2290fe3f3..309eb498aec4a 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php @@ -233,4 +233,12 @@ ['/app/etc/local.xml', '/app/etc/config.php'], ['/app/code/Magento/RecurringPayment'], ['/app/code/Magento/PayPalRecurringPayment'], + ['/app/code/Magento/Weee/Model/Total/Quote/Nominal/Weee.php'], + ['/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Subtotal.php'], + ['/app/code/Magento/Tax/Model/Sales/Total/Quote/Nominal/Tax.php'], + ['/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php'], + ['/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal.php'], + ['/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal'], + ['/app/code/Magento/Checkout/Block/Total/Nominal.php'], + ['/app/code/Magento/Checkout/etc/sales.xml'], ]; diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt index 618a8a5fd2eb3..630cf55270507 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt @@ -113,8 +113,6 @@ lib/internal/Magento/Framework/App/Config Magento/Cron/Model Magento/SalesRule/Model/Resource/Report/Rule Magento/SalesRule/Model/Resource/Rule -Magento/SalesRule/Model/Quote/Nominal -Magento/Tax/Model/Sales/Total/Quote/Nominal Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit Magento/User/Block/User/Edit var/generation diff --git a/dev/tests/unit/testsuite/Magento/Multishipping/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Multishipping/Helper/DataTest.php index 27a1d9017b182..868c9a1c885d8 100644 --- a/dev/tests/unit/testsuite/Magento/Multishipping/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Multishipping/Helper/DataTest.php @@ -87,7 +87,6 @@ public function testGetMaximumQty() * @param int $itemsSummaryQty * @param int $itemVirtualQty * @param int $maximumQty - * @param bool $hasNominalItems * @dataProvider isMultishippingCheckoutAvailableDataProvider */ public function testIsMultishippingCheckoutAvailable( @@ -98,8 +97,7 @@ public function testIsMultishippingCheckoutAvailable( $validateMinimumAmount, $itemsSummaryQty, $itemVirtualQty, - $maximumQty, - $hasNominalItems + $maximumQty ) { $this->scopeConfigMock->expects( $this->once() @@ -158,7 +156,6 @@ public function testIsMultishippingCheckoutAvailable( )->will( $this->returnValue($maximumQty) ); - $this->quoteMock->expects($this->any())->method('hasNominalItems')->will($this->returnValue($hasNominalItems)); $this->assertEquals($result, $this->helper->isMultishippingCheckoutAvailable()); } @@ -171,15 +168,13 @@ public function testIsMultishippingCheckoutAvailable( public function isMultishippingCheckoutAvailableDataProvider() { return [ - [true, false, true, null, null, null, null, null, null], - [false, false, false, null, null, null, null, null, null], - [false, true, true, true, null, null, null, null, null], - [false, true, true, false, false, null, null, null, null], - [true, true, true, false, true, 2, 1, 3, null], - [false, true, true, false, true, 1, 2, null, null], - [false, true, true, false, true, 2, 1, 1, null], - [true, true, true, false, true, 2, 1, 3, false], - [false, true, true, false, true, 2, 1, 3, true] + [true, false, true, null, null, null, null, null], + [false, false, false, null, null, null, null, null], + [false, true, true, true, null, null, null, null], + [false, true, true, false, false, null, null, null], + [true, true, true, false, true, 2, 1, 3], + [false, true, true, false, true, 1, 2, null], + [false, true, true, false, true, 2, 1, 1], ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/QuoteTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/QuoteTest.php index a7d332047ac35..8ba42e784dad8 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/QuoteTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/QuoteTest.php @@ -55,17 +55,15 @@ public function testGetTaxContainer() } /** - * @param int $isNominal * @param string $pItem * @param string $name * @param int $qty * @param float $price * @dataProvider getAllItemsDataProvider */ - public function testGetAllItems($isNominal, $pItem, $name, $qty, $price) + public function testGetAllItems($pItem, $name, $qty, $price) { $itemMock = $this->getMock('Magento\Sales\Model\Quote\Item\AbstractItem', [], [], '', false); - $itemMock->expects($this->any())->method('isNominal')->will($this->returnValue($isNominal)); $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)); @@ -76,7 +74,7 @@ public function testGetAllItems($isNominal, $pItem, $name, $qty, $price) 'parent_item' => $pItem, 'name' => $name, 'qty' => $qty, - 'price' => $isNominal ? 0 : $price, + 'price' => $price, 'original_item' => $itemMock, ] ), @@ -88,12 +86,9 @@ public function testGetAllItems($isNominal, $pItem, $name, $qty, $price) public function getAllItemsDataProvider() { return [ - [0, 'parent item 1', 'name 1', 1, 0.1], - [1, 'parent item 1', 'name 1', 1, 0.1], - [0, 'parent item 2', 'name 2', 2, 1.2], - [1, 'parent item 2', 'name 2', 2, 1.2], - [0, 'parent item 3', 'name 3', 3, 2.3], - [1, 'parent item 3', 'name 3', 3, 2.3] + ['parent item 1', 'name 1', 1, 0.1], + ['parent item 2', 'name 2', 2, 1.2], + ['parent item 3', 'name 3', 3, 2.3], ]; } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Helper/Shortcut/CheckoutValidatorTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Helper/Shortcut/CheckoutValidatorTest.php index c68463b3ddefa..5b3d84d6ac084 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Helper/Shortcut/CheckoutValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Helper/Shortcut/CheckoutValidatorTest.php @@ -131,13 +131,12 @@ public function testIsQuoteSummaryValidGrandTotalFalse() { $isInCatalog = false; $quote = $this->getMockBuilder('Magento\Sales\Model\Quote')->disableOriginalConstructor() - ->setMethods(['getGrandTotal', 'validateMinimumAmount', 'hasNominalItems', '__wakeup']) + ->setMethods(['getGrandTotal', 'validateMinimumAmount', '__wakeup']) ->getMock(); $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote)); $quote->expects($this->once())->method('validateMinimumAmount')->will($this->returnValue(true)); $quote->expects($this->once())->method('getGrandTotal')->will($this->returnValue(0)); - $quote->expects($this->once())->method('hasNominalItems')->will($this->returnValue(false)); $this->assertFalse($this->checkoutValidator->isQuoteSummaryValid($isInCatalog)); } @@ -146,7 +145,7 @@ public function testIsQuoteSummaryValidTrue() { $isInCatalog = false; $quote = $this->getMockBuilder('Magento\Sales\Model\Quote')->disableOriginalConstructor() - ->setMethods(['getGrandTotal', 'validateMinimumAmount', 'hasNominalItems', '__wakeup']) + ->setMethods(['getGrandTotal', 'validateMinimumAmount', '__wakeup']) ->getMock(); $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote)); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/core_totals_config.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/core_totals_config.php index b3cc8e5c4abda..2d1af893c9f85 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/core_totals_config.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/core_totals_config.php @@ -5,8 +5,7 @@ return [ // Totals declared in Magento_Sales - 'nominal' => ['before' => ['subtotal'], 'after' => []], - 'subtotal' => ['after' => ['nominal'], 'before' => ['grand_total']], + 'subtotal' => ['after' => [], 'before' => ['grand_total']], 'shipping' => [ 'after' => ['subtotal', 'freeshipping', 'tax_subtotal'], 'before' => ['grand_total'], diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/custom_totals_config.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/custom_totals_config.php index c6bf9622ccc69..07cb6d940c28f 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/custom_totals_config.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Config/_files/custom_totals_config.php @@ -7,8 +7,8 @@ $result += [ 'handling' => ['after' => ['shipping'], 'before' => ['tax']], 'handling_tax' => ['after' => ['tax_shipping'], 'before' => ['tax']], - 'own_subtotal' => ['after' => ['nominal'], 'before' => ['subtotal']], - 'own_total1' => ['after' => ['nominal'], 'before' => ['subtotal']], - 'own_total2' => ['after' => ['nominal'], 'before' => ['subtotal']] + 'own_subtotal' => ['after' => [], 'before' => ['subtotal']], + 'own_total1' => ['after' => [], 'before' => ['subtotal']], + 'own_total2' => ['after' => [], 'before' => ['subtotal']] ]; return $result; diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php index c5d5f553b9c30..f49883375bec4 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/Total/SubtotalTest.php @@ -98,7 +98,7 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri '', false ); - $address->expects($this->any())->method('getAllNonNominalItems')->will( + $address->expects($this->any())->method('getAllItems')->will( $this->returnValue([$quoteItem]) ); @@ -134,7 +134,7 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri $quote->expects($this->any())->method('getStore')->will($this->returnValue($store)); $quoteItem->setProduct($product)->setQuote($quote)->setOriginalCustomPrice($price); - $address->expects($this->any())->method('getAllNonNominalItems')->will( + $address->expects($this->any())->method('getAllItems')->will( $this->returnValue([$quoteItem]) ); $address->expects($this->any())->method('getQuote')->will($this->returnValue($quote)); diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php index ba970d98d1865..17c8a66f0300c 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php @@ -112,13 +112,13 @@ public function testCollectItemNoDiscount() ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) + ->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') ->willReturn($quoteMock); $addressMock->expects($this->any()) - ->method('getAllNonNominalItems') + ->method('getAllItems') ->willReturn([$itemNoDiscount]); $addressMock->expects($this->any()) ->method('getShippingAmount') @@ -164,13 +164,13 @@ public function testCollectItemHasParent() ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) + ->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') ->willReturn($quoteMock); $addressMock->expects($this->any()) - ->method('getAllNonNominalItems') + ->method('getAllItems') ->willReturn([$itemWithParentId]); $addressMock->expects($this->any()) ->method('getShippingAmount') @@ -248,13 +248,13 @@ public function testCollectItemHasChildren($childItemData, $parentData, $expecte ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) + ->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') ->willReturn($quoteMock); $addressMock->expects($this->any()) - ->method('getAllNonNominalItems') + ->method('getAllItems') ->willReturn([$itemWithChildren]); $addressMock->expects($this->any()) ->method('getShippingAmount') @@ -367,13 +367,13 @@ public function testCollectItemHasNoChildren() ->getMock(); $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNonNominalItems', 'getShippingAmount', '__wakeup']) + ->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup']) ->getMock(); $addressMock->expects($this->any()) ->method('getQuote') ->willReturn($quoteMock); $addressMock->expects($this->any()) - ->method('getAllNonNominalItems') + ->method('getAllItems') ->willReturn([$itemWithChildren]); $addressMock->expects($this->any()) ->method('getShippingAmount') diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/Nominal/DiscountTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/Nominal/DiscountTest.php deleted file mode 100644 index f3a0877db6ad2..0000000000000 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/Nominal/DiscountTest.php +++ /dev/null @@ -1,134 +0,0 @@ -objectManager = new ObjectManager($this); - - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); - - $this->validatorMock = $this->getMockBuilder('Magento\SalesRule\Model\Validator') - ->disableOriginalConstructor() - ->setMethods( - [ - 'canApplyRules', - 'reset', - 'init', - 'initTotals', - 'sortItemsByPriority', - 'setSkipActionsValidation', - 'process', - 'processShippingAmount', - 'canApplyDiscount', - '__wakeup', - ] - ) - ->getMock(); - - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') - ->disableOriginalConstructor() - ->getMock(); - - /** @var \Magento\SalesRule\Model\Quote\Nominal\Discount $discount */ - $this->discount = $this->objectManager->getObject( - 'Magento\SalesRule\Model\Quote\Nominal\Discount', - [ - 'storeManager' => $this->storeManagerMock, - 'validator' => $this->validatorMock, - 'eventManager' => $this->eventManagerMock - ] - ); - } - - public function testFetch() - { - $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') - ->disableOriginalConstructor() - ->getMock(); - $this->assertInternalType('array', $this->discount->fetch($addressMock)); - } - - public function testGetNominalAddressItems() - { - $item = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') - ->disableOriginalConstructor() - ->setMethods(['__wakeup']) - ->getMock(); - - $this->validatorMock->expects($this->once()) - ->method('sortItemsByPriority') - ->willReturnArgument(0); - - $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') - ->disableOriginalConstructor() - ->setMethods(['getStore', '__wakeup']) - ->getMock(); - - $this->storeManagerMock->expects($this->once()) - ->method('getStore') - ->willReturn($storeMock); - - $quoteMock = $this->getMockBuilder('Magento\Sales\Model\Quote') - ->disableOriginalConstructor() - ->getMock(); - - $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') - ->disableOriginalConstructor() - ->setMethods(['getQuote', 'getAllNominalItems', 'getShippingAmount', '__wakeup']) - ->getMock(); - - $addressMock->expects($this->any()) - ->method('getQuote') - ->willReturn($quoteMock); - - $addressMock->expects($this->once()) - ->method('getAllNominalItems') - ->willReturn([$item]); - - $addressMock->expects($this->once()) - ->method('getShippingAmount') - ->willReturn(true); - - $this->assertInstanceOf( - 'Magento\SalesRule\Model\Quote\Discount', - $this->discount->collect($addressMock) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php index f8ca461891cbb..7440c65273dbf 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php @@ -134,12 +134,11 @@ protected function getQuoteItemMock() /** @var $quote \Magento\Sales\Model\Quote */ $quote = $this->getMock( 'Magento\Sales\Model\Quote', - ['hasNominalItems', 'getStoreId', '__wakeup'], + ['getStoreId', '__wakeup'], [], '', false ); - $quote->expects($this->any())->method('hasNominalItems')->will($this->returnValue(false)); $quote->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); $itemData = include $fixturePath . 'quote_item_downloadable.php'; diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_downloadable.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_downloadable.php index 04e6e27c49b58..3e6432941dfdd 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_downloadable.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_downloadable.php @@ -68,7 +68,6 @@ 'product' => null, 'tax_class_id' => '0', 'has_error' => false, - 'is_nominal' => false, 'base_calculation_price' => 8, 'calculation_price' => 8, 'converted_price' => 8, diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_simple.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_simple.php index 77f06254c39fa..5429a080dd068 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_simple.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/_files/quote_item_simple.php @@ -68,7 +68,6 @@ 'product' => null, 'tax_class_id' => '2', 'has_error' => false, - 'is_nominal' => false, 'base_calculation_price' => 10, 'calculation_price' => 10, 'converted_price' => 10, diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/ShippingTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/ShippingTest.php index b4bdb92c38593..8f591a04a03d6 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/ShippingTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/ShippingTest.php @@ -113,7 +113,7 @@ public function testCollectDoesNotCalculateTaxIfThereIsNoItemsRelatedToGivenAddr ] ); $addressMock = $this->getMockObject('Magento\Sales\Model\Quote\Address', [ - 'all_non_nominal_items' => [], + 'all_items' => [], 'shipping_tax_calculation_amount' => 100, 'base_shipping_tax_calculation_amount' => 200, 'shipping_discount_amount' => 10, diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php index 90f95e6e632c7..20d686ac83f90 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php @@ -112,7 +112,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods([ 'getAssociatedTaxables', 'getQuote', 'getBillingAddress', - 'getRegionId', 'getAllNonNominalItems', '__wakeup', + 'getRegionId', 'getAllItems', '__wakeup', 'getParentItem', ])->getMock(); @@ -127,7 +127,7 @@ protected function setUp() public function testCollectEmptyAddresses() { - $this->addressMock->expects($this->once())->method('getAllNonNominalItems')->willReturn(null); + $this->addressMock->expects($this->once())->method('getAllItems')->willReturn(null); $this->taxConfigMock->expects($this->never())->method('priceIncludesTax'); $this->model->collect($this->addressMock); } @@ -154,7 +154,7 @@ protected function checkGetAddressItems() { $customerTaxClassId = 2425; $this->addressMock->expects($this->atLeastOnce()) - ->method('getAllNonNominalItems')->willReturn([$this->addressMock]); + ->method('getAllItems')->willReturn([$this->addressMock]); // calls in populateAddressData() $this->quoteDetailsBuilder->expects($this->atLeastOnce())->method('setBillingAddress'); diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php index ae53fc86aff0f..34e528bf729a7 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php @@ -288,7 +288,7 @@ public function testCollect($itemData, $appliedRatesData, $taxDetailsData, $quot ->method('create') ->will($this->returnValue($address)); - $addressData["cached_items_nonnominal"] = $items; + $addressData["cached_items_all"] = $items; foreach ($addressData as $key => $value) { $address->setData($key, $value); } @@ -549,7 +549,7 @@ public function testMapQuoteExtraTaxables($itemData, $addressData) ->method('getBillingAddress') ->will($this->returnValue($address)); - $addressData["cached_items_nonnominal"] = $items; + $addressData["cached_items_all"] = $items; foreach ($addressData as $key => $value) { $address->setData($key, $value); } @@ -621,7 +621,7 @@ public function testFetch($appliedTaxesData, $addressData) $address = $this->getMock( '\Magento\Sales\Model\Quote\Address', [ - 'getAppliedTaxes', 'getQuote', 'getAllNonNominalItems', 'getGrandTotal', '__wakeup', + 'getAppliedTaxes', 'getQuote', 'getAllItems', 'getGrandTotal', '__wakeup', 'addTotal', 'getTaxAmount' ], [], @@ -638,7 +638,7 @@ public function testFetch($appliedTaxesData, $addressData) ->will($this->returnValue($quote)); $address ->expects($this->once()) - ->method('getAllNonNominalItems') + ->method('getAllItems') ->will($this->returnValue($items)); $address ->expects($this->any()) @@ -653,7 +653,7 @@ public function testFetch($appliedTaxesData, $addressData) ->method('getTaxAmount') ->will($this->returnValue(8)); - $addressData["cached_items_nonnominal"] = $items; + $addressData["cached_items_all"] = $items; foreach ($addressData as $key => $value) { $address->setData($key, $value); } @@ -712,7 +712,7 @@ public function testEmptyAddress() ->disableOriginalConstructor() ->setMethods( [ - 'getAllNonNominalItems', + 'getAllItems', '__wakeup', ] )->getMock(); @@ -729,7 +729,7 @@ public function testEmptyAddress() $address->setBaseSubtotalInclTax(1); $address->expects($this->once()) - ->method('getAllNonNominalItems') + ->method('getAllItems') ->will($this->returnValue([])); $objectManager = new ObjectManager($this); diff --git a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php index 6086e0a44b09a..0e13006a04f9a 100644 --- a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php +++ b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php @@ -124,7 +124,7 @@ protected function setupAddressMock($itemMock, $isWeeeTaxable, $itemData, $addre 'Magento\Sales\Model\Quote\Address', [ '__wakeup', - 'getAllNonNominalItems', + 'getAllItems', 'getQuote', 'getWeeeCodeToItemMap', 'getExtraTaxableDetails', @@ -179,7 +179,7 @@ protected function setupAddressMock($itemMock, $isWeeeTaxable, $itemData, $addre $storeMock->expects($this->any())->method('convertPrice')->will($this->returnArgument(0)); $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - $addressMock->expects($this->any())->method('getAllNonNominalItems')->will($this->returnValue([$itemMock])); + $addressMock->expects($this->any())->method('getAllItems')->will($this->returnValue([$itemMock])); $addressMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); $addressMock->expects($this->any())->method('getWeeeCodeToItemMap')->will($this->returnValue($map)); $addressMock->expects($this->any())->method('getExtraTaxableDetails')->will($this->returnValue($extraDetails)); diff --git a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php index 62935f81d6bf4..4bc97b939d180 100644 --- a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php +++ b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php @@ -118,7 +118,7 @@ protected function setupAddressMock($itemMock) 'Magento\Sales\Model\Quote\Address', [ '__wakeup', - 'getAllNonNominalItems', + 'getAllItems', 'getQuote', ], [], @@ -133,7 +133,7 @@ protected function setupAddressMock($itemMock) $this->priceCurrency->expects($this->any())->method('convert')->willReturnArgument(0); $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - $addressMock->expects($this->any())->method('getAllNonNominalItems')->will($this->returnValue([$itemMock])); + $addressMock->expects($this->any())->method('getAllItems')->will($this->returnValue([$itemMock])); $addressMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); return $addressMock; From 9a5fc0220f11190eb86784386f6332d05e58265d Mon Sep 17 00:00:00 2001 From: Iryna Savchenko Date: Mon, 22 Dec 2014 18:32:12 +0200 Subject: [PATCH 04/29] MAGETWO-31559: [TD] Removing NominalItems usage - add tests --- .../Magento/Sales/Model/QuoteTest.php | 29 +++++++++++ .../Magento/Sales/Model/Service/QuoteTest.php | 52 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Service/QuoteTest.php diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php index 2548b7a342ed8..683e203c4112b 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php @@ -1052,4 +1052,33 @@ public function testGetPaymentIsDeleted() $this->assertInstanceOf('\Magento\Sales\Model\Quote\Payment', $this->quote->getPayment()); } + + public function testAddItem() + { + $item = $this->getMock('Magento\Sales\Model\Quote\Item', ['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', + ['setQuote', 'addItem'], + [], + '', + false + ); + $itemsMock->expects($this->once()) + ->method('setQuote'); + $itemsMock->expects($this->once()) + ->method('addItem') + ->with($item); + $this->quoteItemCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($itemsMock); + $this->eventManagerMock->expects($this->once()) + ->method('dispatch'); + + $this->quote->addItem($item); + } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Service/QuoteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Service/QuoteTest.php new file mode 100644 index 0000000000000..ecb0bc895a3b5 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Service/QuoteTest.php @@ -0,0 +1,52 @@ +getMock('Magento\Sales\Model\Convert\QuoteFactory', ['create'], [], '', false); + $convertFactory->expects($this->once()) + ->method('create'); + $this->quoteMock = $this->getMock( + 'Magento\Sales\Model\Quote', + ['getAllVisibleItems', 'setIsActive'], + [], + '', + false + ); + $this->quoteService = $objectManager->getObject( + 'Magento\Sales\Model\Service\Quote', + ['quote' => $this->quoteMock, 'convertQuoteFactory' => $convertFactory] + ); + } + + public function testSubmitAllWithDataObject() + { + $this->quoteMock->expects($this->once()) + ->method('getAllVisibleItems') + ->willReturn(false); + $this->quoteMock->expects($this->once()) + ->method('setIsActive'); + $this->quoteService->submitAllWithDataObject(); + } +} From ee03d713a33909041e1c5d09b45e6b4878a4e72d Mon Sep 17 00:00:00 2001 From: Iryna Savchenko Date: Mon, 22 Dec 2014 19:10:19 +0200 Subject: [PATCH 05/29] MAGETWO-31559: [TD] Removing NominalItems usage - added update script --- .../Magento/Sales/sql/sales_setup/install-2.0.0.php | 6 ++++++ .../Magento/Sales/sql/sales_setup/update-2.0.1.php | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php diff --git a/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php index f5666e119b6d4..adec0e12680ca 100644 --- a/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php +++ b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php @@ -1646,6 +1646,12 @@ '12,4', [], 'Hidden Tax Canceled' +)->addColumn( + 'is_nominal', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['nullable' => false, 'default' => '0'], + 'Is Nominal' )->addColumn( 'tax_refunded', \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, diff --git a/app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php b/app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php new file mode 100644 index 0000000000000..f410c9bb38ef8 --- /dev/null +++ b/app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php @@ -0,0 +1,12 @@ +startSetup(); +/** + * update table 'sales_order_item' + */ +$table = $this->getConnection()->dropColumn('sales_order_item', 'is_nominal'); +$this->endSetup(); From 5ce12355e196db245edd880d364df9ad1430826c Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Tue, 23 Dec 2014 19:20:20 +0200 Subject: [PATCH 06/29] MAGETWO-31168: Investigate increase of checkout steps load time --- app/code/Magento/Checkout/Model/Type/Onepage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 00496f62cd207..be1c0019788c5 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -497,7 +497,7 @@ public function saveBilling($data, $customerAddressId) } } - $this->quoteRepository->save($this->getQuote()); + $address->save(); $this->getCheckout()->setStepData( 'billing', From d27bcf8b125ccd0534f879a71cde2082ecdb70ad Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Wed, 24 Dec 2014 12:33:15 +0200 Subject: [PATCH 07/29] MAGETWO-31111: Plugins configuration caching - fixed spaces code style --- dev/tools/Magento/Tools/Di/App/Compiler.php | 4 ++-- .../Magento/Tools/Di/App/Task/Operation/Interception.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/tools/Magento/Tools/Di/App/Compiler.php b/dev/tools/Magento/Tools/Di/App/Compiler.php index 215d5b42c6427..c106ad7dfb60f 100644 --- a/dev/tools/Magento/Tools/Di/App/Compiler.php +++ b/dev/tools/Magento/Tools/Di/App/Compiler.php @@ -65,12 +65,12 @@ public function launch() $operations = [ Task\OperationFactory::AREA => [ - BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' + BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' ], Task\OperationFactory::INTERCEPTION => BP . '/var/generation', Task\OperationFactory::RELATIONS => [ - BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' + BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' ], Task\OperationFactory::PLUGINS => BP . '/app' diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php index 99da5db890fec..a874543d798c0 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php @@ -30,6 +30,7 @@ class Interception implements OperationInterface /** * @param InterceptionConfigurationBuilder $interceptionConfigurationBuilder + * @param App\AreaList $areaList * @param string $data */ public function __construct( From 99b5fa93b5fe28a3238b976ebd57608baa6a91f9 Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Wed, 24 Dec 2014 12:50:28 +0200 Subject: [PATCH 08/29] MAGETWO-31111: Plugins configuration caching - removed php55 code which is not supported by php54 --- dev/tools/Magento/Tools/Di/App/Compiler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/tools/Magento/Tools/Di/App/Compiler.php b/dev/tools/Magento/Tools/Di/App/Compiler.php index c106ad7dfb60f..f23d792b4080e 100644 --- a/dev/tools/Magento/Tools/Di/App/Compiler.php +++ b/dev/tools/Magento/Tools/Di/App/Compiler.php @@ -89,10 +89,10 @@ public function launch() } catch (Task\OperationException $e) { $responseCode = Response::ERROR; $this->response->setBody($e->getMessage()); - } finally { - $this->response->setCode($responseCode); - return $this->response; } + + $this->response->setCode($responseCode); + return $this->response; } /** From 03772e43065363ff4e700fcbd1ab6b59faeccf7b Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Wed, 24 Dec 2014 14:14:54 +0200 Subject: [PATCH 09/29] MAGETWO-31111: Plugins configuration caching - fixed code style\design defects --- dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php | 1 - dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php index a874543d798c0..d88b05a3dbfa0 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Interception.php @@ -70,5 +70,4 @@ public function doOperation() $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration(get_declared_classes()); $generator->generateList($configuration); } - } diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php index b4972e47a9087..dea507d805a07 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php @@ -65,7 +65,7 @@ public function doOperation() $pluginScanner->addChild(new \Magento\Tools\Di\Code\Scanner\PluginScanner(), 'di'); $pluginDefinitions = []; $pluginList = $pluginScanner->collectEntities($files); - foreach ($pluginList as $type => $entityList) { + foreach ($pluginList as $entityList) { foreach ($entityList as $entity) { $pluginDefinitions[$entity] = $this->definitionRuntime->getMethodList($entity); } From 751a7254ea71beb99d97619d38fb87e3c4dcd996 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Wed, 24 Dec 2014 14:56:50 +0200 Subject: [PATCH 10/29] MAGETWO-31168: Investigate increase of checkout steps load time - save quote only when customer uses checkout method register --- app/code/Magento/Checkout/Model/Type/Onepage.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index be1c0019788c5..f968fadc3cec7 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -491,13 +491,19 @@ public function saveBilling($data, $customerAddressId) )->setCollectShippingRates( true )->collectTotals(); - $shipping->save(); + if ($this->getQuote()->getCheckoutMethod() != self::METHOD_REGISTER) { + $shipping->save(); + } $this->getCheckout()->setStepData('shipping', 'complete', true); break; } } - $address->save(); + if ($this->getQuote()->getCheckoutMethod() == self::METHOD_REGISTER) { + $this->quoteRepository->save($this->getQuote()); + } else { + $address->save(); + } $this->getCheckout()->setStepData( 'billing', From 31fd382aa8e031e114f8238ff0a4364f0067525f Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Wed, 24 Dec 2014 15:46:13 +0200 Subject: [PATCH 11/29] MAGETWO-31168: Investigate increase of checkout steps load time - fix for review --- app/code/Magento/Checkout/Model/Type/Onepage.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index f968fadc3cec7..892a6f74f839b 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -491,7 +491,7 @@ public function saveBilling($data, $customerAddressId) )->setCollectShippingRates( true )->collectTotals(); - if ($this->getQuote()->getCheckoutMethod() != self::METHOD_REGISTER) { + if (!$this->isCheckoutMethodRegister()) { $shipping->save(); } $this->getCheckout()->setStepData('shipping', 'complete', true); @@ -499,7 +499,7 @@ public function saveBilling($data, $customerAddressId) } } - if ($this->getQuote()->getCheckoutMethod() == self::METHOD_REGISTER) { + if ($this->isCheckoutMethodRegister()) { $this->quoteRepository->save($this->getQuote()); } else { $address->save(); @@ -522,6 +522,16 @@ public function saveBilling($data, $customerAddressId) return []; } + /** + * Check whether checkout method is "register" + * + * @return bool + */ + protected function isCheckoutMethodRegister() + { + return $this->getQuote()->getCheckoutMethod() == self::METHOD_REGISTER; + } + /** * Validate customer data and set some its data for further usage in quote * From 172dcb95269382f751144721e5b8492901b4dd62 Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Wed, 24 Dec 2014 16:46:54 +0200 Subject: [PATCH 12/29] MAGETWO-31111: Plugins configuration caching - fixed areas generation --- .../Magento/Framework/Interception/GeneralTest.php | 2 -- dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php | 2 +- dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php index bd54fecae3c2f..db762ae8bd1cc 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php @@ -5,8 +5,6 @@ */ namespace Magento\Framework\Interception; -use Magento\Framework\ObjectManager\Config\Config as ObjectManagerConfig; - /** * Class GeneralTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php index 001db59c8bf62..dea822e1f4f82 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php @@ -74,7 +74,7 @@ public function doOperation() $definitionsCollection->addCollection($this->getDefinitionsCollection($path)); } - $areaCodes = [App\Area::AREA_GLOBAL] + $this->areaList->getCodes(); + $areaCodes = array_merge([App\Area::AREA_GLOBAL], $this->areaList->getCodes()); foreach ($areaCodes as $areaCode) { $this->configWriter->write( $areaCode, diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php index dea507d805a07..2a1046856febd 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php @@ -8,7 +8,7 @@ use Magento\Tools\Di\App\Task\OperationInterface; use Magento\Tools\Di\Compiler\Config; -use Magento\Framework\Interception; +use Magento\Framework\Interception\Definition; class Plugins implements OperationInterface { @@ -23,7 +23,7 @@ class Plugins implements OperationInterface private $data = ''; /** - * @var Interception\Definition\Runtime + * @var Definition\Runtime */ private $definitionRuntime; @@ -34,12 +34,12 @@ class Plugins implements OperationInterface /** * @param Config\WriterInterface $configWriter - * @param Interception\Definition\Runtime $definitionRuntime + * @param Definition\Runtime $definitionRuntime * @param string $data */ public function __construct( Config\WriterInterface $configWriter, - Interception\Definition\Runtime $definitionRuntime, + Definition\Runtime $definitionRuntime, $data = '' ) { $this->configWriter = $configWriter; From ae0e6b7a32b64a5961d7ac4867944e6b89b1e54a Mon Sep 17 00:00:00 2001 From: Pavlo Cherniavskyi Date: Wed, 24 Dec 2014 18:49:26 +0200 Subject: [PATCH 13/29] MAGETWO-31559: [TD] Removing NominalItems usage -- unit tests and refactoring --- .../Magento/Sales/Model/Order/Payment.php | 4 +- .../Magento/Sales/Model/Order/PaymentTest.php | 298 +++++++++++++++--- 2 files changed, 253 insertions(+), 49 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 6061b644b1a3b..703f64b5e13b7 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -1151,13 +1151,14 @@ protected function _authorize($isOnline, $amount) // similar logic of "payment review" order as in capturing if ($this->getIsTransactionPending()) { + $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; $message = __( 'We will authorize %1 after the payment is approved at the payment gateway.', $this->_formatPrice($amount) ); - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; } else { if ($this->getIsFraudDetected()) { + $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; $message = __( 'Order is suspended as its authorizing amount %1 is suspected to be fraudulent.', $this->_formatPrice($amount, $this->getCurrencyCode()) @@ -1167,7 +1168,6 @@ protected function _authorize($isOnline, $amount) } } if ($this->getIsFraudDetected()) { - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; $status = \Magento\Sales\Model\Order::STATUS_FRAUD; } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/PaymentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/PaymentTest.php index b452ec13778ee..4c078953aa5eb 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/PaymentTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/PaymentTest.php @@ -6,67 +6,115 @@ /** * Class PaymentTest + * * @package Magento\Sales\Model\Order */ class PaymentTest extends \PHPUnit_Framework_TestCase { - /** - * @var Payment - */ - protected $payment; + /** @var Payment */ + private $payment; - /** - * @var \Magento\Payment\Helper\Data | \PHPUnit_Framework_MockObject_MockObject - */ - protected $helper; + /** @var \Magento\Payment\Helper\Data | \PHPUnit_Framework_MockObject_MockObject */ + private $helperMock; - /** - * @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject - */ - protected $eventManager; + /** @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject */ + private $eventManagerMock; + + /** @var \Magento\Directory\Model\PriceCurrency | \PHPUnit_Framework_MockObject_MockObject */ + private $priceCurrencyMock; + + /** @var \Magento\Sales\Model\Order | \PHPUnit_Framework_MockObject_MockObject $orderMock */ + private $orderMock; + + /** @var \Magento\Payment\Model\Method\AbstractMethod | \PHPUnit_Framework_MockObject_MockObject $orderMock */ + private $paymentMethodMock; protected function setUp() { - $objectManger = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') + ->disableOriginalConstructor() + ->getMock(); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $context = $this->getMockBuilder('Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->getMock(); - $context = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); $context->expects($this->once()) ->method('getEventDispatcher') - ->will($this->returnValue($this->eventManager)); + ->will($this->returnValue($this->eventManagerMock)); + + $this->helperMock = $this->getMockBuilder('Magento\Payment\Helper\Data') + ->disableOriginalConstructor() + ->setMethods(['getMethodInstance']) + ->getMock(); + + $this->priceCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\PriceCurrency') + ->disableOriginalConstructor() + ->setMethods(['format']) + ->getMock(); + + $this->priceCurrencyMock->expects($this->any()) + ->method('format') + ->willReturnCallback( + function ($value) { + return $value; + } + ); + + $this->paymentMethodMock = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') + ->disableOriginalConstructor() + ->setMethods([ + 'canVoid', + 'authorize', + 'getConfigData', + 'getConfigPaymentAction', + 'validate', + ]) + ->getMock(); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); - $this->helper = $this->getMock('Magento\Payment\Helper\Data', ['getMethodInstance'], [], '', false); + $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods([ + 'getConfig', + 'setState', + 'getStoreId', + 'getBaseGrandTotal', + 'getBaseCurrency', + 'getBaseCurrencyCode', + 'getTotalDue', + 'getBaseTotalDue', + ]) + ->getMock(); - $this->payment = $objectManger->getObject( + $this->payment = (new \Magento\TestFramework\Helper\ObjectManager($this))->getObject( 'Magento\Sales\Model\Order\Payment', [ - 'paymentData' => $this->helper, - 'context' => $context + 'context' => $context, + 'paymentData' => $this->helperMock, + 'priceCurrency' => $this->priceCurrencyMock, ] ); + + $this->payment->setMethod('any'); + $this->payment->setOrder($this->orderMock); } protected function tearDown() { - $this->payment = null; + unset($this->payment); } public function testCancel() { - $paymentMethod = $this->getMock('Magento\Payment\Model\Method\AbstractMethod', ['canVoid'], [], '', false); - $this->helper->expects($this->once())->method('getMethodInstance')->will($this->returnValue($paymentMethod)); - $this->payment->setMethod('any'); // check fix for partial refunds in Payflow Pro - $paymentMethod->expects( - $this->once() - )->method( - 'canVoid' - )->with( - new \PHPUnit_Framework_Constraint_IsIdentical($this->payment) - )->will( - $this->returnValue(false) - ); + $this->paymentMethodMock->expects($this->once()) + ->method('canVoid') + ->with($this->payment) + ->willReturn(false); $this->assertEquals($this->payment, $this->payment->cancel()); } @@ -74,36 +122,192 @@ public function testCancel() public function testPlace() { $newOrderStatus = 'new_status'; - /** @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject $orderConfig */ - $orderConfig = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false); - $orderConfig->expects($this->at(0)) + + /** @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject $orderConfigMock */ + $orderConfigMock = $this->getMockBuilder('Magento\Sales\Model\Order\Config') + ->disableOriginalConstructor() + ->setMethods(['getStateStatuses', 'getStateDefaultStatus']) + ->getMock(); + + $orderConfigMock->expects($this->once()) ->method('getStateStatuses') ->with(\Magento\Sales\Model\Order::STATE_NEW) ->will($this->returnValue(['firstStatus', 'secondStatus'])); - $orderConfig->expects($this->at(1)) + + $orderConfigMock->expects($this->once()) ->method('getStateDefaultStatus') ->with(\Magento\Sales\Model\Order::STATE_NEW) ->will($this->returnValue($newOrderStatus)); - /** @var \Magento\Sales\Model\Order | \PHPUnit_Framework_MockObject_MockObject $order */ - $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); - $order->expects($this->any()) + + $this->orderMock->expects($this->exactly(2)) ->method('getConfig') - ->will($this->returnValue($orderConfig)); - $order->expects($this->once()) + ->will($this->returnValue($orderConfigMock)); + + $this->orderMock->expects($this->once()) ->method('setState') ->with(\Magento\Sales\Model\Order::STATE_NEW, $newOrderStatus); - $methodInstance = $this->getMock('Magento\Payment\Model\Method\AbstractMethod', [], [], '', false); - $this->payment->setOrder($order); - $this->payment->setMethodInstance($methodInstance); + $this->paymentMethodMock->expects($this->once()) + ->method('getConfigPaymentAction') + ->willReturn(null); - $this->eventManager->expects($this->at(0)) + $this->eventManagerMock->expects($this->at(0)) ->method('dispatch') ->with('sales_order_payment_place_start', ['payment' => $this->payment]); - $this->eventManager->expects($this->at(1)) + + $this->eventManagerMock->expects($this->at(1)) ->method('dispatch') ->with('sales_order_payment_place_end', ['payment' => $this->payment]); $this->assertEquals($this->payment, $this->payment->place()); } + + public function testAuthorize() + { + $storeID = 1; + $amount = 10; + + $baseCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + ->disableOriginalConstructor() + ->setMethods(['formatTxt']) + ->getMock(); + + $baseCurrencyMock->expects($this->once()) + ->method('formatTxt') + ->willReturnCallback( + function ($value) { + return $value; + } + ); + + $this->orderMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeID); + + $this->orderMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->willReturn($amount); + + $this->orderMock->expects($this->once()) + ->method('getBaseCurrency') + ->willReturn($baseCurrencyMock); + + $this->orderMock->expects($this->once()) + ->method('setState') + ->with(\Magento\Sales\Model\Order::STATE_PROCESSING, true, 'Authorized amount of ' . $amount); + + $this->paymentMethodMock->expects($this->once()) + ->method('authorize') + ->with($this->payment) + ->willReturnSelf(); + + $paymentResult = $this->payment->authorize(true, $amount); + + $this->assertInstanceOf('Magento\Sales\Model\Order\Payment', $paymentResult); + $this->assertEquals($amount, $paymentResult->getBaseAmountAuthorized()); + } + + public function testAuthorizeFraudDetected() + { + $storeID = 1; + $amount = 10; + + $baseCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + ->disableOriginalConstructor() + ->setMethods(['formatTxt']) + ->getMock(); + + $baseCurrencyMock->expects($this->once()) + ->method('formatTxt') + ->willReturnCallback( + function ($value) { + return $value; + } + ); + + $this->orderMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeID); + + $this->orderMock->expects($this->once()) + ->method('getBaseCurrencyCode') + ->willReturn("USD"); + + $this->orderMock->expects($this->once()) + ->method('getBaseCurrency') + ->willReturn($baseCurrencyMock); + + $this->orderMock->expects($this->once()) + ->method('setState') + ->with( + \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW, + \Magento\Sales\Model\Order::STATUS_FRAUD, + "Order is suspended as its authorizing amount $amount is suspected to be fraudulent." + ); + + $this->paymentMethodMock->expects($this->once()) + ->method('authorize') + ->with($this->payment) + ->willReturnSelf(); + + $this->payment->setCurrencyCode('GBP'); + + $paymentResult = $this->payment->authorize(true, $amount); + + $this->assertInstanceOf('Magento\Sales\Model\Order\Payment', $paymentResult); + $this->assertEquals($amount, $paymentResult->getBaseAmountAuthorized()); + $this->assertTrue($paymentResult->getIsFraudDetected()); + } + + public function testAuthorizeTransactionPending() + { + $storeID = 1; + $amount = 10; + + $baseCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + ->disableOriginalConstructor() + ->setMethods(['formatTxt']) + ->getMock(); + + $baseCurrencyMock->expects($this->once()) + ->method('formatTxt') + ->willReturnCallback( + function ($value) { + return $value; + } + ); + + $this->orderMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeID); + + $this->orderMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->willReturn($amount); + + $this->orderMock->expects($this->once()) + ->method('getBaseCurrency') + ->willReturn($baseCurrencyMock); + + $this->orderMock->expects($this->once()) + ->method('setState') + ->with( + \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW, + true, + "We will authorize $amount after the payment is approved at the payment gateway." + ); + + $this->paymentMethodMock->expects($this->once()) + ->method('authorize') + ->with($this->payment) + ->willReturnSelf(); + + $this->payment->setIsTransactionPending(true); + + $paymentResult = $this->payment->authorize(true, $amount); + + $this->assertInstanceOf('Magento\Sales\Model\Order\Payment', $paymentResult); + $this->assertEquals($amount, $paymentResult->getBaseAmountAuthorized()); + $this->assertTrue($paymentResult->getIsTransactionPending()); + } } From 058998c3311fcfa81b4a26aa46d8602a23418ec4 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Wed, 24 Dec 2014 19:39:30 +0200 Subject: [PATCH 14/29] MAGETWO-31168: Investigate increase of checkout steps load time - fix for review --- app/code/Magento/Checkout/Model/Type/Onepage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 892a6f74f839b..3f57bda555d16 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -430,7 +430,7 @@ public function saveBilling($data, $customerAddressId) $address = $this->getQuote()->getBillingAddress(); } - if (!$this->getQuote()->getCustomerId() && self::METHOD_REGISTER == $this->getQuote()->getCheckoutMethod()) { + if (!$this->getQuote()->getCustomerId() && $this->isCheckoutMethodRegister()) { if ($this->_customerEmailExists($address->getEmail(), $this->_storeManager->getWebsite()->getId())) { return [ 'error' => 1, From 021207aa579b74695e9480f1629db56cf34896a1 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Fri, 26 Dec 2014 15:40:45 +0200 Subject: [PATCH 15/29] MAGETWO-31168: Investigate increase of checkout steps load time - found degradation --- app/code/Magento/Sales/Model/Service/Quote.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/Service/Quote.php b/app/code/Magento/Sales/Model/Service/Quote.php index f2872f9cdf2ee..05963a51471b2 100644 --- a/app/code/Magento/Sales/Model/Service/Quote.php +++ b/app/code/Magento/Sales/Model/Service/Quote.php @@ -184,8 +184,6 @@ protected function prepareCustomerData(\Magento\Sales\Model\Quote $quote) $this->customerBuilder->populate($customer)->create(), $quote->getPasswordHash() ); - } else { - $this->customerRepository->save($customer); } if (!$quote->getBillingAddress()->getId() && $customer->getDefaultBilling()) { From 7e6d2c50380e5bb5fc0b08105cf06dbdebe703cc Mon Sep 17 00:00:00 2001 From: Iryna Savchenko Date: Mon, 29 Dec 2014 16:30:10 +0200 Subject: [PATCH 16/29] MAGETWO-31764: Function _underscore didn't work with keys like SKeyName ('s_key_name') --- dev/tests/unit/testsuite/Magento/Framework/ObjectTest.php | 5 +++-- lib/internal/Magento/Framework/Object.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectTest.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectTest.php index 1931664c04be8..600426164129d 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectTest.php @@ -453,10 +453,11 @@ public function underscoreDataProvider() return [ 'Test 1' => ['Stone1Color', 'stone_1_color'], 'Test 2' => ['StoneColor', 'stone_color'], - 'Test 3' => ['StoneToXML', 'stone_to_xml'], + 'Test 3' => ['StoneToXml', 'stone_to_xml'], 'Test 4' => ['1StoneColor', '1_stone_color'], 'Test 5' => ['getCcLast4', 'get_cc_last_4'], - 'Test 6' => ['99Bottles', '99_bottles'] + 'Test 6' => ['99Bottles', '99_bottles'], + 'Test 7' => ['XApiLogin', 'x_api_login'] ]; } } diff --git a/lib/internal/Magento/Framework/Object.php b/lib/internal/Magento/Framework/Object.php index 438cdad543fa3..abb347a15a6f5 100644 --- a/lib/internal/Magento/Framework/Object.php +++ b/lib/internal/Magento/Framework/Object.php @@ -544,7 +544,7 @@ protected function _underscore($name) if (isset(self::$_underscoreCache[$name])) { return self::$_underscoreCache[$name]; } - $result = strtolower(trim(preg_replace('/([A-Z]+|[0-9]+)/', "_$1", $name), '_')); + $result = strtolower(trim(preg_replace('/([A-Z]|[0-9]+)/', "_$1", $name), '_')); self::$_underscoreCache[$name] = $result; return $result; } From c8b52489a1283ae2418e0a0458ecc6a9db815342 Mon Sep 17 00:00:00 2001 From: Pavlo Cherniavskyi Date: Mon, 29 Dec 2014 17:32:24 +0200 Subject: [PATCH 17/29] MAGETWO-31559: [TD] Removing NominalItems usage -- unit tests (open access to method authorize) --- .../Magento/Sales/Model/Order/Payment.php | 19 ++++--------------- .../Test/Legacy/_files/obsolete_methods.php | 1 + 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 703f64b5e13b7..40b8645fbe3e4 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -377,7 +377,7 @@ protected function processAction($action, \Magento\Sales\Model\Order $order) $this->_order($baseTotalDue); break; case \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE: - $this->_authorize(true, $baseTotalDue); + $this->authorize(true, $baseTotalDue); // base amount will be set inside $this->setAmountAuthorized($totalDue); break; @@ -571,7 +571,7 @@ public function registerCaptureNotification($amount, $skipFraudDetection = false */ public function registerAuthorizationNotification($amount) { - return $this->_isTransactionExists() ? $this : $this->_authorize(false, $amount); + return $this->_isTransactionExists() ? $this : $this->authorize(false, $amount); } /** @@ -1125,9 +1125,10 @@ protected function _order($amount) * * @param bool $isOnline * @param float $amount + * * @return $this */ - protected function _authorize($isOnline, $amount) + public function authorize($isOnline, $amount) { // check for authorization amount to be equal to grand total $this->setShouldCloseParentTransaction(false); @@ -1181,18 +1182,6 @@ protected function _authorize($isOnline, $amount) return $this; } - /** - * Public access to _authorize method - * - * @param bool $isOnline - * @param float $amount - * @return $this - */ - public function authorize($isOnline, $amount) - { - return $this->_authorize($isOnline, $amount); - } - /** * Void payment either online or offline (process void notification) * NOTE: that in some cases authorization can be voided after a capture. In such case it makes sense to use diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 4d14b40318db5..c2bcc43d810c9 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -1652,6 +1652,7 @@ ['_isDataChanged', 'Magento\Catalog\Model\Product'], ['getVisibleOnFrontStates', 'Magento\Sales\Model\Order\Config', 'getVisibleOnFrontStatuses'], ['getInvisibleOnFrontStates', 'Magento\Sales\Model\Order\Config', 'getInvisibleOnFrontStatuses'], + ['_authorize', 'Magento\Sales\Model\Order\Payment'], ['_shouldBeConverted', 'Magento\Sales\Model\Resource\AbstractResource'], ['_beforeSave', 'Magento\Sales\Model\Resource\AbstractResource'], ['_afterSave', 'Magento\Sales\Model\Resource\AbstractResource'], From 8233beff68413d21b398201d9cb6ca954a3b636e Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Mon, 29 Dec 2014 19:36:33 +0200 Subject: [PATCH 18/29] MAGETWO-31111: Plugins configuration caching - Interception configuration caching added --- dev/tools/Magento/Tools/Di/App/Compiler.php | 5 +- .../App/Task/Operation/InterceptionCache.php | 58 +++++++++++++++++++ .../Tools/Di/App/Task/OperationFactory.php | 6 ++ .../Framework/Interception/Config/Config.php | 8 ++- .../Interception/ConfigInterface.php | 8 +++ 5 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php diff --git a/dev/tools/Magento/Tools/Di/App/Compiler.php b/dev/tools/Magento/Tools/Di/App/Compiler.php index f23d792b4080e..48533145213d2 100644 --- a/dev/tools/Magento/Tools/Di/App/Compiler.php +++ b/dev/tools/Magento/Tools/Di/App/Compiler.php @@ -73,7 +73,10 @@ public function launch() BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' ], Task\OperationFactory::PLUGINS => - BP . '/app' + BP . '/app', + Task\OperationFactory::INTERCEPTION_CACHE => [ + BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' + ] ]; $responseCode = Response::SUCCESS; diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php new file mode 100644 index 0000000000000..b504f675c75b2 --- /dev/null +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php @@ -0,0 +1,58 @@ +data = $data; + $this->configInterface = $configInterface; + } + + /** + * Flushes interception cached configuration and generates a new one + * + * @return void + */ + public function doOperation() + { + if (empty($this->data)) { + return; + } + + $logWriter = new \Magento\Tools\Di\Compiler\Log\Writer\Quiet(); + $errorWriter = new \Magento\Tools\Di\Compiler\Log\Writer\Console(); + + $log = new \Magento\Tools\Di\Compiler\Log\Log($logWriter, $errorWriter); + + $validator = new \Magento\Framework\Code\Validator(); + $validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity()); + $validator->add(new \Magento\Framework\Code\Validator\ContextAggregation()); + + $directoryCompiler = new \Magento\Tools\Di\Compiler\Directory($log, $validator); + foreach ($this->data as $path) { + if (is_readable($path)) { + $directoryCompiler->compile($path); + } + } + + list($definitions, ) = $directoryCompiler->getResult(); + + $this->configInterface->initialize(array_keys($definitions)); + } +} diff --git a/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php b/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php index 79ec97ad52b59..198152fd0ec4b 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php +++ b/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php @@ -33,6 +33,11 @@ class OperationFactory */ const PLUGINS = 'plugins'; + /** + * Interception cache + */ + const INTERCEPTION_CACHE = 'interception_cache'; + /** * Operations definitions * @@ -43,6 +48,7 @@ class OperationFactory self::INTERCEPTION => 'Magento\Tools\Di\App\Task\Operation\Interception', self::RELATIONS => 'Magento\Tools\Di\App\Task\Operation\Relations', self::PLUGINS => 'Magento\Tools\Di\App\Task\Operation\Plugins', + self::INTERCEPTION_CACHE => 'Magento\Tools\Di\App\Task\Operation\InterceptionCache', ]; /** diff --git a/lib/internal/Magento/Framework/Interception/Config/Config.php b/lib/internal/Magento/Framework/Interception/Config/Config.php index 360c8e8f45331..cc07306193ed6 100644 --- a/lib/internal/Magento/Framework/Interception/Config/Config.php +++ b/lib/internal/Magento/Framework/Interception/Config/Config.php @@ -99,17 +99,19 @@ public function __construct( if ($intercepted !== false) { $this->_intercepted = unserialize($intercepted); } else { - $this->initialize(); + $this->initialize($this->_classDefinitions->getClasses()); } } /** * Initialize interception config * + * @param array $classDefinitions * @return void */ - protected function initialize() + public function initialize($classDefinitions = []) { + $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [$this->_cacheId]); $config = []; foreach ($this->_scopeList->getAllScopes() as $scope) { $config = array_replace_recursive($config, $this->_reader->read($scope)); @@ -123,7 +125,7 @@ protected function initialize() foreach ($config as $typeName => $typeConfig) { $this->hasPlugins(ltrim($typeName, '\\')); } - foreach ($this->_classDefinitions->getClasses() as $class) { + foreach ($classDefinitions as $class) { $this->hasPlugins($class); } $this->_cache->save(serialize($this->_intercepted), $this->_cacheId); diff --git a/lib/internal/Magento/Framework/Interception/ConfigInterface.php b/lib/internal/Magento/Framework/Interception/ConfigInterface.php index 180ba0b883861..4e4946de75a06 100644 --- a/lib/internal/Magento/Framework/Interception/ConfigInterface.php +++ b/lib/internal/Magento/Framework/Interception/ConfigInterface.php @@ -15,4 +15,12 @@ interface ConfigInterface * @return bool */ public function hasPlugins($type); + + /** + * Initialize interception config + * + * @param array $classDefinitions + * @return void + */ + public function initialize($classDefinitions = []); } From 44ec421c87cdc6678ae86b5f58b60443a7d10c7d Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Tue, 30 Dec 2014 18:12:48 +0200 Subject: [PATCH 19/29] MAGETWO-31111: Plugins configuration caching - removed unused caching --- dev/tools/Magento/Tools/Di/App/Compiler.php | 5 -- .../Tools/Di/App/Task/Operation/Plugins.php | 76 ------------------- .../Tools/Di/App/Task/Operation/Relations.php | 69 ----------------- .../Tools/Di/App/Task/OperationFactory.php | 12 --- 4 files changed, 162 deletions(-) delete mode 100644 dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php delete mode 100644 dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php diff --git a/dev/tools/Magento/Tools/Di/App/Compiler.php b/dev/tools/Magento/Tools/Di/App/Compiler.php index 48533145213d2..d1c7cb1fd9109 100644 --- a/dev/tools/Magento/Tools/Di/App/Compiler.php +++ b/dev/tools/Magento/Tools/Di/App/Compiler.php @@ -69,11 +69,6 @@ public function launch() ], Task\OperationFactory::INTERCEPTION => BP . '/var/generation', - Task\OperationFactory::RELATIONS => [ - BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' - ], - Task\OperationFactory::PLUGINS => - BP . '/app', Task\OperationFactory::INTERCEPTION_CACHE => [ BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' ] diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php deleted file mode 100644 index 2a1046856febd..0000000000000 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Plugins.php +++ /dev/null @@ -1,76 +0,0 @@ -configWriter = $configWriter; - $this->definitionRuntime = $definitionRuntime; - $this->data = $data; - } - - /** - * {@inheritdoc} - */ - public function doOperation() - { - if (empty($this->data)) { - return; - } - - $filePatterns = ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/']; - - $directoryScanner = new \Magento\Tools\Di\Code\Scanner\DirectoryScanner(); - $files = $directoryScanner->scan($this->data, $filePatterns); - - $pluginScanner = new \Magento\Tools\Di\Code\Scanner\CompositeScanner(); - $pluginScanner->addChild(new \Magento\Tools\Di\Code\Scanner\PluginScanner(), 'di'); - $pluginDefinitions = []; - $pluginList = $pluginScanner->collectEntities($files); - foreach ($pluginList as $entityList) { - foreach ($entityList as $entity) { - $pluginDefinitions[$entity] = $this->definitionRuntime->getMethodList($entity); - } - } - - $this->configWriter->write(self::CODE, $pluginDefinitions); - } -} diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php deleted file mode 100644 index bf35ac068ee7a..0000000000000 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/Relations.php +++ /dev/null @@ -1,69 +0,0 @@ -configWriter = $configWriter; - $this->data = $data; - } - - /** - * {@inheritdoc} - */ - public function doOperation() - { - if (empty($this->data)) { - return; - } - - $logWriter = new \Magento\Tools\Di\Compiler\Log\Writer\Quiet(); - $errorWriter = new \Magento\Tools\Di\Compiler\Log\Writer\Console(); - - $log = new \Magento\Tools\Di\Compiler\Log\Log($logWriter, $errorWriter); - - $validator = new \Magento\Framework\Code\Validator(); - $validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity()); - $validator->add(new \Magento\Framework\Code\Validator\ContextAggregation()); - - $directoryCompiler = new \Magento\Tools\Di\Compiler\Directory($log, $validator); - foreach ($this->data as $path) { - if (is_readable($path)) { - $directoryCompiler->compile($path); - } - } - - list(, $relations) = $directoryCompiler->getResult(); - $this->configWriter->write(self::CODE, $relations); - } -} diff --git a/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php b/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php index 198152fd0ec4b..69b5d25ed10d1 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php +++ b/dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php @@ -23,16 +23,6 @@ class OperationFactory */ const INTERCEPTION = 'interception'; - /** - * Relations - */ - const RELATIONS = 'relations'; - - /** - * Plugins - */ - const PLUGINS = 'plugins'; - /** * Interception cache */ @@ -46,8 +36,6 @@ class OperationFactory private $operationsDefinitions = [ self::AREA => 'Magento\Tools\Di\App\Task\Operation\Area', self::INTERCEPTION => 'Magento\Tools\Di\App\Task\Operation\Interception', - self::RELATIONS => 'Magento\Tools\Di\App\Task\Operation\Relations', - self::PLUGINS => 'Magento\Tools\Di\App\Task\Operation\Plugins', self::INTERCEPTION_CACHE => 'Magento\Tools\Di\App\Task\Operation\InterceptionCache', ]; From 85b44746319509128d1fceeaf0be397c75ee2605 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Tue, 30 Dec 2014 18:19:49 +0200 Subject: [PATCH 20/29] MAGETWO-31168: Investigate increase of checkout steps load time - fix test --- .../Checkout/Model/Type/OnepageTest.php | 97 +++++++++++++++---- 1 file changed, 76 insertions(+), 21 deletions(-) diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php index 7db6a77aa9e3e..0b46674f5f7b0 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -46,8 +46,8 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $addressFactoryMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $formFactoryMock; + /** @var \Magento\Customer\Model\FormFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $customerFormFactoryMock; /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $customerFactoryMock; @@ -65,7 +65,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase protected $messageManagerMock; /** @var \Magento\Customer\Model\Metadata\FormFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $customerFormFactoryMock; + protected $formFactoryMock; /** @var \Magento\Customer\Api\Data\CustomerDataBuilder|\PHPUnit_Framework_MockObject_MockObject */ protected $customerBuilderMock; @@ -134,7 +134,7 @@ protected function setUp() ['isAjax', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'] ); $this->addressFactoryMock = $this->getMock('Magento\Customer\Model\AddressFactory', [], [], '', false); - $this->formFactoryMock = $this->getMock('Magento\Customer\Model\FormFactory', [], [], '', false); + $this->formFactoryMock = $this->getMock('Magento\Customer\Model\Metadata\FormFactory', [], [], '', false); $this->customerFactoryMock = $this->getMock('Magento\Customer\Model\CustomerFactory', [], [], '', false); $this->quoteFactoryMock = $this->getMock('Magento\Sales\Model\Service\QuoteFactory', [], [], '', false); $this->orderFactoryMock = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); @@ -142,7 +142,7 @@ protected function setUp() $this->messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); $this->customerFormFactoryMock = $this->getMock( - 'Magento\Customer\Model\Metadata\FormFactory', + 'Magento\Customer\Model\FormFactory', ['create'], [], '', @@ -212,13 +212,13 @@ protected function setUp() 'storeManager' => $this->storeManagerMock, 'request' => $this->requestMock, 'customrAddrFactory' => $this->addressFactoryMock, - 'customerFormFactory' => $this->formFactoryMock, + 'customerFormFactory' => $this->customerFormFactoryMock, 'customerFactory' => $this->customerFactoryMock, 'serviceQuoteFactory' => $this->quoteFactoryMock, 'orderFactory' => $this->orderFactoryMock, 'objectCopyService' => $this->copyMock, 'messageManager' => $this->messageManagerMock, - 'formFactory' => $this->customerFormFactoryMock, + 'formFactory' => $this->formFactoryMock, 'customerBuilder' => $this->customerBuilderMock, 'addressBuilder' => $this->addressBuilderMock, 'mathRandom' => $this->randomMock, @@ -396,6 +396,8 @@ public function testSaveBilling( $getStepDataResult, $expected ) { + $useForShipping = (int)$data['use_for_shipping']; + $passwordHash = 'password hash'; $this->requestMock->expects($this->any())->method('isAjax')->will($this->returnValue(false)); $customerValidationResultMock = $this->getMock( @@ -454,17 +456,52 @@ public function testSaveBilling( ); $shippingAddressMock = $this->getMock( 'Magento\Sales\Model\Quote\Address', - ['setSameAsBilling', 'save', '__wakeup', 'unserialize'], + [ + 'setSameAsBilling', + 'save', + 'collectTotals', + 'addData', + 'setShippingMethod', + 'setCollectShippingRates' + ], [], '', false ); - $shippingAddressMock->expects($this->any())->method('setSameAsBilling')->with((int)$data['use_for_shipping']); - $shippingAddressMock->expects($this->once())->method('save'); + $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($shippingAddressMock)); + + $shippingAddressMock->expects($useForShipping ? $this->any() : $this->once()) + ->method('setSameAsBilling') + ->with($useForShipping) + ->will($this->returnSelf()); + + $expects = (!$useForShipping || ($checkoutMethod != Onepage::METHOD_REGISTER)) ? $this->once() : $this->never(); + $shippingAddressMock->expects($expects) + ->method('save'); + + $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never()) + ->method('addData') + ->will($this->returnSelf()); + + $shippingAddressMock->expects($this->any()) + ->method('setSaveInAddressBook') + ->will($this->returnSelf()); + + $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never()) + ->method('setShippingMethod') + ->will($this->returnSelf()); + + $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never()) + ->method('setCollectShippingRates') + ->will($this->returnSelf()); + + $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never()) + ->method('collectTotals'); + $quoteMock->expects($this->any())->method('setPasswordHash')->with($passwordHash); $quoteMock->expects($this->any())->method('getCheckoutMethod')->will($this->returnValue($checkoutMethod)); $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue($isVirtual)); - $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($shippingAddressMock)); + $addressMock = $this->getMock( 'Magento\Sales\Model\Quote\Address', [ @@ -486,7 +523,15 @@ public function testSaveBilling( $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock)); $quoteMock->expects($this->any())->method('getCustomerId')->will($this->returnValue($quoteCustomerId)); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + + $this->quoteRepositoryMock + ->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->once() : $this->never()) + ->method('save') + ->with($quoteMock); + + $addressMock->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->never() : $this->once()) + ->method('save'); + $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock)); $data1 = []; $extensibleDataObjectConverterMock = $this->getMock( @@ -504,7 +549,7 @@ public function testSaveBilling( $formMock = $this->getMock('Magento\Customer\Model\Metadata\Form', [], [], '', false); $formMock->expects($this->atLeastOnce())->method('validateData')->will($this->returnValue($validateDataResult)); - $this->customerFormFactoryMock->expects($this->any())->method('create')->will($this->returnValue($formMock)); + $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($formMock)); $formMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->requestMock)); $formMock->expects($this->any()) ->method('extractData') @@ -525,7 +570,7 @@ public function testSaveBilling( $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); $this->checkoutSessionMock->expects($this->any()) ->method('getStepData') - ->will($this->returnValue((int)$data['use_for_shipping'] === 1 ? true : $getStepDataResult)); + ->will($this->returnValue($useForShipping ? true : $getStepDataResult)); $this->checkoutSessionMock->expects($this->any())->method('setStepData')->will($this->returnSelf()); $customerAddressMock = $this->getMockForAbstractClass( 'Magento\Customer\Api\Data\AddressInterface', @@ -540,13 +585,6 @@ public function testSaveBilling( ->method('getById') ->will($isAddress ? $this->returnValue($customerAddressMock) : $this->throwException(new \Exception())); - $this->customerBuilderMock - ->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->never() : $this->once()) - ->method('populate'); - $this->customerBuilderMock - ->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->never() : $this->once()) - ->method('setGroupId'); - $websiteMock = $this->getMock('Magento\Store\Model\Website', [], [], '', false); $this->storeManagerMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock)); $this->assertEquals($expected, $this->onepage->saveBilling($data, $customerAddressId)); @@ -571,6 +609,23 @@ public function saveBillingDataProvider() false, // $isVirtual false, // $getStepDataResult [], // $expected + ], + [ + ['use_for_shipping' => 1], // $data + 1, // $customerAddressId + 1, // $quoteCustomerId + 1, // $addressCustomerId + true, //$isAddress + true, // $validateDataResult + true, // $validateResult + Onepage::METHOD_CUSTOMER, // $checkoutMethod + 'password', // $customerPassword + 'password', // $confirmPassword + [], // $validationResultMessages + true, // $isEmailAvailable + false, // $isVirtual + false, // $getStepDataResult + [], // $expected ] ]; } From 61a83ba4f550f2dceb7b15ad378326eebb7347b5 Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Tue, 30 Dec 2014 18:25:37 +0200 Subject: [PATCH 21/29] MAGETWO-31111: Plugins configuration caching - fixed tests --- .../unit/testsuite/Magento/Tools/Di/App/CompilerTest.php | 6 ++---- .../Magento/Tools/Di/App/Task/OperationFactoryTest.php | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php b/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php index e518db722a548..201fefe99d97a 100644 --- a/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php +++ b/dev/tests/unit/testsuite/Magento/Tools/Di/App/CompilerTest.php @@ -120,11 +120,9 @@ private function getOptions() ], Task\OperationFactory::INTERCEPTION => BP . '/var/generation', - Task\OperationFactory::RELATIONS => [ + Task\OperationFactory::INTERCEPTION_CACHE => [ BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation' - ], - Task\OperationFactory::PLUGINS => - BP . '/app' + ] ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php b/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php index 2f2d7ffd507b1..d9e41462ed65e 100644 --- a/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Tools/Di/App/Task/OperationFactoryTest.php @@ -66,8 +66,7 @@ public function aliasesDataProvider() return [ [OperationFactory::AREA, [], 'Magento\Tools\Di\App\Task\Operation\Area'], [OperationFactory::INTERCEPTION, null, 'Magento\Tools\Di\App\Task\Operation\Interception'], - [OperationFactory::RELATIONS, 1, 'Magento\Tools\Di\App\Task\Operation\Relations'], - [OperationFactory::PLUGINS, 'argument', 'Magento\Tools\Di\App\Task\Operation\Plugins'], + [OperationFactory::INTERCEPTION_CACHE, 1, 'Magento\Tools\Di\App\Task\Operation\InterceptionCache'], ]; } From 7d2842f31a9f82aa5ac2d7ebbd127b3fa5faf138 Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Wed, 31 Dec 2014 13:02:53 +0200 Subject: [PATCH 22/29] MAGETWO-31111: Plugins configuration caching - Added annotations --- .../Tools/Di/App/Task/Operation/InterceptionCache.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php b/dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php index b504f675c75b2..ceda04f299df3 100644 --- a/dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php +++ b/dev/tools/Magento/Tools/Di/App/Task/Operation/InterceptionCache.php @@ -5,6 +5,7 @@ */ namespace Magento\Tools\Di\App\Task\Operation; + use Magento\Tools\Di\App\Task\OperationInterface; class InterceptionCache implements OperationInterface @@ -14,8 +15,15 @@ class InterceptionCache implements OperationInterface */ private $data = []; + /** + * @var \Magento\Framework\Interception\Config\Config + */ private $configInterface; + /** + * @param \Magento\Framework\Interception\Config\Config $configInterface + * @param array $data + */ public function __construct( \Magento\Framework\Interception\Config\Config $configInterface, $data = [] From c8e18122d9651d177aedcdf1115b0f7d49d51976 Mon Sep 17 00:00:00 2001 From: Pavlo Cherniavskyi Date: Wed, 31 Dec 2014 14:26:47 +0200 Subject: [PATCH 23/29] MAGETWO-31559: [TD] Removing NominalItems usage -- integration test for start method --- .../Paypal/Model/Express/CheckoutTest.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php index 5f404a8e5ce3e..bc4374a18d0a2 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php @@ -127,6 +127,60 @@ public function testPrepareNewCustomerQuoteConfirmationRequired() ); } + /** + * @magentoDataFixture Magento/Paypal/_files/quote_payment_express_with_customer.php + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testGuestExpressCheckoutStart() + { + /** @var Quote $quote */ + $quote = $this->_getFixtureQuote(); + + $quote->setIsMultiShipping(false); + $quote->setCheckoutMethod(Onepage::METHOD_GUEST); + $quote->getShippingAddress()->setSameAsBilling(0); + + $paypalConfigMock = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); + $apiTypeFactory = $this->getMock('Magento\Paypal\Model\Api\Type\Factory', [], [], '', false); + $paypalInfo = $this->getMock('Magento\Paypal\Model\Info', [], [], '', false); + + $apiMock = $this->getMockBuilder('\Magento\Paypal\Model\Api\Nvp') + ->disableOriginalConstructor() + ->setMethods(['call', 'callSetExpressCheckout']) + ->getMock(); + + $apiMock->expects($this->any())->method('call')->will($this->returnValue([])); + $apiMock->expects($this->once())->method('callSetExpressCheckout'); + + $apiMock->expects($this->never())->method('getBillingAgreementType'); + $apiMock->expects($this->never())->method('setBillingType'); + + $apiTypeFactory->expects($this->any())->method('create')->will($this->returnValue($apiMock)); + + /** @var \Magento\Paypal\Model\Express\Checkout $checkout */ + $checkout = $this->_objectManager->create( + 'Magento\Paypal\Model\Express\Checkout', + [ + 'params' => ['quote' => $quote, 'config' => $paypalConfigMock], + 'apiTypeFactory' => $apiTypeFactory, + 'paypalInfo' => $paypalInfo + ] + ); + + $checkout->setIsBillingAgreementRequested(false); + $checkout->setIsBml(false); + + $checkout->setCustomerData($quote->getCustomer()); + + $token = $checkout->start("https://domain.com/some/return/url", "https://domain.com/some/cancel/url"); + + $this->assertNull($token); + $this->assertTrue($quote->getTotalsCollectedFlag()); + $this->assertFalse($quote->hasDataChanges()); + $this->assertTrue($quote->getPayment()->hasMethod()); + } + /** * Verify that after placing the order, addresses are associated with the order and the quote is a guest quote. * From 22fcfa85555f4ed14aa27172a595d1aee32879d4 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Thu, 8 Jan 2015 16:39:37 +0200 Subject: [PATCH 24/29] MAGETWO-15874: Edit button is present when order is already captured --- app/code/Magento/Sales/Model/Order.php | 16 ++++++++++++++++ .../testsuite/Magento/Sales/Model/OrderTest.php | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 89e8ca8befbd5..cde2f205911d2 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -801,6 +801,10 @@ public function canEdit() return false; } + if ($this->hasInvoices()) { + return false; + } + if (!$this->getPayment()->getMethodInstance()->canEdit()) { return false; } @@ -1820,6 +1824,18 @@ public function getInvoiceCollection() return $this->_invoices; } + /** + * Set order invoices collection + * + * @param InvoiceCollection $invoices + * @return $this + */ + public function setInvoiceCollection(InvoiceCollection $invoices) + { + $this->_invoices = $invoices; + return $this; + } + /** * Retrieve order shipments collection * diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php index 6af26f5a8165f..782c33995a1f2 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php @@ -191,6 +191,23 @@ public function testCanCancelIsPaymentReview() $this->assertFalse($this->order->canCancel()); } + public function testCanEditIfHasInvoices() + { + $invoiceCollection = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Invoice\Collection') + ->disableOriginalConstructor() + ->setMethods(['count']) + ->getMock(); + + $invoiceCollection->expects($this->once()) + ->method('count') + ->willReturn(2); + + $this->order->setInvoiceCollection($invoiceCollection); + $this->order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING); + + $this->assertFalse($this->order->canEdit()); + } + public function testCanCancelCanReviewPayment() { $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Payment') From 573942eaea496ea242a365cb4a2e63b73725f757 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Fri, 9 Jan 2015 19:59:17 +0200 Subject: [PATCH 25/29] MAGETWO-31168: Investigate increase of checkout steps load time --- app/code/Magento/Sales/Model/Service/Quote.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Sales/Model/Service/Quote.php b/app/code/Magento/Sales/Model/Service/Quote.php index 05963a51471b2..f2872f9cdf2ee 100644 --- a/app/code/Magento/Sales/Model/Service/Quote.php +++ b/app/code/Magento/Sales/Model/Service/Quote.php @@ -184,6 +184,8 @@ protected function prepareCustomerData(\Magento\Sales\Model\Quote $quote) $this->customerBuilder->populate($customer)->create(), $quote->getPasswordHash() ); + } else { + $this->customerRepository->save($customer); } if (!$quote->getBillingAddress()->getId() && $customer->getDefaultBilling()) { From 18b85abaf72558885a05d5bbecb825af2740359e Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Mon, 12 Jan 2015 20:02:40 +0200 Subject: [PATCH 26/29] Merge remote-tracking branch 'remotes/origin/MAGETWO-31559' into develop Conflicts: app/code/Magento/Paypal/Helper/Shortcut/CheckoutValidator.php app/code/Magento/Paypal/Model/Express/Checkout.php app/code/Magento/Sales/Api/Data/OrderItemInterface.php dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php dev/tests/unit/testsuite/Magento/Paypal/Helper/Shortcut/CheckoutValidatorTest.php --- app/code/Magento/Sales/Api/Data/OrderItemInterface.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php index c7b07a65c021c..2b9aafe9f63c5 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php @@ -264,7 +264,9 @@ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterf * Base hidden tax refunded. */ const BASE_HIDDEN_TAX_REFUNDED = 'base_hidden_tax_refunded'; - const IS_NOMINAL = 'is_nominal'; + /* + * Tax canceled flag + */ const TAX_CANCELED = 'tax_canceled'; /* * Hidden-tax-canceled flag. From 22c28a290cf31f170bee7e40fdb6eb98551c19c3 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Tue, 13 Jan 2015 12:59:04 +0200 Subject: [PATCH 27/29] Merge remote-tracking branch 'remotes/main/develop' into develop - fix Copyright string --- app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php | 3 ++- .../testsuite/Magento/Sales/Model/Service/QuoteTest.php | 3 ++- .../unit/testsuite/Magento/Tools/Di/App/Task/AreaTest.php | 5 ++--- .../Magento/Tools/Di/App/Task/OperationFactoryTest.php | 6 ++---- dev/tools/Magento/Tools/Di/App/Task/Manager.php | 5 ++--- dev/tools/Magento/Tools/Di/App/Task/Operation/Area.php | 5 ++--- .../Magento/Tools/Di/App/Task/Operation/Interception.php | 5 ++--- .../Tools/Di/App/Task/Operation/InterceptionCache.php | 5 ++--- dev/tools/Magento/Tools/Di/App/Task/OperationException.php | 5 ++--- dev/tools/Magento/Tools/Di/App/Task/OperationFactory.php | 5 ++--- dev/tools/Magento/Tools/Di/App/Task/OperationInterface.php | 5 ++--- 11 files changed, 22 insertions(+), 30 deletions(-) diff --git a/app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php b/app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php index f410c9bb38ef8..c8961b1ba40e9 100644 --- a/app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php +++ b/app/code/Magento/Sales/sql/sales_setup/update-2.0.1.php @@ -1,6 +1,7 @@ Date: Tue, 13 Jan 2015 13:47:08 +0200 Subject: [PATCH 28/29] Merge remote-tracking branch 'remotes/main/develop' into develop - fix remove obsolete class --- .../Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Nominal/Collector.php deleted file mode 100644 index e69de29bb2d1d..0000000000000 From cac05e38a95d4f19219eabe7fc170a536031a647 Mon Sep 17 00:00:00 2001 From: Kostiantyn Poida Date: Tue, 13 Jan 2015 18:25:16 +0200 Subject: [PATCH 29/29] Merge remote-tracking branch 'remotes/origin/MAGETWO-31559' into develop - remove extra code --- app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php index 87cf2c1881edc..87dfff6eaa459 100644 --- a/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php +++ b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php @@ -1647,12 +1647,6 @@ '12,4', [], 'Hidden Tax Canceled' -)->addColumn( - 'is_nominal', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Is Nominal' )->addColumn( 'tax_refunded', \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,