From 76e9ff0f4435bf2b365c08c1f0af393e8ad9f38f Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Mon, 8 Jun 2015 16:44:13 -0500 Subject: [PATCH 01/56] MAGETWO-38383: Increase Unit Test Code Coverage - Added unit tests for the Fixture classes. --- .../Fixtures/CartPriceRulesFixtureTest.php | 102 ++++++++++ .../Fixtures/CatalogPriceRulesFixtureTest.php | 116 +++++++++++ .../Unit/Fixtures/CategoriesFixtureTest.php | 117 +++++++++++ .../Unit/Fixtures/ConfigsApplyFixtureTest.php | 58 ++++++ .../ConfigurableProductsFixtureTest.php | 98 +++++++++ .../Unit/Fixtures/CustomersFixtureTest.php | 75 +++++++ .../Fixtures/EavVariationsFixtureTest.php | 82 ++++++++ .../IndexersStatesApplyFixtureTest.php | 58 ++++++ .../Test/Unit/Fixtures/OrdersFixtureTest.php | 186 ++++++++++++++++++ .../Fixtures/SimpleProductsFixtureTest.php | 100 ++++++++++ .../Test/Unit/Fixtures/StoresFixtureTest.php | 145 ++++++++++++++ .../Unit/Fixtures/TaxRatesFixtureTest.php | 72 +++++++ 12 files changed, 1209 insertions(+) create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php new file mode 100644 index 0000000000000..c214047cec7a6 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -0,0 +1,102 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock->expects($this->once()) + ->method('getRootCategoryId') + ->will($this->returnValue(2)); + + $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock->expects($this->once()) + ->method('getGroups') + ->will($this->returnValue([$storeMock])); + $websiteMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue('website_id')); + + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock->expects($this->once()) + ->method('getWebsites') + ->will($this->returnValue([$websiteMock])); + + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $abstractDbMock->expects($this->any()) + ->method('getAllChildren') + ->will($this->returnValue([1])); + + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock->expects($this->any()) + ->method('getResource') + ->will($this->returnValue($abstractDbMock)); + $categoryMock->expects($this->once()) + ->method('getPath') + ->will($this->returnValue('path/to/file')); + $categoryMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue('category_id')); + + $modelMock = $this->getMockBuilder('\Magento\SalesRule\Model\Rule')->disableOriginalConstructor()->getMock(); + $modelMock->expects($this->once()) + ->method('getIdFieldName') + ->will($this->returnValue('Field Id Name')); + + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($storeManagerMock)); + $objectManagerMock->expects($this->exactly(2)) + ->method('get') + ->will($this->onConsecutiveCalls($categoryMock, $modelMock)); + + $this->fixtureModelMock + ->expects($this->exactly(2)) + ->method('getValue') + ->will($this->onConsecutiveCalls(1, 3)); + $this->fixtureModelMock + ->expects($this->exactly(3)) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); + + + $cartPriceFixture = new CartPriceRulesFixture($this->fixtureModelMock); + $cartPriceFixture->execute(); + } + + public function testGetActionTitle() + { + $cartPriceFixture = new CartPriceRulesFixture($this->fixtureModelMock); + $this->assertSame('Generating shopping cart price rules', $cartPriceFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $cartPriceFixture = new CartPriceRulesFixture($this->fixtureModelMock); + $this->assertSame([ + 'cart_price_rules' => 'Cart Price Rules' + ], $cartPriceFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php new file mode 100644 index 0000000000000..d506155b2336e --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -0,0 +1,116 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock + ->expects($this->once()) + ->method('getRootCategoryId') + ->will($this->returnValue(2)); + + $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock + ->expects($this->once()) + ->method('getGroups') + ->will($this->returnValue([$storeMock])); + $websiteMock + ->expects($this->once()) + ->method('getId') + ->will($this->returnValue('website_id')); + + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock + ->expects($this->once()) + ->method('getWebsites') + ->will($this->returnValue([$websiteMock])); + + $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); + $abstractDbMock = $this->getMockForAbstractClass('Magento\Framework\Model\Resource\Db\AbstractDb', [$contextMock], '', true, true, true, ['getAllChildren']); + $abstractDbMock + ->expects($this->any()) + ->method('getAllChildren') + ->will($this->returnValue([1])); + + $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock + ->expects($this->any()) + ->method('getResource') + ->will($this->returnValue($abstractDbMock)); + $categoryMock + ->expects($this->once()) + ->method('getPath') + ->will($this->returnValue('path/to/file')); + $categoryMock + ->expects($this->once()) + ->method('getId') + ->will($this->returnValue('category_id')); + + $modelMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); + $modelMock + ->expects($this->once()) + ->method('getIdFieldName') + ->will($this->returnValue('Field Id Name')); + + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($storeManagerMock)); + $objectManagerMock + ->expects($this->exactly(2)) + ->method('get') + ->will($this->onConsecutiveCalls($categoryMock, $modelMock)); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('resetObjectManager'); + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->will($this->returnValue(1)); + $this->fixtureModelMock + ->expects($this->exactly(3)) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); + + + $catalogPriceFixture = new CatalogPriceRulesFixture($this->fixtureModelMock); + $catalogPriceFixture->execute(); + } + + public function testGetActionTitle() + { + $catalogPriceFixture = new CatalogPriceRulesFixture($this->fixtureModelMock); + $this->assertSame('Generating catalog price rules', $catalogPriceFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $catalogPriceFixture = new CatalogPriceRulesFixture($this->fixtureModelMock); + $this->assertSame([ + 'catalog_price_rules' => 'Catalog Price Rules' + ], $catalogPriceFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php new file mode 100644 index 0000000000000..ec704b2cfc522 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -0,0 +1,117 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + public function testExecute() + { + $categoryMock = $this->getMockBuilder('\Magento\Catalog\Model\Category')->disableOriginalConstructor()->setMethods(array( + 'getName', + 'setId', + 'setUrlKey', + 'setUrlPath', + 'setName', + 'setParentId', + 'setPath', + 'setLevel', + 'setAvailableSortBy', + 'setDefaultSortBy', + 'setIsActive', + 'save' + ))->getMock(); + $categoryMock + ->expects($this->once()) + ->method('getName') + ->will($this->returnValue('category_name')); + $categoryMock->expects($this->once()) + ->method('setId') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setUrlKey') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setUrlPath') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setName') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setParentId') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setPath') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setLevel') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setAvailableSortBy') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setDefaultSortBy') + ->willReturnSelf(); + $categoryMock->expects($this->once()) + ->method('setIsActive') + ->willReturnSelf(); + + $groupMock = $this->getMock('\Magento\Store\Model\Group', [], [], '', false); + $groupMock + ->expects($this->once()) + ->method('getRootCategoryId') + ->will($this->returnValue('root_category_id')); + + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock + ->expects($this->once()) + ->method('getGroups') + ->will($this->returnValue([$groupMock])); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock + ->expects($this->exactly(2)) + ->method('create') + ->will($this->onConsecutiveCalls($storeManagerMock, $categoryMock)); + + $this->fixtureModelMock + ->expects($this->exactly(2)) + ->method('getValue') + ->will($this->onConsecutiveCalls(1, 3)); + $this->fixtureModelMock + ->expects($this->exactly(2)) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); + + $categoriesFixture = new CategoriesFixture($this->fixtureModelMock); + $categoriesFixture->execute(); + } + + public function testGetActionTitle() + { + $categoriesFixture = new CategoriesFixture($this->fixtureModelMock); + $this->assertSame('Generating categories', $categoriesFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $categoriesFixture = new CategoriesFixture($this->fixtureModelMock); + $this->assertSame([ + 'categories' => 'Categories' + ], $categoriesFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php new file mode 100644 index 0000000000000..ae4a8c3ee6be0 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php @@ -0,0 +1,58 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + public function testExecute() + { + $cacheMock = $this->getMockBuilder('\Magento\Framework\App\Cache')->disableOriginalConstructor()->getMock(); + + $valueMock = $this->getMockBuilder('\Magento\Framework\App\Config')->disableOriginalConstructor()->getMock(); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->once()) + ->method('get') + ->will($this->returnValue($cacheMock)); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->will($this->returnValue(['config' => $valueMock])); + $this->fixtureModelMock + ->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); + + $configsApplyFixture = new ConfigsApplyFixture($this->fixtureModelMock); + $configsApplyFixture->execute(); + } + + public function testGetActionTitle() + { + $configsApplyFixture = new ConfigsApplyFixture($this->fixtureModelMock); + $this->assertSame('Config Changes', $configsApplyFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $configsApplyFixture = new ConfigsApplyFixture($this->fixtureModelMock); + $this->assertSame([], $configsApplyFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php new file mode 100644 index 0000000000000..6c9cfe67f26c3 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -0,0 +1,98 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import')->disableOriginalConstructor()->getMock(); + + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $abstractDbMock->expects($this->any()) + ->method('getAllChildren') + ->will($this->returnValue([1])); + + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock->expects($this->once()) + ->method('getResource') + ->will($this->returnValue($abstractDbMock)); + $categoryMock->expects($this->any()) + ->method('getName') + ->will($this->returnValue('category_name')); + $categoryMock->expects($this->once()) + ->method('getPath') + ->will($this->returnValue('path/to/category')); + $categoryMock->expects($this->any())->method('load') + ->willReturnSelf(); + + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock->expects($this->once()) + ->method('getRootCategoryId') + ->will($this->returnValue([2])); + + $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock->expects($this->once()) + ->method('getCode') + ->will($this->returnValue('website_code')); + $websiteMock->expects($this->once()) + ->method('getGroups') + ->will($this->returnValue([$storeMock])); + + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock->expects($this->once()) + ->method('getWebsites') + ->will($this->returnValue([$websiteMock])); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->exactly(2)) + ->method('create') + ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); + $objectManagerMock->expects($this->once()) + ->method('get') + ->will($this->returnValue($categoryMock)); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->will($this->returnValue(1)); + $this->fixtureModelMock + ->expects($this->exactly(3)) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); + + $configurableProductsFixture = new ConfigurableProductsFixture($this->fixtureModelMock); + $configurableProductsFixture->execute(); + } + + public function testGetActionTitle() + { + $configurableProductsFixture = new ConfigurableProductsFixture($this->fixtureModelMock); + $this->assertSame('Generating configurable products', $configurableProductsFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $configurableProductsFixture = new ConfigurableProductsFixture($this->fixtureModelMock); + $this->assertSame([ + 'configurable_products' => 'Configurable products' + ], $configurableProductsFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php new file mode 100644 index 0000000000000..b81a143bc38d7 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -0,0 +1,75 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import')->disableOriginalConstructor()->getMock(); + + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock->expects($this->once()) + ->method('getCode') + ->will($this->returnValue('store_code')); + + $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock->expects($this->once()) + ->method('getCode') + ->will($this->returnValue('website_code')); + + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock->expects($this->once()) + ->method('getDefaultStoreView') + ->will($this->returnValue($storeMock)); + $storeManagerMock->expects($this->once()) + ->method('getWebsites') + ->will($this->returnValue([$websiteMock])); + + $objectManagerMode = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMode->expects($this->exactly(2)) + ->method('create') + ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->will($this->returnValue(1)); + $this->fixtureModelMock + ->expects($this->exactly(2)) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMode)); + + $customersFixture = new CustomersFixture($this->fixtureModelMock); + $customersFixture->execute(); + } + + public function testGetActionTitle() + { + $customersFixture = new CustomersFixture($this->fixtureModelMock); + $this->assertSame('Generating customers', $customersFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $customersFixture = new CustomersFixture($this->fixtureModelMock); + $this->assertSame([ + 'customers' => 'Customers' + ], $customersFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php new file mode 100644 index 0000000000000..c064ab6a36d4d --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -0,0 +1,82 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $attributeMock = $this->getMockBuilder('Magenot\Catalog\Model\Resource\Eav\Attribute') + ->setMethods(array('setAttributeGroupId', 'addData', 'setAttributeSetId', 'save')) + ->getMock(); + $attributeMock->expects($this->exactly(2)) + ->method('setAttributeSetId') + ->willReturnSelf(); + $attributeMock->expects($this->once()) + ->method('setAttributeGroupId') + ->willReturnSelf(); + + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock->expects($this->once()) + ->method('getStores') + ->will($this->returnValue([$storeMock])); + + $setMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Set')->disableOriginalConstructor()->getMock(); + $setMock->expects($this->once()) + ->method('getDefaultGroupId') + ->will($this->returnValue(2)); + + $cacheMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface')->disableOriginalConstructor()->getMock(); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->exactly(2)) + ->method('create') + ->will($this->onConsecutiveCalls($attributeMock, $storeManagerMock)); + $objectManagerMock->expects($this->exactly(2)) + ->method('get') + ->will($this->onConsecutiveCalls($setMock, $cacheMock)); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->will($this->returnValue(1)); + $this->fixtureModelMock + ->expects($this->exactly(4)) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); + + $eavVariationsFixture = new EavVariationsFixture($this->fixtureModelMock); + $eavVariationsFixture->execute(); + } + + public function testGetActionTitle() + { + $eavVariationsFixture = new EavVariationsFixture($this->fixtureModelMock); + $this->assertSame('Generating configurable EAV variations', $eavVariationsFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $eavVariationsFixture = new EavVariationsFixture($this->fixtureModelMock); + $this->assertSame([], $eavVariationsFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php new file mode 100644 index 0000000000000..651531d4dd395 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php @@ -0,0 +1,58 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $cacheInterfaceMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface')->disableOriginalConstructor()->getMock(); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->once()) + ->method('get') + ->willReturn($cacheInterfaceMock); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(array( + 'indexer' => ['id' => 1] + )); + $this->fixtureModelMock + ->expects($this->once()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); + + $indexersStatesApplyFixture = new IndexersStatesApplyFixture($this->fixtureModelMock); + $indexersStatesApplyFixture->execute(); + } + + public function testGetActionTitle() + { + $indexersStatesApplyFixture = new IndexersStatesApplyFixture($this->fixtureModelMock); + $this->assertSame('Indexers Mode Changes', $indexersStatesApplyFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $indexersStatesApplyFixture = new IndexersStatesApplyFixture($this->fixtureModelMock); + $this->assertSame([], $indexersStatesApplyFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php new file mode 100644 index 0000000000000..e3a719ce17c44 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -0,0 +1,186 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $adapterInterfaceMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface')->disableOriginalConstructor()->getMockForAbstractClass(); + $adapterInterfaceMock->expects($this->any()) + ->method('getTableName') + ->willReturn('table_name'); + + $resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource')->disableOriginalConstructor()->getMock(); + $resourceMock->expects($this->any()) + ->method('getConnection') + ->willReturn($adapterInterfaceMock); + + + foreach ($this->mockObjectNames as $mockObjectName) { + $mockObject = $this->getMockBuilder($mockObjectName)->disableOriginalConstructor()->getMock(); + $path = explode('\\', $mockObjectName); + $name = array_pop($path); + if (strcasecmp($mockObjectName, 'Magento\Sales\Model\Resource\Order') == 0) { + $mockObject->expects($this->exactly(2)) + ->method('getTable') + ->willReturn(strtolower($name) . '_table_name'); + } else { + $mockObject->expects($this->once()) + ->method('getTable') + ->willReturn(strtolower($name) . '_table_name'); + } + $map = array($mockObjectName, $mockObject); + $this->mockObjects[] = $map; + } + + $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->setMethods(array('getId', 'getName'))->getMock(); + $websiteMock->expects($this->once()) + ->method('getId') + ->willReturn('website_id'); + $websiteMock->expects($this->once()) + ->method('getName') + ->willReturn('website_name'); + + $groupMock = $this->getMockBuilder('\Magento\Store\Model\Group')->disableOriginalConstructor()->setMethods(array('getName'))->getMock(); + $groupMock->expects($this->once()) + ->method('getName') + ->willReturn('group_name'); + + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->setMethods(array( + 'getStoreId', + 'getWebsite', + 'getGroup', + 'getName', + 'getRootCategoryId' + ))->getMock(); + $storeMock->expects($this->once()) + ->method('getStoreId') + ->willReturn(1); + $storeMock->expects($this->exactly(2)) + ->method('getWebsite') + ->willReturn($websiteMock); + $storeMock->expects($this->once()) + ->method('getGroup') + ->willReturn($groupMock); + $storeMock->expects($this->once()) + ->method('getName') + ->willReturn('store_name'); + $storeMock->expects($this->once()) + ->method('getRootCategoryId') + ->willReturn(1); + + $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManager->expects($this->once()) + ->method('getStores') + ->willReturn([$storeMock]); + + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $abstractDbMock->expects($this->any()) + ->method('getAllChildren') + ->will($this->returnValue([1])); + + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock->expects($this->once()) + ->method('getResource') + ->willReturn($abstractDbMock); + $categoryMock->expects($this->once()) + ->method('getPath') + ->willReturn('path/to/category'); + $categoryMock->expects($this->any()) + ->method('getName') + ->willReturn('category_name'); + $categoryMock->expects($this->any()) + ->method('load') + ->willReturnSelf(); + $this->mockObjects[] = array('Magento\Catalog\Model\Category', $categoryMock); + + $productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $productMock->expects($this->any()) + ->method('load') + ->willReturnSelf(); + $this->mockObjects[] = array('Magento\Catalog\Model\Product', $productMock); + $this->mockObjects[] = array('Magento\Framework\App\Resource', $resourceMock); + + $selectMock = $this->getMockBuilder('\Magento\Framework\DB\Select')->disableOriginalConstructor()->getMock(); + + $collectionMock = $this->getMockBuilder('\Magento\Catalog\Model\Resource\Product\Collection')->disableOriginalConstructor()->getMock(); + $collectionMock->expects($this->once()) + ->method('getSelect') + ->willReturn($selectMock); + $collectionMock->expects($this->once()) + ->method('getAllIds') + ->willReturn([1, 1]); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock + ->expects($this->any()) + ->method('get') + ->will($this->returnValueMap($this->mockObjects)); + $objectManagerMock + ->expects($this->exactly(2)) + ->method('create') + ->will($this->onConsecutiveCalls($storeManager, $collectionMock)); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(1); + $this->fixtureModelMock + ->expects($this->any()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); + + $ordersFixture = new OrdersFixture($this->fixtureModelMock); + $ordersFixture->execute(); + } + + public function testGetActionTitle() + { + $ordersFixture = new OrdersFixture($this->fixtureModelMock); + $this->assertSame('Generating orders', $ordersFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $ordersFixture = new OrdersFixture($this->fixtureModelMock); + $this->assertSame([ + 'orders' => 'Orders' + ], $ordersFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php new file mode 100644 index 0000000000000..d6a23f30c9dd9 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -0,0 +1,100 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock->expects($this->once()) + ->method('getRootCategoryId') + ->willReturn(1); + + $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock->expects($this->once()) + ->method('getCode') + ->willReturn('website_code'); + $websiteMock->expects($this->once()) + ->method('getGroups') + ->willReturn([$storeMock]); + + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock->expects($this->once()) + ->method('getWebsites') + ->willReturn([$websiteMock]); + + $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import')->disableOriginalConstructor()->getMock(); + + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $abstractDbMock->expects($this->any()) + ->method('getAllChildren') + ->will($this->returnValue([1])); + + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock->expects($this->once()) + ->method('getResource') + ->willReturn($abstractDbMock); + $categoryMock->expects($this->once()) + ->method('getPath') + ->willReturn('path/to/category'); + $categoryMock->expects($this->any()) + ->method('load') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('getName') + ->willReturn('category_name'); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->exactly(2)) + ->method('create') + ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); + $objectManagerMock->expects($this->once()) + ->method('get') + ->willReturn($categoryMock); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(1); + $this->fixtureModelMock + ->expects($this->exactly(3)) + ->method('getObjectManager') + ->willReturn($objectManagerMock); + + $simpleProductsFixture = new SimpleProductsFixture($this->fixtureModelMock); + $simpleProductsFixture->execute(); + } + + public function testGetActionTitle() + { + $simpleProductsFixture = new SimpleProductsFixture($this->fixtureModelMock); + $this->assertSame('Generating simple products', $simpleProductsFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $simpleProductsFixture = new SimpleProductsFixture($this->fixtureModelMock); + $this->assertSame([ + 'simple_products' => 'Simple products' + ], $simpleProductsFixture->introduceParamLabels()); + } + +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php new file mode 100644 index 0000000000000..ab9760b103d23 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -0,0 +1,145 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock->expects($this->any()) + ->method('getId') + ->willReturn('website_id'); + $websiteMock->expects($this->once()) + ->method('save'); + + $groupMock = $this->getMockBuilder('\Magento\Store\Model\Group')->disableOriginalConstructor()->getMock(); + $groupMock->expects($this->any()) + ->method('getId') + ->willReturn('group_id'); + $groupMock->expects($this->once()) + ->method('save'); + + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock->expects($this->once()) + ->method('getRootCategoryId') + ->willReturn(1); + $storeMock->expects($this->once()) + ->method('getId') + ->willReturn('store_id'); + $storeMock->expects($this->once()) + ->method('save'); + + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock->expects($this->once()) + ->method('getWebsite') + ->willReturn($websiteMock); + $storeManagerMock->expects($this->once()) + ->method('getGroup') + ->willReturn($groupMock); + $storeManagerMock->expects($this->once()) + ->method('getDefaultStoreView') + ->willReturn($storeMock); + $storeManagerMock->expects($this->once()) + ->method('getStore') + ->willReturn($storeMock); + + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->setMethods(array( + 'setId', + 'setUrlKey', + 'setUrlPath', + 'setName', + 'setParentId', + 'setPath', + 'setLevel', + 'setAvailableSortBy', + 'setDefaultSortBy', + 'setIsActive', + 'getId', + 'save' + ))->getMock(); + $categoryMock->expects($this->once()) + ->method('setId') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setUrlKey') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setUrlPath') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setName') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setParentId') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setPath') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setLevel') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setAvailableSortBy') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setDefaultSortBy') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('setIsActive') + ->willReturnSelf(); + $categoryMock->expects($this->any()) + ->method('getId') + ->willReturn('category_id'); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->exactly(2)) + ->method('create') + ->will($this->onConsecutiveCalls($storeManagerMock, $categoryMock)); + + $this->fixtureModelMock + ->expects($this->exactly(3)) + ->method('getValue') + ->will($this->onConsecutiveCalls(1, 1, 1)); + $this->fixtureModelMock + ->expects($this->exactly(2)) + ->method('getObjectManager') + ->willReturn($objectManagerMock); + + $storesFixture = new StoresFixture($this->fixtureModelMock); + $storesFixture->execute(); + } + + public function testGetActionTitle() + { + $storesFixture = new StoresFixture($this->fixtureModelMock); + $this->assertSame('Generating websites, stores and store views', $storesFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $storesFixture = new StoresFixture($this->fixtureModelMock); + $this->assertSame([ + 'websites' => 'Websites', + 'store_groups' => 'Store Groups', + 'store_views' => 'Store Views' + ], $storesFixture->introduceParamLabels()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php new file mode 100644 index 0000000000000..9e416eb4b06bf --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -0,0 +1,72 @@ +fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + } + + public function testExecute() + { + $rateMock = $this->getMockBuilder('Magento\Tax\Model\Calculation\Rate')->disableOriginalConstructor()->setMethods(array( + 'setId', + 'delete' + ))->getMock(); + + $collectionMock = $this->getMockBuilder('Magento\Tax\Model\Resource\Calculation\Rate\Collection')->disableOriginalConstructor()->getMock(); + $collectionMock->expects($this->once()) + ->method('getAllIds') + ->willReturn([1]); + + $csvImportHandlerMock = $this->getMockBuilder('Magento\TaxImportExport\Model\Rate\CsvImportHandler')->disableOriginalConstructor()->getMock(); + + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->exactly(2)) + ->method('get') + ->will($this->onConsecutiveCalls($collectionMock, $rateMock)); + $objectManagerMock->expects($this->once()) + ->method('create') + ->willReturn($csvImportHandlerMock); + + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn('taxRates.file'); + $this->fixtureModelMock + ->expects($this->exactly(3)) + ->method('getObjectManager') + ->willReturn($objectManagerMock); + + $taxRatesFixture = new TaxRatesFixture($this->fixtureModelMock); + $taxRatesFixture->execute(); + } + + public function testGetActionTitle() + { + $taxRatesFixture = new TaxRatesFixture($this->fixtureModelMock); + $this->assertSame('Generating tax rates', $taxRatesFixture->getActionTitle()); + } + + public function testIntroduceParamLabels() + { + $taxRatesFixture = new TaxRatesFixture($this->fixtureModelMock); + $this->assertSame([], $taxRatesFixture->introduceParamLabels()); + } + +} From ca8f8470c77bda2a374883b8dc3c7e68cadc38f9 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Tue, 9 Jun 2015 12:00:54 -0500 Subject: [PATCH 02/56] MAGETWO-38383: Increase Unit Test Code Coverage - Edited code style in accordance with acceptance tests --- .../Fixtures/CartPriceRulesFixtureTest.php | 25 +++-- .../Fixtures/CatalogPriceRulesFixtureTest.php | 17 ++-- .../Unit/Fixtures/CategoriesFixtureTest.php | 33 ++++--- .../Unit/Fixtures/ConfigsApplyFixtureTest.php | 8 +- .../ConfigurableProductsFixtureTest.php | 29 ++++-- .../Unit/Fixtures/CustomersFixtureTest.php | 19 +++- .../Fixtures/EavVariationsFixtureTest.php | 22 +++-- .../IndexersStatesApplyFixtureTest.php | 16 +++- .../Test/Unit/Fixtures/OrdersFixtureTest.php | 92 ++++++++++++------- .../Fixtures/SimpleProductsFixtureTest.php | 36 +++++--- .../Test/Unit/Fixtures/StoresFixtureTest.php | 47 ++++++---- .../Unit/Fixtures/TaxRatesFixtureTest.php | 31 +++++-- 12 files changed, 253 insertions(+), 122 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index c214047cec7a6..46240a01f2382 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -18,7 +18,9 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() @@ -36,18 +38,27 @@ public function testExecute() ->method('getId') ->will($this->returnValue('website_id')); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') + ->setConstructorArgs([$contextMock]) + ->setMethods(['getAllChildren']) + ->getMockForAbstractClass(); $abstractDbMock->expects($this->any()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') + ->disableOriginalConstructor() + ->getMock(); $categoryMock->expects($this->any()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); @@ -64,7 +75,9 @@ public function testExecute() ->will($this->returnValue('Field Id Name')); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->once()) ->method('create') ->will($this->returnValue($storeManagerMock)); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index d506155b2336e..6776ae71e27e1 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -8,7 +8,6 @@ use \Magento\Setup\Fixtures\CatalogPriceRulesFixture; - class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase { /** @@ -18,7 +17,9 @@ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() @@ -45,10 +46,14 @@ public function testExecute() ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); - $abstractDbMock = $this->getMockForAbstractClass('Magento\Framework\Model\Resource\Db\AbstractDb', [$contextMock], '', true, true, true, ['getAllChildren']); - $abstractDbMock - ->expects($this->any()) + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') + ->setConstructorArgs([$contextMock]) + ->setMethods(['getAllChildren']) + ->getMockForAbstractClass(); + $abstractDbMock->expects($this->any()) ->method('getAllChildren') ->will($this->returnValue([1])); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index ec704b2cfc522..44e362aed4608 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -17,24 +17,27 @@ class CategoriesFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() { - $categoryMock = $this->getMockBuilder('\Magento\Catalog\Model\Category')->disableOriginalConstructor()->setMethods(array( - 'getName', - 'setId', - 'setUrlKey', - 'setUrlPath', - 'setName', - 'setParentId', - 'setPath', - 'setLevel', - 'setAvailableSortBy', - 'setDefaultSortBy', - 'setIsActive', - 'save' - ))->getMock(); + $categoryMock = $this->getMockBuilder('\Magento\Catalog\Model\Category')->disableOriginalConstructor() + ->setMethods([ + 'getName', + 'setId', + 'setUrlKey', + 'setUrlPath', + 'setName', + 'setParentId', + 'setPath', + 'setLevel', + 'setAvailableSortBy', + 'setDefaultSortBy', + 'setIsActive', + 'save' + ])->getMock(); $categoryMock ->expects($this->once()) ->method('getName') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php index ae4a8c3ee6be0..68f004e0dc14d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php @@ -18,7 +18,9 @@ class ConfigsApplyFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() { @@ -26,7 +28,9 @@ public function testExecute() $valueMock = $this->getMockBuilder('\Magento\Framework\App\Config')->disableOriginalConstructor()->getMock(); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->once()) ->method('get') ->will($this->returnValue($cacheMock)); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index 6c9cfe67f26c3..023ad1532bc2d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -17,20 +17,31 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() { - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import')->disableOriginalConstructor()->getMock(); + $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') + ->disableOriginalConstructor() + ->getMock(); - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') + ->setConstructorArgs([$contextMock]) + ->setMethods(['getAllChildren']) + ->getMockForAbstractClass(); $abstractDbMock->expects($this->any()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') + ->disableOriginalConstructor() + ->getMock(); $categoryMock->expects($this->once()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); @@ -56,12 +67,16 @@ public function testExecute() ->method('getGroups') ->will($this->returnValue([$storeMock])); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php index b81a143bc38d7..4f4f6c49f0e30 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -8,7 +8,8 @@ use \Magento\Setup\Fixtures\CustomersFixture; -class CustomersFixtureTest extends \PHPUnit_Framework_TestCase { +class CustomersFixtureTest extends \PHPUnit_Framework_TestCase +{ /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel */ @@ -16,12 +17,16 @@ class CustomersFixtureTest extends \PHPUnit_Framework_TestCase { public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() { - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import')->disableOriginalConstructor()->getMock(); + $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') + ->disableOriginalConstructor() + ->getMock(); $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); $storeMock->expects($this->once()) @@ -33,7 +38,9 @@ public function testExecute() ->method('getCode') ->will($this->returnValue('website_code')); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); $storeManagerMock->expects($this->once()) ->method('getDefaultStoreView') ->will($this->returnValue($storeMock)); @@ -41,7 +48,9 @@ public function testExecute() ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $objectManagerMode = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMode = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMode->expects($this->exactly(2)) ->method('create') ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php index c064ab6a36d4d..f31b84b6ac00e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -18,13 +18,15 @@ class EavVariationsFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() { $attributeMock = $this->getMockBuilder('Magenot\Catalog\Model\Resource\Eav\Attribute') - ->setMethods(array('setAttributeGroupId', 'addData', 'setAttributeSetId', 'save')) + ->setMethods(['setAttributeGroupId', 'addData', 'setAttributeSetId', 'save']) ->getMock(); $attributeMock->expects($this->exactly(2)) ->method('setAttributeSetId') @@ -35,19 +37,27 @@ public function testExecute() $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); $storeManagerMock->expects($this->once()) ->method('getStores') ->will($this->returnValue([$storeMock])); - $setMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Set')->disableOriginalConstructor()->getMock(); + $setMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Set') + ->disableOriginalConstructor() + ->getMock(); $setMock->expects($this->once()) ->method('getDefaultGroupId') ->will($this->returnValue(2)); - $cacheMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface')->disableOriginalConstructor()->getMock(); + $cacheMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface') + ->disableOriginalConstructor() + ->getMock(); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->onConsecutiveCalls($attributeMock, $storeManagerMock)); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php index 651531d4dd395..0fc1bfd419a1d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php @@ -17,14 +17,20 @@ class IndexersStatesApplyFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() { - $cacheInterfaceMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface')->disableOriginalConstructor()->getMock(); + $cacheInterfaceMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface') + ->disableOriginalConstructor() + ->getMock(); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->once()) ->method('get') ->willReturn($cacheInterfaceMock); @@ -32,9 +38,9 @@ public function testExecute() $this->fixtureModelMock ->expects($this->once()) ->method('getValue') - ->willReturn(array( + ->willReturn([ 'indexer' => ['id' => 1] - )); + ]); $this->fixtureModelMock ->expects($this->once()) ->method('getObjectManager') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index e3a719ce17c44..0b53a11dfea98 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -10,7 +10,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase { - private $mockObjectNames = array( + private $mockObjectNames = [ 'Magento\Quote\Model\Resource\Quote', 'Magento\Quote\Model\Resource\Quote\Address', 'Magento\Quote\Model\Resource\Quote\Item', @@ -24,7 +24,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase 'Magento\Sales\Model\Resource\Order\Payment', 'Magento\Sales\Model\Resource\Order\Status\History', '\Magento\Eav\Model\Resource\Entity\Store' - ); + ]; private $mockObjects; @@ -35,22 +35,6 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); - } - - public function testExecute() - { - $adapterInterfaceMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface')->disableOriginalConstructor()->getMockForAbstractClass(); - $adapterInterfaceMock->expects($this->any()) - ->method('getTableName') - ->willReturn('table_name'); - - $resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource')->disableOriginalConstructor()->getMock(); - $resourceMock->expects($this->any()) - ->method('getConnection') - ->willReturn($adapterInterfaceMock); - - foreach ($this->mockObjectNames as $mockObjectName) { $mockObject = $this->getMockBuilder($mockObjectName)->disableOriginalConstructor()->getMock(); $path = explode('\\', $mockObjectName); @@ -64,11 +48,39 @@ public function testExecute() ->method('getTable') ->willReturn(strtolower($name) . '_table_name'); } - $map = array($mockObjectName, $mockObject); + $map = [$mockObjectName, $mockObject]; $this->mockObjects[] = $map; } - $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->setMethods(array('getId', 'getName'))->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testExecute() + { + $adapterInterfaceMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $adapterInterfaceMock->expects($this->any()) + ->method('getTableName') + ->willReturn('table_name'); + + $resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->getMock(); + $resourceMock->expects($this->any()) + ->method('getConnection') + ->willReturn($adapterInterfaceMock); + + $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getName']) + ->getMock(); $websiteMock->expects($this->once()) ->method('getId') ->willReturn('website_id'); @@ -76,18 +88,21 @@ public function testExecute() ->method('getName') ->willReturn('website_name'); - $groupMock = $this->getMockBuilder('\Magento\Store\Model\Group')->disableOriginalConstructor()->setMethods(array('getName'))->getMock(); + $groupMock = $this->getMockBuilder('\Magento\Store\Model\Group') + ->disableOriginalConstructor() + ->setMethods(['getName']) + ->getMock(); $groupMock->expects($this->once()) ->method('getName') ->willReturn('group_name'); - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->setMethods(array( + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->setMethods([ 'getStoreId', 'getWebsite', 'getGroup', 'getName', 'getRootCategoryId' - ))->getMock(); + ])->getMock(); $storeMock->expects($this->once()) ->method('getStoreId') ->willReturn(1); @@ -104,18 +119,27 @@ public function testExecute() ->method('getRootCategoryId') ->willReturn(1); - $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); $storeManager->expects($this->once()) ->method('getStores') ->willReturn([$storeMock]); - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') + ->setConstructorArgs([$contextMock]) + ->setMethods(['getAllChildren']) + ->getMockForAbstractClass(); $abstractDbMock->expects($this->any()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') + ->disableOriginalConstructor() + ->getMock(); $categoryMock->expects($this->once()) ->method('getResource') ->willReturn($abstractDbMock); @@ -128,18 +152,20 @@ public function testExecute() $categoryMock->expects($this->any()) ->method('load') ->willReturnSelf(); - $this->mockObjects[] = array('Magento\Catalog\Model\Category', $categoryMock); + $this->mockObjects[] = ['Magento\Catalog\Model\Category', $categoryMock]; $productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); $productMock->expects($this->any()) ->method('load') ->willReturnSelf(); - $this->mockObjects[] = array('Magento\Catalog\Model\Product', $productMock); - $this->mockObjects[] = array('Magento\Framework\App\Resource', $resourceMock); + $this->mockObjects[] = ['Magento\Catalog\Model\Product', $productMock]; + $this->mockObjects[] = ['Magento\Framework\App\Resource', $resourceMock]; $selectMock = $this->getMockBuilder('\Magento\Framework\DB\Select')->disableOriginalConstructor()->getMock(); - $collectionMock = $this->getMockBuilder('\Magento\Catalog\Model\Resource\Product\Collection')->disableOriginalConstructor()->getMock(); + $collectionMock = $this->getMockBuilder('\Magento\Catalog\Model\Resource\Product\Collection') + ->disableOriginalConstructor() + ->getMock(); $collectionMock->expects($this->once()) ->method('getSelect') ->willReturn($selectMock); @@ -147,7 +173,9 @@ public function testExecute() ->method('getAllIds') ->willReturn([1, 1]); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock ->expects($this->any()) ->method('get') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index d6a23f30c9dd9..dd5f0d01203d9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -8,8 +8,8 @@ use \Magento\Setup\Fixtures\SimpleProductsFixture; -class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase { - +class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase +{ /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel */ @@ -17,7 +17,9 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase { public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() @@ -35,20 +37,31 @@ public function testExecute() ->method('getGroups') ->willReturn([$storeMock]); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->willReturn([$websiteMock]); - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import')->disableOriginalConstructor()->getMock(); - - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context')->disableOriginalConstructor()->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb')->setConstructorArgs([$contextMock])->setMethods(['getAllChildren'])->getMockForAbstractClass(); + $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') + ->disableOriginalConstructor() + ->getMock(); + + $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') + ->setConstructorArgs([$contextMock]) + ->setMethods(['getAllChildren']) + ->getMockForAbstractClass(); $abstractDbMock->expects($this->any()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->getMock(); + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') + ->disableOriginalConstructor() + ->getMock(); $categoryMock->expects($this->once()) ->method('getResource') ->willReturn($abstractDbMock); @@ -62,7 +75,9 @@ public function testExecute() ->method('getName') ->willReturn('category_name'); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); @@ -96,5 +111,4 @@ public function testIntroduceParamLabels() 'simple_products' => 'Simple products' ], $simpleProductsFixture->introduceParamLabels()); } - } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php index ab9760b103d23..c061b6de6f57b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -18,9 +18,15 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } + /** + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ public function testExecute() { $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); @@ -47,7 +53,9 @@ public function testExecute() $storeMock->expects($this->once()) ->method('save'); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager')->disableOriginalConstructor()->getMock(); + $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); $storeManagerMock->expects($this->once()) ->method('getWebsite') ->willReturn($websiteMock); @@ -61,20 +69,23 @@ public function testExecute() ->method('getStore') ->willReturn($storeMock); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category')->disableOriginalConstructor()->setMethods(array( - 'setId', - 'setUrlKey', - 'setUrlPath', - 'setName', - 'setParentId', - 'setPath', - 'setLevel', - 'setAvailableSortBy', - 'setDefaultSortBy', - 'setIsActive', - 'getId', - 'save' - ))->getMock(); + $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') + ->disableOriginalConstructor() + ->setMethods([ + 'setId', + 'setUrlKey', + 'setUrlPath', + 'setName', + 'setParentId', + 'setPath', + 'setLevel', + 'setAvailableSortBy', + 'setDefaultSortBy', + 'setIsActive', + 'getId', + 'save' + ]) + ->getMock(); $categoryMock->expects($this->once()) ->method('setId') ->willReturnSelf(); @@ -109,7 +120,9 @@ public function testExecute() ->method('getId') ->willReturn('category_id'); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->onConsecutiveCalls($storeManagerMock, $categoryMock)); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 9e416eb4b06bf..7093b8c02b3b4 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -10,7 +10,8 @@ use Magento\Weee\Model\Attribute\Backend\Weee\Tax; use Test\AAaa\test; -class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase { +class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase +{ /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel @@ -19,24 +20,35 @@ class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase { public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel')->disableOriginalConstructor()->getMock(); + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); } public function testExecute() { - $rateMock = $this->getMockBuilder('Magento\Tax\Model\Calculation\Rate')->disableOriginalConstructor()->setMethods(array( - 'setId', - 'delete' - ))->getMock(); + $rateMock = $this->getMockBuilder('Magento\Tax\Model\Calculation\Rate') + ->disableOriginalConstructor() + ->setMethods([ + 'setId', + 'delete' + ]) + ->getMock(); - $collectionMock = $this->getMockBuilder('Magento\Tax\Model\Resource\Calculation\Rate\Collection')->disableOriginalConstructor()->getMock(); + $collectionMock = $this->getMockBuilder('Magento\Tax\Model\Resource\Calculation\Rate\Collection') + ->disableOriginalConstructor() + ->getMock(); $collectionMock->expects($this->once()) ->method('getAllIds') ->willReturn([1]); - $csvImportHandlerMock = $this->getMockBuilder('Magento\TaxImportExport\Model\Rate\CsvImportHandler')->disableOriginalConstructor()->getMock(); + $csvImportHandlerMock = $this->getMockBuilder('Magento\TaxImportExport\Model\Rate\CsvImportHandler') + ->disableOriginalConstructor() + ->getMock(); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')->disableOriginalConstructor()->getMock(); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); $objectManagerMock->expects($this->exactly(2)) ->method('get') ->will($this->onConsecutiveCalls($collectionMock, $rateMock)); @@ -68,5 +80,4 @@ public function testIntroduceParamLabels() $taxRatesFixture = new TaxRatesFixture($this->fixtureModelMock); $this->assertSame([], $taxRatesFixture->introduceParamLabels()); } - } From 440e2d5f65f0dbd58428faa2a73a57f39ea1be6f Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Tue, 9 Jun 2015 13:47:09 -0500 Subject: [PATCH 03/56] MAGETWO-38383: Increase Unit Test Code Coverage - Fixed unit tests --- .../Test/Unit/Fixtures/OrdersFixtureTest.php | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index 0b53a11dfea98..c999e4eb9ce54 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -34,6 +34,17 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase private $fixtureModelMock; public function setUp() + { + $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testExecute() { foreach ($this->mockObjectNames as $mockObjectName) { $mockObject = $this->getMockBuilder($mockObjectName)->disableOriginalConstructor()->getMock(); @@ -52,17 +63,6 @@ public function setUp() $this->mockObjects[] = $map; } - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); - } - - /** - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testExecute() - { $adapterInterfaceMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -154,10 +154,19 @@ public function testExecute() ->willReturnSelf(); $this->mockObjects[] = ['Magento\Catalog\Model\Category', $categoryMock]; - $productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->setMethods(['load', 'getSku', 'getName']) + ->getMock(); $productMock->expects($this->any()) ->method('load') ->willReturnSelf(); + $productMock->expects($this->any()) + ->method('getSku') + ->willReturn('product_sku'); + $productMock->expects($this->any()) + ->method('getName') + ->willReturn('product_name'); $this->mockObjects[] = ['Magento\Catalog\Model\Product', $productMock]; $this->mockObjects[] = ['Magento\Framework\App\Resource', $resourceMock]; From a166001d397ab5e1c7c60d91ee5302baca2ac448 Mon Sep 17 00:00:00 2001 From: Yuri Kovsher Date: Wed, 10 Jun 2015 12:06:41 +0300 Subject: [PATCH 04/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway --- app/code/Magento/Sales/Model/Order/Payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 8bb5b416876d0..522db9a764ef7 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -276,7 +276,7 @@ public function place() $isCustomerNotified = $isCustomerNotified ?: $order->getCustomerNoteNotify(); - if (!in_array($orderStatus, $order->getConfig()->getStateStatuses($orderState))) { + if (!array_key_exists($orderStatus, $order->getConfig()->getStateStatuses($orderState))) { $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState); } From 1197fa73d5a936e7a555a0d4258a9511e6b95183 Mon Sep 17 00:00:00 2001 From: Yuri Kovsher Date: Wed, 10 Jun 2015 17:30:43 +0300 Subject: [PATCH 05/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway --- app/code/Magento/Sales/Model/Order/Payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 522db9a764ef7..ffbc04ae6293f 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -404,7 +404,7 @@ public function capture($invoice) ); } $status = false; - if (!$invoice->getIsPaid() && !$this->getIsTransactionPending()) { + if (!$invoice->getIsPaid()) { // attempt to capture: this can trigger "is_transaction_pending" $this->getMethodInstance()->setStore($order->getStoreId())->capture($this, $amountToCapture); From 181eb0d2ab90dc449913b4209d22498de8d45e9b Mon Sep 17 00:00:00 2001 From: Maxim Shikula Date: Thu, 11 Jun 2015 17:54:05 +0300 Subject: [PATCH 06/56] MAGETWO-32942: Processing Triggered Only Suspicious Transactions --- app/code/Magento/Sales/Model/Order/Payment.php | 2 +- .../Magento/Sales/view/adminhtml/layout/sales_order_view.xml | 2 ++ .../Sales/view/adminhtml/templates/order/view/tab/info.phtml | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 2c0960eba7ac3..f84b63220830b 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -1176,7 +1176,7 @@ public function authorize($isOnline, $amount) ); } else { if ($this->getIsFraudDetected()) { - $state = Order::STATE_PAYMENT_REVIEW; + $state = Order::STATE_PROCESSING; $message = __( 'Order is suspended as its authorizing amount %1 is suspected to be fraudulent.', $this->_formatPrice($amount, $this->getCurrencyCode()) diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml index 19260c6cf0849..f0c99ecaf4464 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml @@ -31,6 +31,8 @@ + + diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/view/tab/info.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/view/tab/info.phtml index b315a0053976c..18b099b5aa7d3 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/view/tab/info.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/view/tab/info.phtml @@ -30,7 +30,10 @@
getPaymentHtml() ?>
getOrderCurrencyCode()) ?>
-
getChildHtml('order_payment_additional'); ?>
+
+ getChildHtml('order_payment_additional'); ?> + getChildHtml('payment_additional_info'); ?> +
getChildHtml('order_shipping_view') ?> From bd0ad2a6736bd03453474fbcef4a5c2b75ebdbfd Mon Sep 17 00:00:00 2001 From: Maxim Shikula Date: Thu, 11 Jun 2015 18:29:25 +0300 Subject: [PATCH 07/56] MAGETWO-32942: Processing Triggered Only Suspicious Transactions --- app/code/Magento/Sales/Setup/InstallData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Setup/InstallData.php b/app/code/Magento/Sales/Setup/InstallData.php index 0c19a25a16670..2dac7727cef40 100644 --- a/app/code/Magento/Sales/Setup/InstallData.php +++ b/app/code/Magento/Sales/Setup/InstallData.php @@ -101,7 +101,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface ], 'processing' => [ 'label' => __('Processing'), - 'statuses' => ['processing' => ['default' => '1']], + 'statuses' => ['processing' => ['default' => '1'], 'fraud' => []], 'visible_on_front' => true, ], 'complete' => [ From 074dd430a3f679b67d5fa33dedcb5957165b1bdd Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Thu, 11 Jun 2015 11:29:57 -0500 Subject: [PATCH 08/56] MAGETWO-38383: Increase Unit Test Code Coverage - Removed extra newlines - Changed uses of getMockBuilder to getMock - Removed duplicate code - Replaced onConsecutiveCalls to returnValueMaps --- .../Fixtures/CartPriceRulesFixtureTest.php | 70 ++++----- .../Fixtures/CatalogPriceRulesFixtureTest.php | 72 ++++------ .../Unit/Fixtures/CategoriesFixtureTest.php | 50 ++++--- .../Unit/Fixtures/ConfigsApplyFixtureTest.php | 28 ++-- .../ConfigurableProductsFixtureTest.php | 74 +++++----- .../Unit/Fixtures/CustomersFixtureTest.php | 48 ++++--- .../Fixtures/EavVariationsFixtureTest.php | 54 ++++--- .../IndexersStatesApplyFixtureTest.php | 28 ++-- .../Test/Unit/Fixtures/OrdersFixtureTest.php | 135 ++++++++---------- .../Fixtures/SimpleProductsFixtureTest.php | 73 +++++----- .../Test/Unit/Fixtures/StoresFixtureTest.php | 83 +++++------ .../Unit/Fixtures/TaxRatesFixtureTest.php | 44 +++--- 12 files changed, 368 insertions(+), 391 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index 46240a01f2382..431ad680ae2aa 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -10,27 +10,31 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase { - /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\CartPriceRulesFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new CartPriceRulesFixture($this->fixtureModelMock); } public function testExecute() { - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue(2)); - $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); $websiteMock->expects($this->once()) ->method('getGroups') ->will($this->returnValue([$storeMock])); @@ -38,28 +42,27 @@ public function testExecute() ->method('getId') ->will($this->returnValue('website_id')); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') - ->disableOriginalConstructor() - ->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') - ->setConstructorArgs([$contextMock]) - ->setMethods(['getAllChildren']) - ->getMockForAbstractClass(); - $abstractDbMock->expects($this->any()) + $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); + $abstractDbMock = $this->getMockForAbstractClass( + '\Magento\Framework\Model\Resource\Db\AbstractDb', + [$contextMock], + '', + true, + true, + true, + ['getAllChildren'] + ); + $abstractDbMock->expects($this->once()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') - ->disableOriginalConstructor() - ->getMock(); - $categoryMock->expects($this->any()) + $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock->expects($this->once()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); $categoryMock->expects($this->once()) @@ -68,48 +71,45 @@ public function testExecute() $categoryMock->expects($this->once()) ->method('getId') ->will($this->returnValue('category_id')); + $valueMap[] = ['Magento\Catalog\Model\Category', $categoryMock,]; - $modelMock = $this->getMockBuilder('\Magento\SalesRule\Model\Rule')->disableOriginalConstructor()->getMock(); + $modelMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); $modelMock->expects($this->once()) ->method('getIdFieldName') ->will($this->returnValue('Field Id Name')); + $valueMap[] = ['Magento\SalesRule\Model\Rule', $modelMock]; - - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->once()) ->method('create') ->will($this->returnValue($storeManagerMock)); $objectManagerMock->expects($this->exactly(2)) ->method('get') - ->will($this->onConsecutiveCalls($categoryMock, $modelMock)); + ->will($this->returnValueMap($valueMap)); + $valueMap[] = ['cart_price_rules', 0, 1]; + $valueMap[] = ['cart_price_rules_floor', 3, 3]; $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getValue') - ->will($this->onConsecutiveCalls(1, 3)); + ->will($this->returnValueMap($valueMap)); $this->fixtureModelMock ->expects($this->exactly(3)) ->method('getObjectManager') ->will($this->returnValue($objectManagerMock)); - - $cartPriceFixture = new CartPriceRulesFixture($this->fixtureModelMock); - $cartPriceFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $cartPriceFixture = new CartPriceRulesFixture($this->fixtureModelMock); - $this->assertSame('Generating shopping cart price rules', $cartPriceFixture->getActionTitle()); + $this->assertSame('Generating shopping cart price rules', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $cartPriceFixture = new CartPriceRulesFixture($this->fixtureModelMock); $this->assertSame([ 'cart_price_rules' => 'Cart Price Rules' - ], $cartPriceFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index 6776ae71e27e1..f5ddca85604d9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -15,82 +15,70 @@ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\CatalogPriceRulesFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new CatalogPriceRulesFixture($this->fixtureModelMock); } public function testExecute() { $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeMock - ->expects($this->once()) + $storeMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue(2)); $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); - $websiteMock - ->expects($this->once()) + $websiteMock->expects($this->once()) ->method('getGroups') ->will($this->returnValue([$storeMock])); - $websiteMock - ->expects($this->once()) + $websiteMock->expects($this->once()) ->method('getId') ->will($this->returnValue('website_id')); $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $storeManagerMock - ->expects($this->once()) + $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') - ->disableOriginalConstructor() - ->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') - ->setConstructorArgs([$contextMock]) - ->setMethods(['getAllChildren']) - ->getMockForAbstractClass(); - $abstractDbMock->expects($this->any()) + $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); + $abstractDbMock = $this->getMockForAbstractClass('\Magento\Framework\Model\Resource\Db\AbstractDb', [$contextMock], '', true, true, true, ['getAllChildren']); + $abstractDbMock->expects($this->once()) ->method('getAllChildren') ->will($this->returnValue([1])); $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); - $categoryMock - ->expects($this->any()) + $categoryMock->expects($this->once()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); - $categoryMock - ->expects($this->once()) + $categoryMock->expects($this->once()) ->method('getPath') ->will($this->returnValue('path/to/file')); - $categoryMock - ->expects($this->once()) + $categoryMock->expects($this->once()) ->method('getId') ->will($this->returnValue('category_id')); + $valueMap[] = ['Magento\Catalog\Model\Category', $categoryMock]; - $modelMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); - $modelMock - ->expects($this->once()) + $modelMock = $this->getMock('Magento\CatalogRule\Model\Rule', [], [], '', false); + $modelMock->expects($this->once()) ->method('getIdFieldName') ->will($this->returnValue('Field Id Name')); - + $valueMap[] = ['Magento\CatalogRule\Model\Rule', $modelMock]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); - $objectManagerMock - ->expects($this->once()) + $objectManagerMock->expects($this->once()) ->method('create') ->will($this->returnValue($storeManagerMock)); - $objectManagerMock - ->expects($this->exactly(2)) + $objectManagerMock->expects($this->exactly(2)) ->method('get') - ->will($this->onConsecutiveCalls($categoryMock, $modelMock)); + ->will($this->returnValueMap($valueMap)); - $this->fixtureModelMock - ->expects($this->once()) - ->method('resetObjectManager'); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') @@ -100,22 +88,18 @@ public function testExecute() ->method('getObjectManager') ->will($this->returnValue($objectManagerMock)); - - $catalogPriceFixture = new CatalogPriceRulesFixture($this->fixtureModelMock); - $catalogPriceFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $catalogPriceFixture = new CatalogPriceRulesFixture($this->fixtureModelMock); - $this->assertSame('Generating catalog price rules', $catalogPriceFixture->getActionTitle()); + $this->assertSame('Generating catalog price rules', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $catalogPriceFixture = new CatalogPriceRulesFixture($this->fixtureModelMock); $this->assertSame([ 'catalog_price_rules' => 'Catalog Price Rules' - ], $catalogPriceFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index 44e362aed4608..ca431afe6edc0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -15,16 +15,22 @@ class CategoriesFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\CategoriesFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new CategoriesFixture($this->fixtureModelMock); } public function testExecute() { - $categoryMock = $this->getMockBuilder('\Magento\Catalog\Model\Category')->disableOriginalConstructor() - ->setMethods([ + $categoryMock = $this->getMock( + '\Magento\Catalog\Model\Category', + [ 'getName', 'setId', 'setUrlKey', @@ -37,9 +43,11 @@ public function testExecute() 'setDefaultSortBy', 'setIsActive', 'save' - ])->getMock(); - $categoryMock - ->expects($this->once()) + ], + [], + '', + false); + $categoryMock->expects($this->once()) ->method('getName') ->will($this->returnValue('category_name')); $categoryMock->expects($this->once()) @@ -72,49 +80,47 @@ public function testExecute() $categoryMock->expects($this->once()) ->method('setIsActive') ->willReturnSelf(); + $valueMap[] = ['Magento\Catalog\Model\Category', [], $categoryMock]; $groupMock = $this->getMock('\Magento\Store\Model\Group', [], [], '', false); - $groupMock - ->expects($this->once()) + $groupMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue('root_category_id')); $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $storeManagerMock - ->expects($this->once()) + $storeManagerMock->expects($this->once()) ->method('getGroups') ->will($this->returnValue([$groupMock])); + $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); - $objectManagerMock - ->expects($this->exactly(2)) + $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->onConsecutiveCalls($storeManagerMock, $categoryMock)); + ->will($this->returnValueMap($valueMap)); + $valueMap[] = ['categories', 0, 1]; + $valueMap[] = ['categories_nesting_level', 3, 3]; $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getValue') - ->will($this->onConsecutiveCalls(1, 3)); + ->will($this->returnValueMap($valueMap)); $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getObjectManager') ->will($this->returnValue($objectManagerMock)); - $categoriesFixture = new CategoriesFixture($this->fixtureModelMock); - $categoriesFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $categoriesFixture = new CategoriesFixture($this->fixtureModelMock); - $this->assertSame('Generating categories', $categoriesFixture->getActionTitle()); + $this->assertSame('Generating categories', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $categoriesFixture = new CategoriesFixture($this->fixtureModelMock); $this->assertSame([ 'categories' => 'Categories' - ], $categoriesFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php index 68f004e0dc14d..6a9c3788c93ee 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php @@ -16,21 +16,24 @@ class ConfigsApplyFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\ConfigsApplyFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new ConfigsApplyFixture($this->fixtureModelMock); } public function testExecute() { - $cacheMock = $this->getMockBuilder('\Magento\Framework\App\Cache')->disableOriginalConstructor()->getMock(); + $cacheMock = $this->getMock('\Magento\Framework\App\Cache', [], [], '', false); - $valueMock = $this->getMockBuilder('\Magento\Framework\App\Config')->disableOriginalConstructor()->getMock(); + $valueMock = $this->getMock('\Magento\Framework\App\Config', [], [], '', false); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->once()) ->method('get') ->will($this->returnValue($cacheMock)); @@ -44,19 +47,16 @@ public function testExecute() ->method('getObjectManager') ->will($this->returnValue($objectManagerMock)); - $configsApplyFixture = new ConfigsApplyFixture($this->fixtureModelMock); - $configsApplyFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $configsApplyFixture = new ConfigsApplyFixture($this->fixtureModelMock); - $this->assertSame('Config Changes', $configsApplyFixture->getActionTitle()); + $this->assertSame('Config Changes', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $configsApplyFixture = new ConfigsApplyFixture($this->fixtureModelMock); - $this->assertSame([], $configsApplyFixture->introduceParamLabels()); + $this->assertSame([], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index 023ad1532bc2d..6d1fc16d29525 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -15,51 +15,61 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\ConfigurableProductsFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new ConfigurableProductsFixture($this->fixtureModelMock); } public function testExecute() { - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') - ->disableOriginalConstructor() - ->getMock(); - - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') - ->disableOriginalConstructor() - ->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') - ->setConstructorArgs([$contextMock]) - ->setMethods(['getAllChildren']) - ->getMockForAbstractClass(); - $abstractDbMock->expects($this->any()) + $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $valueMap[] = [ + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'catalog_product', 'behavior' => 'replace']], + $importMock + ]; + + $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); + $abstractDbMock = $this->getMockForAbstractClass( + '\Magento\Framework\Model\Resource\Db\AbstractDb', + [$contextMock], + '', + true, + true, + true, + ['getAllChildren'] + ); + $abstractDbMock->expects($this->once()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') - ->disableOriginalConstructor() - ->getMock(); + $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->exactly(3)) ->method('getName') ->will($this->returnValue('category_name')); $categoryMock->expects($this->once()) ->method('getPath') ->will($this->returnValue('path/to/category')); - $categoryMock->expects($this->any())->method('load') + $categoryMock->expects($this->exactly(4)) + ->method('load') ->willReturnSelf(); - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue([2])); - $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); $websiteMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('website_code')); @@ -67,19 +77,16 @@ public function testExecute() ->method('getGroups') ->will($this->returnValue([$storeMock])); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); + $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); + ->will($this->returnValueMap($valueMap)); $objectManagerMock->expects($this->once()) ->method('get') ->will($this->returnValue($categoryMock)); @@ -93,21 +100,18 @@ public function testExecute() ->method('getObjectManager') ->will($this->returnValue($objectManagerMock)); - $configurableProductsFixture = new ConfigurableProductsFixture($this->fixtureModelMock); - $configurableProductsFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $configurableProductsFixture = new ConfigurableProductsFixture($this->fixtureModelMock); - $this->assertSame('Generating configurable products', $configurableProductsFixture->getActionTitle()); + $this->assertSame('Generating configurable products', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $configurableProductsFixture = new ConfigurableProductsFixture($this->fixtureModelMock); $this->assertSame([ 'configurable_products' => 'Configurable products' - ], $configurableProductsFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php index 4f4f6c49f0e30..29dc845215728 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -15,45 +15,50 @@ class CustomersFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\CustomersFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new CustomersFixture($this->fixtureModelMock); } public function testExecute() { - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') - ->disableOriginalConstructor() - ->getMock(); + $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $valueMap[] = [ + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'customer_composite', 'behavior' => 'append']], + $importMock + ]; - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('store_code')); - $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); $websiteMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('website_code')); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getDefaultStoreView') ->will($this->returnValue($storeMock)); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); + $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; - $objectManagerMode = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - $objectManagerMode->expects($this->exactly(2)) + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); + ->will($this->returnValueMap($valueMap)); $this->fixtureModelMock ->expects($this->once()) @@ -62,23 +67,20 @@ public function testExecute() $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getObjectManager') - ->will($this->returnValue($objectManagerMode)); + ->will($this->returnValue($objectManagerMock)); - $customersFixture = new CustomersFixture($this->fixtureModelMock); - $customersFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $customersFixture = new CustomersFixture($this->fixtureModelMock); - $this->assertSame('Generating customers', $customersFixture->getActionTitle()); + $this->assertSame('Generating customers', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $customersFixture = new CustomersFixture($this->fixtureModelMock); $this->assertSame([ 'customers' => 'Customers' - ], $customersFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php index f31b84b6ac00e..72a5423985dad 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -16,54 +16,63 @@ class EavVariationsFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\EavVariationsFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new EavVariationsFixture($this->fixtureModelMock); } public function testExecute() { - $attributeMock = $this->getMockBuilder('Magenot\Catalog\Model\Resource\Eav\Attribute') - ->setMethods(['setAttributeGroupId', 'addData', 'setAttributeSetId', 'save']) - ->getMock(); + $attributeMock = $this->getMock( + 'Magento\Catalog\Model\Resource\Eav\Attribute', + [ + 'setAttributeSetId', + 'setAttributeGroupId', + 'save' + ], + [], + '', + false + ); $attributeMock->expects($this->exactly(2)) ->method('setAttributeSetId') ->willReturnSelf(); $attributeMock->expects($this->once()) ->method('setAttributeGroupId') ->willReturnSelf(); + $valueMap[] = ['Magento\Catalog\Model\Resource\Eav\Attribute', [], $attributeMock]; - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getStores') ->will($this->returnValue([$storeMock])); + $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; - $setMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Set') - ->disableOriginalConstructor() - ->getMock(); + $setMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false); $setMock->expects($this->once()) ->method('getDefaultGroupId') ->will($this->returnValue(2)); + $valueMap[] = ['Magento\Eav\Model\Entity\Attribute\Set', $setMock]; - $cacheMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface') - ->disableOriginalConstructor() - ->getMock(); + $cacheMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); + $valueMap[] = ['Magento\Framework\App\CacheInterface', $cacheMock]; - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->onConsecutiveCalls($attributeMock, $storeManagerMock)); + ->will($this->returnValueMap($valueMap)); $objectManagerMock->expects($this->exactly(2)) ->method('get') - ->will($this->onConsecutiveCalls($setMock, $cacheMock)); + ->will($this->returnValueMap($valueMap)); $this->fixtureModelMock ->expects($this->once()) @@ -74,8 +83,7 @@ public function testExecute() ->method('getObjectManager') ->will($this->returnValue($objectManagerMock)); - $eavVariationsFixture = new EavVariationsFixture($this->fixtureModelMock); - $eavVariationsFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php index 0fc1bfd419a1d..2b15554348bc9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php @@ -15,22 +15,23 @@ class IndexersStatesApplyFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\IndexersStatesApplyFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new IndexersStatesApplyFixture($this->fixtureModelMock); } public function testExecute() { - $cacheInterfaceMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface') - ->disableOriginalConstructor() - ->getMock(); + $cacheInterfaceMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->once()) ->method('get') ->willReturn($cacheInterfaceMock); @@ -46,19 +47,16 @@ public function testExecute() ->method('getObjectManager') ->willReturn($objectManagerMock); - $indexersStatesApplyFixture = new IndexersStatesApplyFixture($this->fixtureModelMock); - $indexersStatesApplyFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $indexersStatesApplyFixture = new IndexersStatesApplyFixture($this->fixtureModelMock); - $this->assertSame('Indexers Mode Changes', $indexersStatesApplyFixture->getActionTitle()); + $this->assertSame('Indexers Mode Changes', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $indexersStatesApplyFixture = new IndexersStatesApplyFixture($this->fixtureModelMock); - $this->assertSame([], $indexersStatesApplyFixture->introduceParamLabels()); + $this->assertSame([], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index c999e4eb9ce54..8dfb98c21136c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -33,11 +33,16 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\OrdersFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new OrdersFixture($this->fixtureModelMock); } /** @@ -47,7 +52,7 @@ public function setUp() public function testExecute() { foreach ($this->mockObjectNames as $mockObjectName) { - $mockObject = $this->getMockBuilder($mockObjectName)->disableOriginalConstructor()->getMock(); + $mockObject = $this->getMock($mockObjectName, [], [], '', false); $path = explode('\\', $mockObjectName); $name = array_pop($path); if (strcasecmp($mockObjectName, 'Magento\Sales\Model\Resource\Order') == 0) { @@ -59,28 +64,20 @@ public function testExecute() ->method('getTable') ->willReturn(strtolower($name) . '_table_name'); } - $map = [$mockObjectName, $mockObject]; - $this->mockObjects[] = $map; + $this->mockObjects[] = [$mockObjectName, $mockObject]; } - $adapterInterfaceMock = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $adapterInterfaceMock->expects($this->any()) + $adapterInterfaceMock = $this->getMockForAbstractClass('\Magento\Framework\DB\Adapter\AdapterInterface', [], '', true, true, true, []); + $adapterInterfaceMock->expects($this->exactly(14)) ->method('getTableName') ->willReturn('table_name'); - $resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource') - ->disableOriginalConstructor() - ->getMock(); - $resourceMock->expects($this->any()) + $resourceMock = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $resourceMock->expects($this->exactly(15)) ->method('getConnection') ->willReturn($adapterInterfaceMock); - $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website') - ->disableOriginalConstructor() - ->setMethods(['getId', 'getName']) - ->getMock(); + $websiteMock = $this->getMock('\Magento\Store\Model\Website', ['getId', 'getName'], [], '', false); $websiteMock->expects($this->once()) ->method('getId') ->willReturn('website_id'); @@ -88,21 +85,24 @@ public function testExecute() ->method('getName') ->willReturn('website_name'); - $groupMock = $this->getMockBuilder('\Magento\Store\Model\Group') - ->disableOriginalConstructor() - ->setMethods(['getName']) - ->getMock(); + $groupMock = $this->getMock('\Magento\Store\Model\Group', ['getName'], [], '', false); $groupMock->expects($this->once()) ->method('getName') ->willReturn('group_name'); - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->setMethods([ - 'getStoreId', - 'getWebsite', - 'getGroup', - 'getName', - 'getRootCategoryId' - ])->getMock(); + $storeMock = $this->getMock( + '\Magento\Store\Model\Store', + [ + 'getStoreId', + 'getWebsite', + 'getGroup', + 'getName', + 'getRootCategoryId' + ], + [], + '', + false + ); $storeMock->expects($this->once()) ->method('getStoreId') ->willReturn(1); @@ -119,105 +119,94 @@ public function testExecute() ->method('getRootCategoryId') ->willReturn(1); - $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); - $storeManager->expects($this->once()) + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock->expects($this->once()) ->method('getStores') ->willReturn([$storeMock]); - - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') - ->disableOriginalConstructor() - ->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') - ->setConstructorArgs([$contextMock]) - ->setMethods(['getAllChildren']) - ->getMockForAbstractClass(); - $abstractDbMock->expects($this->any()) + $this->mockObjects[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; + + $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); + $abstractDbMock = $this->getMockForAbstractClass( + '\Magento\Framework\Model\Resource\Db\AbstractDb', + [$contextMock], + '', + true, + true, + true, + ['getAllChildren'] + ); + $abstractDbMock->expects($this->once()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') - ->disableOriginalConstructor() - ->getMock(); + $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->willReturn($abstractDbMock); $categoryMock->expects($this->once()) ->method('getPath') ->willReturn('path/to/category'); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->exactly(2)) ->method('getName') ->willReturn('category_name'); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->exactly(5)) ->method('load') ->willReturnSelf(); $this->mockObjects[] = ['Magento\Catalog\Model\Category', $categoryMock]; - $productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product') - ->disableOriginalConstructor() - ->setMethods(['load', 'getSku', 'getName']) - ->getMock(); - $productMock->expects($this->any()) + $productMock = $this->getMock('\Magento\Catalog\Model\Product', ['load', 'getSku', 'getName'], [], '', false); + $productMock->expects($this->exactly(2)) ->method('load') ->willReturnSelf(); - $productMock->expects($this->any()) + $productMock->expects($this->exactly(2)) ->method('getSku') ->willReturn('product_sku'); - $productMock->expects($this->any()) + $productMock->expects($this->exactly(2)) ->method('getName') ->willReturn('product_name'); $this->mockObjects[] = ['Magento\Catalog\Model\Product', $productMock]; $this->mockObjects[] = ['Magento\Framework\App\Resource', $resourceMock]; - $selectMock = $this->getMockBuilder('\Magento\Framework\DB\Select')->disableOriginalConstructor()->getMock(); + $selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); - $collectionMock = $this->getMockBuilder('\Magento\Catalog\Model\Resource\Product\Collection') - ->disableOriginalConstructor() - ->getMock(); + $collectionMock = $this->getMock('\Magento\Catalog\Model\Resource\Product\Collection', [], [], '', false); $collectionMock->expects($this->once()) ->method('getSelect') ->willReturn($selectMock); $collectionMock->expects($this->once()) ->method('getAllIds') ->willReturn([1, 1]); + $this->mockObjects[] = ['Magento\Catalog\Model\Resource\Product\Collection', [], $collectionMock]; - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - $objectManagerMock - ->expects($this->any()) + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->exactly(32)) ->method('get') ->will($this->returnValueMap($this->mockObjects)); - $objectManagerMock - ->expects($this->exactly(2)) + $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->onConsecutiveCalls($storeManager, $collectionMock)); + ->will($this->returnValueMap($this->mockObjects)); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') ->willReturn(1); $this->fixtureModelMock - ->expects($this->any()) + ->expects($this->exactly(34)) ->method('getObjectManager') ->willReturn($objectManagerMock); - $ordersFixture = new OrdersFixture($this->fixtureModelMock); - $ordersFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $ordersFixture = new OrdersFixture($this->fixtureModelMock); - $this->assertSame('Generating orders', $ordersFixture->getActionTitle()); + $this->assertSame('Generating orders', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $ordersFixture = new OrdersFixture($this->fixtureModelMock); $this->assertSame([ 'orders' => 'Orders' - ], $ordersFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index dd5f0d01203d9..a87d075c373e8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -15,21 +15,26 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\SimpleProductsFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new SimpleProductsFixture($this->fixtureModelMock); } public function testExecute() { - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->willReturn(1); - $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); + $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); $websiteMock->expects($this->once()) ->method('getCode') ->willReturn('website_code'); @@ -37,50 +42,51 @@ public function testExecute() ->method('getGroups') ->willReturn([$storeMock]); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->willReturn([$websiteMock]); + $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; + + $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $valueMap[] = [ + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']], + $importMock + ]; - $importMock = $this->getMockBuilder('\Magento\ImportExport\Model\Import') - ->disableOriginalConstructor() - ->getMock(); - - $contextMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') - ->disableOriginalConstructor() - ->getMock(); - $abstractDbMock = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\AbstractDb') - ->setConstructorArgs([$contextMock]) - ->setMethods(['getAllChildren']) - ->getMockForAbstractClass(); - $abstractDbMock->expects($this->any()) + $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); + $abstractDbMock = $this->getMockForAbstractClass( + '\Magento\Framework\Model\Resource\Db\AbstractDb', + [$contextMock], + '', + true, + true, + true, + ['getAllChildren'] + ); + $abstractDbMock->expects($this->once()) ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') - ->disableOriginalConstructor() - ->getMock(); + $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->willReturn($abstractDbMock); $categoryMock->expects($this->once()) ->method('getPath') ->willReturn('path/to/category'); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->exactly(4)) ->method('load') ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->exactly(2)) ->method('getName') ->willReturn('category_name'); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->onConsecutiveCalls($storeManagerMock, $importMock)); + ->will($this->returnValueMap($valueMap)); $objectManagerMock->expects($this->once()) ->method('get') ->willReturn($categoryMock); @@ -94,21 +100,18 @@ public function testExecute() ->method('getObjectManager') ->willReturn($objectManagerMock); - $simpleProductsFixture = new SimpleProductsFixture($this->fixtureModelMock); - $simpleProductsFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $simpleProductsFixture = new SimpleProductsFixture($this->fixtureModelMock); - $this->assertSame('Generating simple products', $simpleProductsFixture->getActionTitle()); + $this->assertSame('Generating simple products', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $simpleProductsFixture = new SimpleProductsFixture($this->fixtureModelMock); $this->assertSame([ 'simple_products' => 'Simple products' - ], $simpleProductsFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php index c061b6de6f57b..75a161ebd6218 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -16,11 +16,16 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\StoresFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new StoresFixture($this->fixtureModelMock); } /** @@ -29,21 +34,21 @@ public function setUp() */ public function testExecute() { - $websiteMock = $this->getMockBuilder('\Magento\Store\Model\Website')->disableOriginalConstructor()->getMock(); - $websiteMock->expects($this->any()) + $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock->expects($this->exactly(2)) ->method('getId') ->willReturn('website_id'); $websiteMock->expects($this->once()) ->method('save'); - $groupMock = $this->getMockBuilder('\Magento\Store\Model\Group')->disableOriginalConstructor()->getMock(); - $groupMock->expects($this->any()) + $groupMock = $this->getMock('\Magento\Store\Model\Group', [], [], '', false); + $groupMock->expects($this->exactly(2)) ->method('getId') ->willReturn('group_id'); $groupMock->expects($this->once()) ->method('save'); - $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->willReturn(1); @@ -53,9 +58,7 @@ public function testExecute() $storeMock->expects($this->once()) ->method('save'); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsite') ->willReturn($websiteMock); @@ -68,15 +71,13 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getStore') ->willReturn($storeMock); + $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; - $categoryMock = $this->getMockBuilder('Magento\Catalog\Model\Category') - ->disableOriginalConstructor() - ->setMethods([ + $categoryMock = $this->getMock( + 'Magento\Catalog\Model\Category', + [ 'setId', - 'setUrlKey', - 'setUrlPath', 'setName', - 'setParentId', 'setPath', 'setLevel', 'setAvailableSortBy', @@ -84,75 +85,65 @@ public function testExecute() 'setIsActive', 'getId', 'save' - ]) - ->getMock(); + ], + [], + '', + false + ); $categoryMock->expects($this->once()) ->method('setId') ->willReturnSelf(); - $categoryMock->expects($this->any()) - ->method('setUrlKey') - ->willReturnSelf(); - $categoryMock->expects($this->any()) - ->method('setUrlPath') - ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->once()) ->method('setName') ->willReturnSelf(); - $categoryMock->expects($this->any()) - ->method('setParentId') - ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->once()) ->method('setPath') ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->once()) ->method('setLevel') ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->once()) ->method('setAvailableSortBy') ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->once()) ->method('setDefaultSortBy') ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->once()) ->method('setIsActive') ->willReturnSelf(); - $categoryMock->expects($this->any()) + $categoryMock->expects($this->once()) ->method('getId') ->willReturn('category_id'); + $valueMap[] = ['Magento\Catalog\Model\Category', [], $categoryMock]; - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->onConsecutiveCalls($storeManagerMock, $categoryMock)); + ->will($this->returnValueMap($valueMap)); $this->fixtureModelMock ->expects($this->exactly(3)) ->method('getValue') - ->will($this->onConsecutiveCalls(1, 1, 1)); + ->will($this->returnValue(1)); $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getObjectManager') ->willReturn($objectManagerMock); - $storesFixture = new StoresFixture($this->fixtureModelMock); - $storesFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $storesFixture = new StoresFixture($this->fixtureModelMock); - $this->assertSame('Generating websites, stores and store views', $storesFixture->getActionTitle()); + $this->assertSame('Generating websites, stores and store views', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $storesFixture = new StoresFixture($this->fixtureModelMock); $this->assertSame([ 'websites' => 'Websites', 'store_groups' => 'Store Groups', 'store_views' => 'Store Views' - ], $storesFixture->introduceParamLabels()); + ], $this->model->introduceParamLabels()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 7093b8c02b3b4..7f557b3fbad48 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -18,40 +18,35 @@ class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase */ private $fixtureModelMock; + /** + * @var \Magento\Setup\Fixtures\TaxRatesFixture + */ + private $model; + public function setUp() { - $this->fixtureModelMock = $this->getMockBuilder('\Magento\Setup\Fixtures\FixtureModel') - ->disableOriginalConstructor() - ->getMock(); + $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + + $this->model = new TaxRatesFixture($this->fixtureModelMock); } public function testExecute() { - $rateMock = $this->getMockBuilder('Magento\Tax\Model\Calculation\Rate') - ->disableOriginalConstructor() - ->setMethods([ - 'setId', - 'delete' - ]) - ->getMock(); + $rateMock = $this->getMock('Magento\Tax\Model\Calculation\Rate', ['setId', 'delete'], [], '', false); + $valueMap[] = ['Magento\Tax\Model\Calculation\Rate', $rateMock]; - $collectionMock = $this->getMockBuilder('Magento\Tax\Model\Resource\Calculation\Rate\Collection') - ->disableOriginalConstructor() - ->getMock(); + $collectionMock = $this->getMock('Magento\Tax\Model\Resource\Calculation\Rate\Collection', [], [], '', false); $collectionMock->expects($this->once()) ->method('getAllIds') ->willReturn([1]); + $valueMap[] = ['Magento\Tax\Model\Resource\Calculation\Rate\Collection', $collectionMock]; - $csvImportHandlerMock = $this->getMockBuilder('Magento\TaxImportExport\Model\Rate\CsvImportHandler') - ->disableOriginalConstructor() - ->getMock(); + $csvImportHandlerMock = $this->getMock('Magento\TaxImportExport\Model\Rate\CsvImportHandler', [], [], '', false); - $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('get') - ->will($this->onConsecutiveCalls($collectionMock, $rateMock)); + ->will($this->returnValueMap($valueMap)); $objectManagerMock->expects($this->once()) ->method('create') ->willReturn($csvImportHandlerMock); @@ -65,19 +60,16 @@ public function testExecute() ->method('getObjectManager') ->willReturn($objectManagerMock); - $taxRatesFixture = new TaxRatesFixture($this->fixtureModelMock); - $taxRatesFixture->execute(); + $this->model->execute(); } public function testGetActionTitle() { - $taxRatesFixture = new TaxRatesFixture($this->fixtureModelMock); - $this->assertSame('Generating tax rates', $taxRatesFixture->getActionTitle()); + $this->assertSame('Generating tax rates', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { - $taxRatesFixture = new TaxRatesFixture($this->fixtureModelMock); - $this->assertSame([], $taxRatesFixture->introduceParamLabels()); + $this->assertSame([], $this->model->introduceParamLabels()); } } From 8f22d9c219191017aff4972169b1dde61f21d81e Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Thu, 11 Jun 2015 14:05:57 -0500 Subject: [PATCH 09/56] MAGETWO-38383: Increase Unit Test Code Coverage - Added an extra test case --- .../Test/Unit/Fixtures/CartPriceRulesFixtureTest.php | 10 ++++++++++ .../Unit/Fixtures/CatalogPriceRulesFixtureTest.php | 10 ++++++++++ .../Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php | 10 ++++++++++ .../Test/Unit/Fixtures/ConfigsApplyFixtureTest.php | 10 ++++++++++ .../Unit/Fixtures/ConfigurableProductsFixtureTest.php | 10 ++++++++++ .../Setup/Test/Unit/Fixtures/CustomersFixtureTest.php | 10 ++++++++++ .../Test/Unit/Fixtures/EavVariationsFixtureTest.php | 10 ++++++++++ .../Unit/Fixtures/IndexersStatesApplyFixtureTest.php | 10 ++++++++++ .../Setup/Test/Unit/Fixtures/OrdersFixtureTest.php | 10 ++++++++++ .../Test/Unit/Fixtures/SimpleProductsFixtureTest.php | 10 ++++++++++ .../Setup/Test/Unit/Fixtures/StoresFixtureTest.php | 10 ++++++++++ .../Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php | 10 ++++++++++ 12 files changed, 120 insertions(+) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index 431ad680ae2aa..fda4061935535 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -101,6 +101,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating shopping cart price rules', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index f5ddca85604d9..eac3b0016c199 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -91,6 +91,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating catalog price rules', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index ca431afe6edc0..c5a0b8ee72457 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -112,6 +112,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating categories', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php index 6a9c3788c93ee..3f30db224c8ac 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php @@ -50,6 +50,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Config Changes', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index 6d1fc16d29525..4dd92b6a112f5 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -103,6 +103,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating configurable products', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php index 29dc845215728..29470069c24ed 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -72,6 +72,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating customers', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php index 72a5423985dad..67359bb1282c4 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -86,6 +86,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $eavVariationsFixture = new EavVariationsFixture($this->fixtureModelMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php index 2b15554348bc9..72a669d30edea 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php @@ -50,6 +50,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Indexers Mode Changes', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index 8dfb98c21136c..572bcd0429a85 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -198,6 +198,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating orders', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index a87d075c373e8..8b18e61cbde0e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -103,6 +103,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating simple products', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php index 75a161ebd6218..cd9538fbc921c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -133,6 +133,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->exactly(3)) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating websites, stores and store views', $this->model->getActionTitle()); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 7f557b3fbad48..3b9aa8eca237f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -63,6 +63,16 @@ public function testExecute() $this->model->execute(); } + public function testExecuteEarlyReturn() + { + $this->fixtureModelMock + ->expects($this->once()) + ->method('getValue') + ->willReturn(false); + + $this->model->execute(); + } + public function testGetActionTitle() { $this->assertSame('Generating tax rates', $this->model->getActionTitle()); From 0e59530eaa6dd7796f1e7b04705124baefcdc233 Mon Sep 17 00:00:00 2001 From: Dmytro Poperechnyy Date: Fri, 12 Jun 2015 14:06:26 +0300 Subject: [PATCH 10/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway - Unit test fixed; --- .../Magento/Sales/Test/Unit/Model/Order/PaymentTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php index 62e3684db0609..cc0929d398099 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -182,14 +182,14 @@ function ($value) { $this->transactionFactory = $this->getMock( 'Magento\Sales\Model\Order\Payment\TransactionFactory', - [], + ['create'], [], '', false ); $this->transactionCollectionFactory = $this->getMock( 'Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory', - [], + ['create'], [], '', false @@ -365,7 +365,7 @@ function ($value) { ->method('getBaseCurrency') ->willReturn($baseCurrencyMock); - $this->assertOrderUpdated(Order::STATE_PAYMENT_REVIEW, Order::STATUS_FRAUD, $message); + $this->assertOrderUpdated(Order::STATE_PROCESSING, Order::STATUS_FRAUD, $message); $this->paymentMethodMock->expects($this->once()) ->method('authorize') From 5436ce34b8e143e68f4504b2467b21e27617407b Mon Sep 17 00:00:00 2001 From: Yuri Kovsher Date: Fri, 12 Jun 2015 15:52:40 +0300 Subject: [PATCH 11/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway --- app/code/Magento/Sales/Model/Order/Payment.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index c70c460a29c38..3c0df8500477e 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -313,12 +313,12 @@ protected function updateOrder(Order $order, $orderState, $orderStatus, $isCusto break; case ($message): case ($originalOrderState && $message): - case ($originalOrderState != $orderState): - case ($originalOrderStatus != $orderStatus): - $order->setState($orderState) - ->setStatus($orderStatus) - ->addStatusHistoryComment($message) - ->setIsCustomerNotified($isCustomerNotified); + if ($originalOrderState != $orderState || $originalOrderStatus != $orderStatus) { + $order->setState($orderState) + ->setStatus($orderStatus) + ->addStatusHistoryComment($message) + ->setIsCustomerNotified($isCustomerNotified); + } break; default: break; @@ -1467,7 +1467,10 @@ protected function _prependMessage($messagePrependTo) { $preparedMessage = $this->getPreparedMessage(); if ($preparedMessage) { - if (is_string($preparedMessage)) { + if ( + is_string($preparedMessage) + || $preparedMessage instanceof \Magento\Framework\Phrase + ) { return $preparedMessage . ' ' . $messagePrependTo; } elseif (is_object( $preparedMessage From 2e87cc783d700ff3c4d2d3ee1115e19ea4bde258 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Fri, 12 Jun 2015 11:17:19 -0500 Subject: [PATCH 12/56] MAGETWO-38383: Increase Unit Test Code Coverage - Added unit test for FixtureModel --- .../Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 3b9aa8eca237f..86b3609d68d68 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -7,8 +7,6 @@ namespace Magento\Setup\Test\Unit\Fixtures; use \Magento\Setup\Fixtures\TaxRatesFixture; -use Magento\Weee\Model\Attribute\Backend\Weee\Tax; -use Test\AAaa\test; class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase { From e1792f5078ec02706054d961af60177d2566922e Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Fri, 12 Jun 2015 19:32:09 +0300 Subject: [PATCH 13/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway --- app/code/Magento/Sales/Model/Order.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) mode change 100644 => 100755 app/code/Magento/Sales/Model/Order.php diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php old mode 100644 new mode 100755 index 4e4bcb681a21e..78ad3e259dd93 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -1067,6 +1067,17 @@ public function cancel() return $this; } + /** + * Is order status in DB "Fraud detected" + * + * @return bool + */ + public function isFraudDetected() + { + return $this->getOrigData(self::STATE) == self::STATE_PAYMENT_REVIEW + && $this->getOrigData(self::STATUS) == self::STATUS_FRAUD; + } + /** * Prepare order totals to cancellation * @@ -1077,7 +1088,7 @@ public function cancel() */ public function registerCancellation($comment = '', $graceful = true) { - if ($this->canCancel() || $this->isPaymentReview()) { + if ($this->canCancel() || $this->isPaymentReview() || $this->isFraudDetected()) { $state = self::STATE_CANCELED; foreach ($this->getAllItems() as $item) { if ($state != self::STATE_PROCESSING && $item->getQtyToRefund()) { From 84f092bf80227d28d418cc964e793d07fcdf95ce Mon Sep 17 00:00:00 2001 From: yuri kovsher Date: Mon, 15 Jun 2015 11:53:46 +0300 Subject: [PATCH 14/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway --- .../Sales/Controller/Adminhtml/Order/ReviewPayment.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php index 83c87cd3c45b4..431b7a5721a7b 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php @@ -34,7 +34,13 @@ public function execute() break; case 'update': $order->getPayment()->update(); - $message = __('The payment update has been made.'); + if ($order->getPayment()->getIsTransactionApproved()) { + $message = __('Transaction has been approved.'); + } else if ($order->getPayment()->getIsTransactionDenied()) { + $message = __('Transaction has been voided/declined.'); + } else { + $message = __('The payment update has been made.'); + } break; default: throw new \Exception(sprintf('Action "%s" is not supported.', $action)); From 86e1e32892014bdeb9f8b1b8c5a48298429353ac Mon Sep 17 00:00:00 2001 From: Dmytro Poperechnyy Date: Mon, 15 Jun 2015 12:01:09 +0300 Subject: [PATCH 15/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway - Added SuppressWarnings CyclomaticComplexity; --- app/code/Magento/Sales/Model/Order.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 78ad3e259dd93..5f78518ad1bd5 100755 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -1085,6 +1085,7 @@ public function isFraudDetected() * @param bool $graceful * @return $this * @throws \Magento\Framework\Exception\LocalizedException + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function registerCancellation($comment = '', $graceful = true) { From cb4de419235a6061ac9ca55b6c3d61a65e20b294 Mon Sep 17 00:00:00 2001 From: yuri kovsher Date: Mon, 15 Jun 2015 12:16:07 +0300 Subject: [PATCH 16/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway --- .../Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php index 431b7a5721a7b..d03e1fcff5270 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php @@ -39,7 +39,7 @@ public function execute() } else if ($order->getPayment()->getIsTransactionDenied()) { $message = __('Transaction has been voided/declined.'); } else { - $message = __('The payment update has been made.'); + $message = __('There is no update for the transaction.'); } break; default: From 9f474a5db5745b714be94e177d1a87e106c24275 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Mon, 15 Jun 2015 15:57:25 +0300 Subject: [PATCH 17/56] MAGETWO-38597: Suspected Fraud order status is displayed on frontend --- app/code/Magento/Sales/Model/Order/Config.php | 35 ++++++++++++++++++- .../Test/Unit/Model/Order/ConfigTest.php | 9 ++++- app/code/Magento/Sales/etc/di.xml | 5 +++ 3 files changed, 47 insertions(+), 2 deletions(-) mode change 100644 => 100755 app/code/Magento/Sales/Model/Order/Config.php mode change 100644 => 100755 app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php mode change 100644 => 100755 app/code/Magento/Sales/etc/di.xml diff --git a/app/code/Magento/Sales/Model/Order/Config.php b/app/code/Magento/Sales/Model/Order/Config.php old mode 100644 new mode 100755 index aa34d1b3d2f80..6f638d146a34e --- a/app/code/Magento/Sales/Model/Order/Config.php +++ b/app/code/Magento/Sales/Model/Order/Config.php @@ -37,18 +37,35 @@ class Config */ protected $orderStatusCollectionFactory; + /** + * @var \Magento\Framework\App\State + */ + protected $state; + + /** + * @var array + */ + protected $maskStatusesMapping = [ + \Magento\Framework\App\Area::AREA_FRONTEND => [ + \Magento\Sales\Model\Order::STATUS_FRAUD => \Magento\Sales\Model\Order::STATE_PROCESSING + ] + ]; + /** * Constructor * * @param \Magento\Sales\Model\Order\StatusFactory $orderStatusFactory * @param \Magento\Sales\Model\Resource\Order\Status\CollectionFactory $orderStatusCollectionFactory + * @param \Magento\Framework\App\State $state */ public function __construct( \Magento\Sales\Model\Order\StatusFactory $orderStatusFactory, - \Magento\Sales\Model\Resource\Order\Status\CollectionFactory $orderStatusCollectionFactory + \Magento\Sales\Model\Resource\Order\Status\CollectionFactory $orderStatusCollectionFactory, + \Magento\Framework\App\State $state ) { $this->orderStatusFactory = $orderStatusFactory; $this->orderStatusCollectionFactory = $orderStatusCollectionFactory; + $this->state = $state; } /** @@ -101,10 +118,26 @@ public function getStateDefaultStatus($state) */ public function getStatusLabel($code) { + $code = $this->maskStatusForArea($this->state->getAreaCode(), $code); $status = $this->orderStatusFactory->create()->load($code); return $status->getStoreLabel(); } + /** + * Mask status for order for specified area + * + * @param string $area + * @param string $code + * @return string + */ + protected function maskStatusForArea($area, $code) + { + if (isset($this->maskStatusesMapping[$area][$code])) { + return $this->maskStatusesMapping[$area][$code]; + } + return $code; + } + /** * State label getter * diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php old mode 100644 new mode 100755 index 19dc8e6fce76f..0cfd5e052ef0e --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php @@ -33,7 +33,14 @@ public function setUp() false, false ); - $this->salesConfig = new Config($orderStatusFactory, $this->orderStatusCollectionFactoryMock); + $this->salesConfig = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) + ->getObject( + 'Magento\Sales\Model\Order\Config', + [ + 'orderStatusFactory' => $orderStatusFactory, + 'orderStatusCollectionFactory' => $this->orderStatusCollectionFactoryMock + ] + ); } public function testGetInvisibleOnFrontStatuses() diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml old mode 100644 new mode 100755 index c0aec4a0857a2..db60995fb8f1a --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -268,4 +268,9 @@ CreditmemoRelationsComposite + + + Magento\Framework\App\State\Proxy + + From 69f6eaf6c9b7ed855da3c378be773c336038e35f Mon Sep 17 00:00:00 2001 From: Dmytro Poperechnyy Date: Mon, 15 Jun 2015 17:07:44 +0300 Subject: [PATCH 18/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway - Unit test updated; --- .../Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php index b2d3cd8159734..eda2169754728 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php @@ -143,17 +143,16 @@ public function testExecuteUpdateAction() $this->orderMock->expects($this->once())->method('load')->with($orderId)->willReturn($this->orderMock); $this->orderMock->expects($this->any())->method('getId')->willReturn($orderId); - $this->orderMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock); + $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock); $this->orderMock->expects($this->once())->method('save')->willReturnSelf(); $this->messageManagerMock->expects($this->once())->method('addSuccess') - ->with('The payment update has been made.'); + ->with('There is no update for the transaction.'); $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); $this->paymentMock->expects($this->once())->method('update'); - $result = $this->reviewPayment->execute(); - $this->assertEquals($this->resultRedirectMock, $result); + $this->assertSame($this->resultRedirectMock, $this->reviewPayment->execute()); } } From df957b541ffc3fd88282e2d7a6336239bcc3cea1 Mon Sep 17 00:00:00 2001 From: Dmytro Poperechnyy Date: Mon, 15 Jun 2015 19:36:44 +0300 Subject: [PATCH 19/56] MAGETWO-32940: Accepting and Voiding Transactions Marked as "Held for Review" by Gateway - Unit test modified; --- .../Controller/Adminhtml/Order/ReviewPaymentTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php index eda2169754728..f81f0878d5955 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php @@ -77,7 +77,7 @@ protected function setUp() $this->paymentMock = $this->getMock( 'Magento\Sales\Model\Order\Payment', - ['update'], + ['update', 'getIsTransactionApproved'], [], '', false @@ -146,12 +146,12 @@ public function testExecuteUpdateAction() $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock); $this->orderMock->expects($this->once())->method('save')->willReturnSelf(); - $this->messageManagerMock->expects($this->once())->method('addSuccess') - ->with('There is no update for the transaction.'); + $this->paymentMock->expects($this->once())->method('update'); + $this->paymentMock->expects($this->any())->method('getIsTransactionApproved')->willReturn(true); - $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); + $this->messageManagerMock->expects($this->once())->method('addSuccess')->with('Transaction has been approved.'); - $this->paymentMock->expects($this->once())->method('update'); + $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); $this->assertSame($this->resultRedirectMock, $this->reviewPayment->execute()); } From e1676358ef9e7265a31fcc84f395d4c0de18c75f Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Fri, 12 Jun 2015 11:17:19 -0500 Subject: [PATCH 20/56] MAGETWO-38383: Increase Unit Test Code Coverage - Added unit test for FixtureModel --- .../Test/Unit/Fixtures/FixtureModelTest.php | 99 +++++++++++++++++++ .../Unit/Fixtures/TaxRatesFixtureTest.php | 2 - 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php new file mode 100644 index 0000000000000..fb155cb6cd20d --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php @@ -0,0 +1,99 @@ +getMock('\Magento\Indexer\Console\Command\IndexerReindexCommand', [], [], '', false); + $fileParserMock = $this->getMock('\Magento\Framework\XML\Parser', [], [], '', false); + + $this->model = new FixtureModel($reindexCommandMock, $fileParserMock); + } + + public function testGetObjectManager() + { + $this->assertInstanceOf('Magento\Framework\ObjectManager\ObjectManager', $this->model->getObjectManager()); + } + + public function testReindex() + { + $outputMock = $this->getMock('\Symfony\Component\Console\Output\OutputInterface', [], [], '', false); + $this->model->reindex($outputMock); + } + + public function testLoadFixtures() + { + // Necessary so that the FixtureModel has an ObjectManager instantiated otherwise this test fails. + $this->model->getObjectManager(); + $this->model->loadFixtures(); + } + + public function testGetParamLabels() + { + $this->assertSame([], $this->model->getParamLabels()); + } + + public function testGetFixtures() + { + $this->assertSame([], $this->model->getFixtures()); + } + + public function testInitObjectManager() + { + $this->assertSame($this->model, $this->model->initObjectManager()); + } + + public function testResetObjectManager() + { + $this->assertSame($this->model, $this->model->resetObjectManager()); + } + + /** + * @expectedException \Exception + */ + public function testLoadConfigException() + { + $this->model->loadConfig('exception.file'); + } + + public function testLoadConfig() + { + $reindexCommandMock = $this->getMock('\Magento\Indexer\Console\Command\IndexerReindexCommand', [], [], '', false); + + $fileParserMock = $this->getMock('\Magento\Framework\XML\Parser', [], [], '', false); + $fileParserMock->expects($this->once()) + ->method('load') + ->willReturnSelf(); + + $this->model = new FixtureModel($reindexCommandMock, $fileParserMock); + $this->model->loadConfig('config.file'); + } + + public function testGetValue() + { + $this->assertSame(null, $this->model->getValue('null_key')); + } +} + +namespace Magento\Setup\Fixtures; + +function is_readable($filename) +{ + if (strpos($filename, 'exception') !== false) { + return false; + } + return true; +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 3b9aa8eca237f..86b3609d68d68 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -7,8 +7,6 @@ namespace Magento\Setup\Test\Unit\Fixtures; use \Magento\Setup\Fixtures\TaxRatesFixture; -use Magento\Weee\Model\Attribute\Backend\Weee\Tax; -use Test\AAaa\test; class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase { From 5b5917cadb32440c6a7edb4f08c8df6405b9be1c Mon Sep 17 00:00:00 2001 From: Yuri Kovsher Date: Tue, 16 Jun 2015 17:52:54 +0300 Subject: [PATCH 21/56] MAGETWO-38815: It's impossible to create credit memo --- app/code/Magento/Sales/Setup/InstallSchema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php index a51b0b23971e7..bad3c309b93be 100644 --- a/app/code/Magento/Sales/Setup/InstallSchema.php +++ b/app/code/Magento/Sales/Setup/InstallSchema.php @@ -1893,7 +1893,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con )->addColumn( 'cc_last_4', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 4, + 100, [], 'Cc Last 4' )->addColumn( From 5af921b80c20297c1d475cd817c024a1b8a644ef Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Tue, 16 Jun 2015 10:23:35 -0500 Subject: [PATCH 22/56] MAGETWO-38383: Increase Unit Test Code Coverage - Edited code style --- .../Unit/Fixtures/CatalogPriceRulesFixtureTest.php | 10 +++++++++- .../Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php | 3 ++- .../Setup/Test/Unit/Fixtures/OrdersFixtureTest.php | 10 +++++++++- .../Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php | 8 +++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index eac3b0016c199..7dd2bbde1da1d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -48,7 +48,15 @@ public function testExecute() ->will($this->returnValue([$websiteMock])); $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); - $abstractDbMock = $this->getMockForAbstractClass('\Magento\Framework\Model\Resource\Db\AbstractDb', [$contextMock], '', true, true, true, ['getAllChildren']); + $abstractDbMock = $this->getMockForAbstractClass( + '\Magento\Framework\Model\Resource\Db\AbstractDb', + [$contextMock], + '', + true, + true, + true, + ['getAllChildren'] + ); $abstractDbMock->expects($this->once()) ->method('getAllChildren') ->will($this->returnValue([1])); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index c5a0b8ee72457..b62472dc171e2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -46,7 +46,8 @@ public function testExecute() ], [], '', - false); + false + ); $categoryMock->expects($this->once()) ->method('getName') ->will($this->returnValue('category_name')); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index 572bcd0429a85..f6b54dd0444c8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -67,7 +67,15 @@ public function testExecute() $this->mockObjects[] = [$mockObjectName, $mockObject]; } - $adapterInterfaceMock = $this->getMockForAbstractClass('\Magento\Framework\DB\Adapter\AdapterInterface', [], '', true, true, true, []); + $adapterInterfaceMock = $this->getMockForAbstractClass( + '\Magento\Framework\DB\Adapter\AdapterInterface', + [], + '', + true, + true, + true, + [] + ); $adapterInterfaceMock->expects($this->exactly(14)) ->method('getTableName') ->willReturn('table_name'); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 86b3609d68d68..3c204de470829 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -39,7 +39,13 @@ public function testExecute() ->willReturn([1]); $valueMap[] = ['Magento\Tax\Model\Resource\Calculation\Rate\Collection', $collectionMock]; - $csvImportHandlerMock = $this->getMock('Magento\TaxImportExport\Model\Rate\CsvImportHandler', [], [], '', false); + $csvImportHandlerMock = $this->getMock( + 'Magento\TaxImportExport\Model\Rate\CsvImportHandler', + [], + [], + '', + false + ); $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) From 0784387a68bd0a53fe80566e6ab41c3f192fba47 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Tue, 16 Jun 2015 10:28:31 -0500 Subject: [PATCH 23/56] MAGETWO-38383: Increase Unit Test Code Coverage - Edited code style --- .../Test/Unit/Fixtures/CartPriceRulesFixtureTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index fda4061935535..4e19456fe7198 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -42,11 +42,6 @@ public function testExecute() ->method('getId') ->will($this->returnValue('website_id')); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); - $storeManagerMock->expects($this->once()) - ->method('getWebsites') - ->will($this->returnValue([$websiteMock])); - $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( '\Magento\Framework\Model\Resource\Db\AbstractDb', @@ -61,6 +56,11 @@ public function testExecute() ->method('getAllChildren') ->will($this->returnValue([1])); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock->expects($this->once()) + ->method('getWebsites') + ->will($this->returnValue([$websiteMock])); + $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') From 855ea82e94796a5480494bba19a3970714d10291 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Tue, 16 Jun 2015 10:52:55 -0500 Subject: [PATCH 24/56] MAGETWO-38383: Increase Unit Test Code Coverage - Edited code style --- .../Test/Unit/Fixtures/FixtureModelTest.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php index fb155cb6cd20d..931832a902996 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php @@ -8,7 +8,8 @@ use \Magento\Setup\Fixtures\FixtureModel; -class FixtureModelTest extends \PHPUnit_Framework_TestCase { +class FixtureModelTest extends \PHPUnit_Framework_TestCase +{ /** * @var \Magento\Setup\Fixtures\FixtureModel @@ -17,7 +18,13 @@ class FixtureModelTest extends \PHPUnit_Framework_TestCase { public function setUp() { - $reindexCommandMock = $this->getMock('\Magento\Indexer\Console\Command\IndexerReindexCommand', [], [], '', false); + $reindexCommandMock = $this->getMock( + '\Magento\Indexer\Console\Command\IndexerReindexCommand', + [], + [], + '', + false + ); $fileParserMock = $this->getMock('\Magento\Framework\XML\Parser', [], [], '', false); $this->model = new FixtureModel($reindexCommandMock, $fileParserMock); @@ -71,7 +78,13 @@ public function testLoadConfigException() public function testLoadConfig() { - $reindexCommandMock = $this->getMock('\Magento\Indexer\Console\Command\IndexerReindexCommand', [], [], '', false); + $reindexCommandMock = $this->getMock( + '\Magento\Indexer\Console\Command\IndexerReindexCommand', + [], + [], + '', + false + ); $fileParserMock = $this->getMock('\Magento\Framework\XML\Parser', [], [], '', false); $fileParserMock->expects($this->once()) From c569d66e9db8bdafcb1e1ca6b7a08eea379de0a4 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Wed, 17 Jun 2015 10:28:43 -0500 Subject: [PATCH 25/56] MAGETWO-38383: Increase Unit Test Code Coverage - Merged valueMap values into one array. --- .../Unit/Fixtures/CartPriceRulesFixtureTest.php | 16 +++++++++++----- .../Fixtures/CatalogPriceRulesFixtureTest.php | 7 +++++-- .../Test/Unit/Fixtures/CategoriesFixtureTest.php | 16 +++++++++++----- .../Fixtures/ConfigurableProductsFixtureTest.php | 15 +++++++++------ .../Test/Unit/Fixtures/CustomersFixtureTest.php | 15 +++++++++------ .../Unit/Fixtures/EavVariationsFixtureTest.php | 11 +++++++---- .../Test/Unit/Fixtures/OrdersFixtureTest.php | 14 +++++++++----- .../Unit/Fixtures/SimpleProductsFixtureTest.php | 15 +++++++++------ .../Test/Unit/Fixtures/StoresFixtureTest.php | 7 +++++-- .../Test/Unit/Fixtures/TaxRatesFixtureTest.php | 7 +++++-- 10 files changed, 80 insertions(+), 43 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index 4e19456fe7198..60dd0d22dd211 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -71,13 +71,16 @@ public function testExecute() $categoryMock->expects($this->once()) ->method('getId') ->will($this->returnValue('category_id')); - $valueMap[] = ['Magento\Catalog\Model\Category', $categoryMock,]; $modelMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); $modelMock->expects($this->once()) ->method('getIdFieldName') ->will($this->returnValue('Field Id Name')); - $valueMap[] = ['Magento\SalesRule\Model\Rule', $modelMock]; + + $objectValueMap = [ + ['Magento\SalesRule\Model\Rule', $modelMock], + ['Magento\Catalog\Model\Category', $categoryMock] + ]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->once()) @@ -85,10 +88,13 @@ public function testExecute() ->will($this->returnValue($storeManagerMock)); $objectManagerMock->expects($this->exactly(2)) ->method('get') - ->will($this->returnValueMap($valueMap)); + ->will($this->returnValueMap($objectValueMap)); + + $valueMap = [ + ['cart_price_rules', 0, 1], + ['cart_price_rules_floor', 3, 3] + ]; - $valueMap[] = ['cart_price_rules', 0, 1]; - $valueMap[] = ['cart_price_rules_floor', 3, 3]; $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index 7dd2bbde1da1d..336fde14d3724 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -71,13 +71,16 @@ public function testExecute() $categoryMock->expects($this->once()) ->method('getId') ->will($this->returnValue('category_id')); - $valueMap[] = ['Magento\Catalog\Model\Category', $categoryMock]; $modelMock = $this->getMock('Magento\CatalogRule\Model\Rule', [], [], '', false); $modelMock->expects($this->once()) ->method('getIdFieldName') ->will($this->returnValue('Field Id Name')); - $valueMap[] = ['Magento\CatalogRule\Model\Rule', $modelMock]; + + $valueMap = [ + ['Magento\CatalogRule\Model\Rule', $modelMock], + ['Magento\Catalog\Model\Category', $categoryMock] + ]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index b62472dc171e2..4b95fa95b8a16 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -81,7 +81,6 @@ public function testExecute() $categoryMock->expects($this->once()) ->method('setIsActive') ->willReturnSelf(); - $valueMap[] = ['Magento\Catalog\Model\Category', [], $categoryMock]; $groupMock = $this->getMock('\Magento\Store\Model\Group', [], [], '', false); $groupMock->expects($this->once()) @@ -92,15 +91,22 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getGroups') ->will($this->returnValue([$groupMock])); - $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; + + $objectValueMock = [ + ['Magento\Store\Model\StoreManager', [], $storeManagerMock], + ['Magento\Catalog\Model\Category', [], $categoryMock] + ]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->returnValueMap($valueMap)); + ->will($this->returnValueMap($objectValueMock)); + + $valueMap = [ + ['categories', 0, 1], + ['categories_nesting_level', 3, 3] + ]; - $valueMap[] = ['categories', 0, 1]; - $valueMap[] = ['categories_nesting_level', 3, 3]; $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index 4dd92b6a112f5..3f13cc59021f6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -30,11 +30,6 @@ public function setUp() public function testExecute() { $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); - $valueMap[] = [ - 'Magento\ImportExport\Model\Import', - ['data' => ['entity' => 'catalog_product', 'behavior' => 'replace']], - $importMock - ]; $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( @@ -81,7 +76,15 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; + + $valueMap = [ + [ + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'catalog_product', 'behavior' => 'replace']], + $importMock + ], + ['Magento\Store\Model\StoreManager', [], $storeManagerMock] + ]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php index 29470069c24ed..6ac4d4cc74721 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -30,11 +30,6 @@ public function setUp() public function testExecute() { $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); - $valueMap[] = [ - 'Magento\ImportExport\Model\Import', - ['data' => ['entity' => 'customer_composite', 'behavior' => 'append']], - $importMock - ]; $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeMock->expects($this->once()) @@ -53,7 +48,15 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; + + $valueMap = [ + [ + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'customer_composite', 'behavior' => 'append']], + $importMock + ], + ['Magento\Store\Model\StoreManager', [], $storeManagerMock] + ]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php index 67359bb1282c4..127983f24af23 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -47,7 +47,6 @@ public function testExecute() $attributeMock->expects($this->once()) ->method('setAttributeGroupId') ->willReturnSelf(); - $valueMap[] = ['Magento\Catalog\Model\Resource\Eav\Attribute', [], $attributeMock]; $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); @@ -55,16 +54,20 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getStores') ->will($this->returnValue([$storeMock])); - $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; $setMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false); $setMock->expects($this->once()) ->method('getDefaultGroupId') ->will($this->returnValue(2)); - $valueMap[] = ['Magento\Eav\Model\Entity\Attribute\Set', $setMock]; $cacheMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); - $valueMap[] = ['Magento\Framework\App\CacheInterface', $cacheMock]; + + $valueMap = [ + ['Magento\Catalog\Model\Resource\Eav\Attribute', [], $attributeMock], + ['Magento\Store\Model\StoreManager', [], $storeManagerMock], + ['Magento\Eav\Model\Entity\Attribute\Set', $setMock], + ['Magento\Framework\App\CacheInterface', $cacheMock] + ]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index f6b54dd0444c8..47d62421e67cd 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -131,7 +131,6 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getStores') ->willReturn([$storeMock]); - $this->mockObjects[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( @@ -160,7 +159,6 @@ public function testExecute() $categoryMock->expects($this->exactly(5)) ->method('load') ->willReturnSelf(); - $this->mockObjects[] = ['Magento\Catalog\Model\Category', $categoryMock]; $productMock = $this->getMock('\Magento\Catalog\Model\Product', ['load', 'getSku', 'getName'], [], '', false); $productMock->expects($this->exactly(2)) @@ -172,8 +170,6 @@ public function testExecute() $productMock->expects($this->exactly(2)) ->method('getName') ->willReturn('product_name'); - $this->mockObjects[] = ['Magento\Catalog\Model\Product', $productMock]; - $this->mockObjects[] = ['Magento\Framework\App\Resource', $resourceMock]; $selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); @@ -184,7 +180,15 @@ public function testExecute() $collectionMock->expects($this->once()) ->method('getAllIds') ->willReturn([1, 1]); - $this->mockObjects[] = ['Magento\Catalog\Model\Resource\Product\Collection', [], $collectionMock]; + + array_push( + $this->mockObjects, + ['Magento\Store\Model\StoreManager', [], $storeManagerMock], + ['Magento\Catalog\Model\Category', $categoryMock], + ['Magento\Catalog\Model\Product', $productMock], + ['Magento\Framework\App\Resource', $resourceMock], + ['Magento\Catalog\Model\Resource\Product\Collection', [], $collectionMock] + ); $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(32)) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index 8b18e61cbde0e..cddc212bb2c75 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -46,14 +46,8 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getWebsites') ->willReturn([$websiteMock]); - $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); - $valueMap[] = [ - 'Magento\ImportExport\Model\Import', - ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']], - $importMock - ]; $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( @@ -83,6 +77,15 @@ public function testExecute() ->method('getName') ->willReturn('category_name'); + $valueMap = [ + [ + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']], + $importMock + ], + ['Magento\Store\Model\StoreManager', [], $storeManagerMock] + ]; + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php index cd9538fbc921c..e234a82524e7e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -71,7 +71,6 @@ public function testExecute() $storeManagerMock->expects($this->once()) ->method('getStore') ->willReturn($storeMock); - $valueMap[] = ['Magento\Store\Model\StoreManager', [], $storeManagerMock]; $categoryMock = $this->getMock( 'Magento\Catalog\Model\Category', @@ -114,7 +113,11 @@ public function testExecute() $categoryMock->expects($this->once()) ->method('getId') ->willReturn('category_id'); - $valueMap[] = ['Magento\Catalog\Model\Category', [], $categoryMock]; + + $valueMap = [ + ['Magento\Store\Model\StoreManager', [], $storeManagerMock], + ['Magento\Catalog\Model\Category', [], $categoryMock] + ]; $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 3c204de470829..f183c4ea34a19 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -31,13 +31,11 @@ public function setUp() public function testExecute() { $rateMock = $this->getMock('Magento\Tax\Model\Calculation\Rate', ['setId', 'delete'], [], '', false); - $valueMap[] = ['Magento\Tax\Model\Calculation\Rate', $rateMock]; $collectionMock = $this->getMock('Magento\Tax\Model\Resource\Calculation\Rate\Collection', [], [], '', false); $collectionMock->expects($this->once()) ->method('getAllIds') ->willReturn([1]); - $valueMap[] = ['Magento\Tax\Model\Resource\Calculation\Rate\Collection', $collectionMock]; $csvImportHandlerMock = $this->getMock( 'Magento\TaxImportExport\Model\Rate\CsvImportHandler', @@ -47,6 +45,11 @@ public function testExecute() false ); + $valueMap = [ + ['Magento\Tax\Model\Calculation\Rate', $rateMock], + ['Magento\Tax\Model\Resource\Calculation\Rate\Collection', $collectionMock] + ]; + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('get') From f11b37ae02a26a536b31e2bc4269a48bef92f537 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 17 Jun 2015 18:29:08 +0300 Subject: [PATCH 26/56] MAGETWO-34858: CMS Page is saved after inserting widget into page content --- app/code/Magento/Widget/Block/Adminhtml/Widget.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Widget/Block/Adminhtml/Widget.php b/app/code/Magento/Widget/Block/Adminhtml/Widget.php index 66cfdbcbcf73d..02616f558f096 100644 --- a/app/code/Magento/Widget/Block/Adminhtml/Widget.php +++ b/app/code/Magento/Widget/Block/Adminhtml/Widget.php @@ -34,6 +34,7 @@ protected function _construct() $this->buttonList->update('save', 'id', 'insert_button'); $this->buttonList->update('save', 'onclick', 'wWidget.insertWidget()'); $this->buttonList->update('save', 'region', 'footer'); + $this->buttonList->update('save', 'data_attribute', []); $this->_formScripts[] = 'require(["mage/adminhtml/wysiwyg/widget"], function(){wWidget = new WysiwygWidget.Widget(' . '"widget_options_form", "select_widget_type", "widget_options", "' . From b56a00a8c89bebf1aa9b19da6f498e367ed84d22 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 17 Jun 2015 18:47:58 +0300 Subject: [PATCH 27/56] MAGETWO-34858: CMS Page is saved after inserting widget into page content --- .../app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml index 21c9773ef8a45..c59eaa0979521 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml @@ -27,7 +27,6 @@ - Bug: MAGETWO-34858 Create page with widget and system variable NewCmsPage%isolation% Main Website/Main Website Store/Default Store View From fb5f16e05a80538cedc6a6da4490ba1f5e7f559c Mon Sep 17 00:00:00 2001 From: Fred Sung Date: Tue, 16 Jun 2015 16:59:56 -0500 Subject: [PATCH 28/56] MAGETWO-38402: Stuck in readiness check when PHP setting checking timeout - Add missing variables to examine readiness check completeness. --- setup/pub/magento/setup/readiness-check.js | 1 + 1 file changed, 1 insertion(+) diff --git a/setup/pub/magento/setup/readiness-check.js b/setup/pub/magento/setup/readiness-check.js index fa6da9344a549..b4aefc1abf0cc 100644 --- a/setup/pub/magento/setup/readiness-check.js +++ b/setup/pub/magento/setup/readiness-check.js @@ -105,6 +105,7 @@ angular.module('readiness-check', []) $scope.isCompleted = function() { return $scope.version.processed + && $scope.settings.processed && $scope.extensions.processed && $scope.permissions.processed; }; From 0a6b86ef75b9c57cc012d8ea83c978b50f6e231d Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Wed, 17 Jun 2015 13:17:31 -0500 Subject: [PATCH 29/56] MAGETWO-38383: Increase Unit Test Code Coverage - Corrected assertions for failing unit tests. --- .../Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php | 2 +- .../Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index 3f13cc59021f6..0a99247b31838 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -80,7 +80,7 @@ public function testExecute() $valueMap = [ [ 'Magento\ImportExport\Model\Import', - ['data' => ['entity' => 'catalog_product', 'behavior' => 'replace']], + ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']], $importMock ], ['Magento\Store\Model\StoreManager', [], $storeManagerMock] diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index cddc212bb2c75..e93da37446403 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -70,10 +70,10 @@ public function testExecute() $categoryMock->expects($this->once()) ->method('getPath') ->willReturn('path/to/category'); - $categoryMock->expects($this->exactly(4)) + $categoryMock->expects($this->exactly(5)) ->method('load') ->willReturnSelf(); - $categoryMock->expects($this->exactly(2)) + $categoryMock->expects($this->exactly(3)) ->method('getName') ->willReturn('category_name'); From 207da596cf69f1107e0e253b538794d046cbddb7 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Wed, 17 Jun 2015 16:56:58 -0500 Subject: [PATCH 30/56] MAGETWO-38383: Increase Unit Test Code Coverage -Added comment to explain why a built-in PHP function was overwritten. --- .../Setup/Test/Unit/Fixtures/FixtureModelTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php index 931832a902996..353dd2bcf06bd 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php @@ -103,6 +103,15 @@ public function testGetValue() namespace Magento\Setup\Fixtures; +/** + * Overriding the built-in PHP function since it cannot be mocked-> + * + * The method is used in FixtureModel. loadConfig in an if statement. By overriding this method we are able to test + * both of the possible cases based on the return value of is_readable. + * + * @param $filename + * @return bool + */ function is_readable($filename) { if (strpos($filename, 'exception') !== false) { From 142878876f0871b4e83b7eb5ba6d101c7f7304ef Mon Sep 17 00:00:00 2001 From: Olga Nakonechna Date: Thu, 18 Jun 2015 18:44:05 +0300 Subject: [PATCH 31/56] MAGETWO-36912: EditableMultiselects are not created on new tax rule page sometimes --- app/code/Magento/Theme/view/adminhtml/requirejs-config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Theme/view/adminhtml/requirejs-config.js b/app/code/Magento/Theme/view/adminhtml/requirejs-config.js index 0cc7098574c9d..43452667827f7 100644 --- a/app/code/Magento/Theme/view/adminhtml/requirejs-config.js +++ b/app/code/Magento/Theme/view/adminhtml/requirejs-config.js @@ -11,6 +11,9 @@ var config = { "extjs/ext-tree-checkbox": [ "extjs/ext-tree", "extjs/defaults" + ], + "jquery/editableMultiselect/js/jquery.editable":[ + "jquery" ] }, "bundles": { From a7f81985dcae93345b0f4db095bf5e4bbdd3a130 Mon Sep 17 00:00:00 2001 From: Olga Nakonechna Date: Thu, 18 Jun 2015 19:07:09 +0300 Subject: [PATCH 32/56] MAGETWO-36912: EditableMultiselects are not created on new tax rule page sometimes --- app/code/Magento/Theme/view/adminhtml/requirejs-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Theme/view/adminhtml/requirejs-config.js b/app/code/Magento/Theme/view/adminhtml/requirejs-config.js index 43452667827f7..81603bc35d901 100644 --- a/app/code/Magento/Theme/view/adminhtml/requirejs-config.js +++ b/app/code/Magento/Theme/view/adminhtml/requirejs-config.js @@ -12,7 +12,7 @@ var config = { "extjs/ext-tree", "extjs/defaults" ], - "jquery/editableMultiselect/js/jquery.editable":[ + "jquery/editableMultiselect/js/jquery.editable": [ "jquery" ] }, From 38484c9f0a7ccb08aeb04ef848e8e4a5de83d845 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Thu, 18 Jun 2015 11:30:22 -0500 Subject: [PATCH 33/56] MAGETWO-38383: Increase Unit Test Code Coverage - Added an extra assertion - Removed test methods that were of no value --- .../Test/Unit/Fixtures/FixtureModelTest.php | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php index 353dd2bcf06bd..95a290f6f5960 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php @@ -41,35 +41,9 @@ public function testReindex() $this->model->reindex($outputMock); } - public function testLoadFixtures() - { - // Necessary so that the FixtureModel has an ObjectManager instantiated otherwise this test fails. - $this->model->getObjectManager(); - $this->model->loadFixtures(); - } - - public function testGetParamLabels() - { - $this->assertSame([], $this->model->getParamLabels()); - } - - public function testGetFixtures() - { - $this->assertSame([], $this->model->getFixtures()); - } - - public function testInitObjectManager() - { - $this->assertSame($this->model, $this->model->initObjectManager()); - } - - public function testResetObjectManager() - { - $this->assertSame($this->model, $this->model->resetObjectManager()); - } - /** * @expectedException \Exception + * @expectedExceptionMessage Profile configuration file `exception.file` is not readable or does not exists. */ public function testLoadConfigException() { From 6dda9790094f01e0c2aa52832679174ff1c5fe85 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Thu, 18 Jun 2015 11:41:52 -0500 Subject: [PATCH 34/56] MAGETWO-38383: Increase Unit Test Code Coverage - Changed method names --- .../Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php | 2 +- .../Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php | 2 +- .../Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php | 2 +- .../Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php | 2 +- .../Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php | 2 +- .../Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php | 2 +- .../Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php | 2 +- .../Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php | 2 +- .../src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php | 2 +- .../Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php | 2 +- .../src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php | 2 +- .../Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index 60dd0d22dd211..a8a129f48cda9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -107,7 +107,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index 336fde14d3724..06e6c9502c59f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -102,7 +102,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index 4b95fa95b8a16..96b1a6f55ec03 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -119,7 +119,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php index 3f30db224c8ac..22bff7a8bd2cd 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php @@ -50,7 +50,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index 0a99247b31838..8a99a88f4b2c8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -106,7 +106,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php index 6ac4d4cc74721..68ba5651304b6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -75,7 +75,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php index 127983f24af23..2854a4d153ec2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -89,7 +89,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php index 72a669d30edea..5e06aaf61d677 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php @@ -50,7 +50,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index 47d62421e67cd..d97e1085e6eed 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -210,7 +210,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index e93da37446403..f26c416848b72 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -106,7 +106,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php index e234a82524e7e..2cec584560505 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -136,7 +136,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->exactly(3)) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index f183c4ea34a19..0e1442dc3785f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -70,7 +70,7 @@ public function testExecute() $this->model->execute(); } - public function testExecuteEarlyReturn() + public function testNoFixtureConfigValue() { $this->fixtureModelMock ->expects($this->once()) From de81b8b25dcef65cdf1b984ca4ef1f390f98e20c Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Fri, 19 Jun 2015 18:50:44 +0300 Subject: [PATCH 35/56] MAGETWO-38732: [GITHUB] Cart is not working because of an incorrect path #1363 --- app/code/Magento/Customer/view/frontend/web/js/customer-data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js index e459e07201fe3..bfb277c067d57 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -8,7 +8,7 @@ define([ 'ko', 'Magento_Customer/js/section-config', 'jquery/jquery-storageapi', - 'jquery/jquery-cookie' + 'jquery/jquery.cookie' ], function ($, _, ko, sectionConfig) { 'use strict'; From 72ec3746d8da12e2fec388da7dac5aa3e312e4e1 Mon Sep 17 00:00:00 2001 From: Fred Sung Date: Mon, 22 Jun 2015 18:42:45 -0500 Subject: [PATCH 36/56] MAGETWO-38402: Stuck in readiness check when PHP setting checking timeout - Add error event handler and timeout value for $http.get() - progress.phtml layout update to display error message when error event has been triggered. --- setup/pub/magento/setup/readiness-check.js | 38 +++- .../setup/readiness-check/progress.phtml | 162 ++++++++++-------- 2 files changed, 123 insertions(+), 77 deletions(-) diff --git a/setup/pub/magento/setup/readiness-check.js b/setup/pub/magento/setup/readiness-check.js index b4aefc1abf0cc..1b421e191b8e2 100644 --- a/setup/pub/magento/setup/readiness-check.js +++ b/setup/pub/magento/setup/readiness-check.js @@ -23,6 +23,13 @@ angular.module('readiness-check', []) $rootScope.checkingInProgress = function() { return $scope.progressCounter > 0; }; + $scope.requestFailedHandler = function(obj) { + obj.processed = true; + obj.isRequestError = true; + $scope.hasErrors = true; + $rootScope.hasErrors = true; + $scope.stopProgress(); + } $scope.completed = false; $scope.hasErrors = false; @@ -30,22 +37,26 @@ angular.module('readiness-check', []) $scope.version = { visible: false, processed: false, - expanded: false + expanded: false, + isRequestError: false }; $scope.settings = { visible: false, processed: false, - expanded: false + expanded: false, + isRequestError: false }; $scope.extensions = { visible: false, processed: false, - expanded: false + expanded: false, + isRequestError: false }; $scope.permissions = { visible: false, processed: false, - expanded: false + expanded: false, + isRequestError: false }; $scope.items = { @@ -60,6 +71,9 @@ angular.module('readiness-check', []) angular.extend($scope.version, data); $scope.updateOnProcessed($scope.version.responseType); $scope.stopProgress(); + }, + fail: function() { + $scope.requestFailedHandler($scope.version); } }, 'php-settings': { @@ -73,6 +87,9 @@ angular.module('readiness-check', []) angular.extend($scope.settings, data); $scope.updateOnProcessed($scope.settings.responseType); $scope.stopProgress(); + }, + fail: function() { + $scope.requestFailedHandler($scope.settings); } }, 'php-extensions': { @@ -86,6 +103,9 @@ angular.module('readiness-check', []) angular.extend($scope.extensions, data); $scope.updateOnProcessed($scope.extensions.responseType); $scope.stopProgress(); + }, + fail: function() { + $scope.requestFailedHandler($scope.extensions); } }, 'file-permissions': { @@ -99,6 +119,9 @@ angular.module('readiness-check', []) angular.extend($scope.permissions, data); $scope.updateOnProcessed($scope.permissions.responseType); $scope.stopProgress(); + }, + fail: function() { + $scope.requestFailedHandler($scope.permissions); } } }; @@ -134,8 +157,11 @@ angular.module('readiness-check', []) }; $scope.query = function(item) { - return $http.get(item.url) - .success(function(data) { item.process(data) }); + return $http.get(item.url, {timeout: 3000}) + .success(function(data) { item.process(data) }) + .error(function(data, status) { + item.fail(); + }); }; $scope.progress = function() { diff --git a/setup/view/magento/setup/readiness-check/progress.phtml b/setup/view/magento/setup/readiness-check/progress.phtml index 38f17626b0349..ae1f6acaa1dd9 100644 --- a/setup/view/magento/setup/readiness-check/progress.phtml +++ b/setup/view/magento/setup/readiness-check/progress.phtml @@ -67,17 +67,22 @@

PHP Version Check

-

- Your PHP version is {{version.data.current}}. The required PHP version is {{version.data.required}}. - - Show detail - Hide detail - -

-

- Download and install PHP version {{version.data.required}} from www.php.net using this PHP Documentation. -

-

If you need more help please call your hosting provider.

+
+

Server failed to respond. Please try again.

+
+
+

+ Your PHP version is {{version.data.current}}. The required PHP version is {{version.data.required}}. + + Show detail + Hide detail + +

+

+ Download and install PHP version {{version.data.required}} from www.php.net using this PHP Documentation. +

+

If you need more help please call your hosting provider.

+
@@ -110,17 +115,22 @@
-

PHP Settings Check

+
+

PHP Settings Check

-
-
-

Need Help?

- PHP Documentation +
+

Server failed to respond. Please try again.

-
-

- {{setting.message}} -

+
+
+

Need Help?

+ PHP Documentation +
+
+

+ {{setting.message}} +

+
@@ -178,32 +188,37 @@

PHP Extensions Check

-

- {{extensions.data.missing.length}} missing PHP extensions. - - Show detail - Hide detail - -

-

- The best way to resolve this is to install the correct missing extensions. The exact fix depends on our server, your host, and other system variables. -
- Our PHP Extension Help can get you started. -

-

- If you need more help, please call your hosting provider. -

-
    -
  • - - - PHP Extension {{name}}. -
  • -
+
+

Server failed to respond. Please try again.

+
+
+

+ {{extensions.data.missing.length}} missing PHP extensions. + + Show detail + Hide detail + +

+

+ The best way to resolve this is to install the correct missing extensions. The exact fix depends on our server, your host, and other system variables. +
+ Our PHP Extension Help can get you started. +

+

+ If you need more help, please call your hosting provider. +

+
    +
  • + + + PHP Extension {{name}}. +
  • +
+
@@ -256,32 +271,37 @@

File Permission Check

-

- {{permissions.data.required.length - permissions.data.current.length}} file permission not met. - - Show detail - Hide detail - -

-

- The best way to resolve this is to allow write permissions for the following Magento directories. The exact fix depends on your server, your host, and other system variables. -
- Our File Permission Help can get you started. -

-

- If you need more help, please call your hosting provider. -

+
+

Server failed to respond. Please try again.

+
+
+

+ {{permissions.data.required.length - permissions.data.current.length}} file permission not met. + + Show detail + Hide detail + +

+

+ The best way to resolve this is to allow write permissions for the following Magento directories. The exact fix depends on your server, your host, and other system variables. +
+ Our File Permission Help can get you started. +

+

+ If you need more help, please call your hosting provider. +

-
    -
  • - - - "{{name}}" writable directory permission. -
  • -
+
    +
  • + + + "{{name}}" writable directory permission. +
  • +
+
From 43fcdf8060b9efa42931005ae03c70b87eb11b9a Mon Sep 17 00:00:00 2001 From: Dmytro Poperechnyy Date: Tue, 23 Jun 2015 12:58:02 +0300 Subject: [PATCH 37/56] MAGETWO-39137: Fix comment in \Magento\Framework\App\Http::launch() method --- lib/internal/Magento/Framework/App/Http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/Http.php b/lib/internal/Magento/Framework/App/Http.php index 755131e2309d3..897985cc0982b 100644 --- a/lib/internal/Magento/Framework/App/Http.php +++ b/lib/internal/Magento/Framework/App/Http.php @@ -113,7 +113,7 @@ public function launch() /** @var \Magento\Framework\App\FrontControllerInterface $frontController */ $frontController = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface'); $result = $frontController->dispatch($this->_request); - // TODO: Temporary solution till all controllers are returned not ResultInterface (MAGETWO-28359) + // TODO: Temporary solution until all controllers return ResultInterface (MAGETWO-28359) if ($result instanceof ResultInterface) { $this->registry->register('use_page_cache_plugin', true, true); $result->renderResult($this->_response); From e5f1a51d5dab2f3f67a49dd1677f8c109244eb36 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Tue, 23 Jun 2015 15:27:04 -0500 Subject: [PATCH 38/56] MAGETWO-38974: Base-url placeholder - Implemented a check for the {{base_url}} placeholder --- .../Setup/Console/Command/InstallStoreConfigurationCommand.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php index 425ed23f6e179..2837e078a3e51 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php @@ -178,6 +178,9 @@ public function validate(InputInterface $input) switch ($key) { case StoreConfigurationDataMapper::KEY_BASE_URL: /** @var Validator $url */ + if (strcmp($value, '{{base_url}}') == 0) { + break; + } $url = $this->objectManager->get('Magento\Framework\Url\Validator'); if (!$url->isValid($value)) { $errorMsgs = $url->getMessages(); From bae9a0738a216360f4c7048b2a970fb54424c093 Mon Sep 17 00:00:00 2001 From: Fred Sung Date: Tue, 23 Jun 2015 17:38:20 -0500 Subject: [PATCH 39/56] MAGETWO-38402: Stuck in readiness check when PHP setting checking timeout - Added missing semicolon. --- setup/pub/magento/setup/readiness-check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/pub/magento/setup/readiness-check.js b/setup/pub/magento/setup/readiness-check.js index 1b421e191b8e2..840fe52343831 100644 --- a/setup/pub/magento/setup/readiness-check.js +++ b/setup/pub/magento/setup/readiness-check.js @@ -29,7 +29,7 @@ angular.module('readiness-check', []) $scope.hasErrors = true; $rootScope.hasErrors = true; $scope.stopProgress(); - } + }; $scope.completed = false; $scope.hasErrors = false; From e2bbf2b01c9f8cf6271d8f37a8a0d204b486be43 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Wed, 24 Jun 2015 18:42:07 +0300 Subject: [PATCH 40/56] MAGETWO-39146: Mark order with status "Suspected Fraud" on specific response from gateway --- app/code/Magento/Sales/Model/Order/Payment.php | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 app/code/Magento/Sales/Model/Order/Payment.php diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php old mode 100644 new mode 100755 index 3c0df8500477e..5253f8feffbb2 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -373,6 +373,9 @@ public function capture($invoice) if (is_null($invoice)) { $invoice = $this->_invoice(); $this->setCreatedInvoice($invoice); + if ($this->getIsFraudDetected()) { + $this->getOrder()->setStatus(Order::STATUS_FRAUD); + } return $this; } $amountToCapture = $this->_formatAmount($invoice->getBaseGrandTotal()); From d1f615b54e77f9d59d74aa7b16a63183b11a29f5 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Thu, 25 Jun 2015 16:29:05 +0300 Subject: [PATCH 41/56] MAGETWO-38757: Admin user redirected to the Orders page after Get Payment Update --- .../Controller/Adminhtml/Order/ReviewPaymentTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) mode change 100644 => 100755 app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php old mode 100644 new mode 100755 index f81f0878d5955..1f53e7b02b597 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php @@ -148,11 +148,15 @@ public function testExecuteUpdateAction() $this->paymentMock->expects($this->once())->method('update'); $this->paymentMock->expects($this->any())->method('getIsTransactionApproved')->willReturn(true); + + $this->messageManagerMock->expects($this->once())->method('addSuccess'); - $this->messageManagerMock->expects($this->once())->method('addSuccess')->with('Transaction has been approved.'); + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with('sales/order/view') + ->willReturnSelf(); - $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); - - $this->assertSame($this->resultRedirectMock, $this->reviewPayment->execute()); + $result = $this->reviewPayment->execute(); + $this->assertEquals($this->resultRedirectMock, $result); } } From 4db1cf95fa923cb1619e582946da705f4f694233 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Thu, 25 Jun 2015 17:02:11 +0300 Subject: [PATCH 42/56] MAGETWO-38757: Admin user redirected to the Orders page after Get Payment Update --- .../Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php | 2 -- app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) mode change 100644 => 100755 app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php index d03e1fcff5270..d2a58add102ff 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php @@ -48,8 +48,6 @@ public function execute() $order->save(); $this->messageManager->addSuccess($message); } - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php old mode 100644 new mode 100755 index cc0929d398099..3448d9dc53d73 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -133,7 +133,8 @@ function ($value) { 'denyPayment', 'fetchTransactionInfo', 'canCapture', - 'canRefund' + 'canRefund', + 'canOrder', ] ) ->getMock(); From 2c667a932129533a7d7fe1e85b03a2c0104d825c Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Fri, 26 Jun 2015 09:20:43 -0500 Subject: [PATCH 43/56] MAGETWO-38383: Increase Unit Test Code Coverage - Added missing parameter type - Changed class variables to local variables - Fixed tests to properly test methods' actions --- .../Fixtures/CartPriceRulesFixtureTest.php | 13 ++++ .../Fixtures/CatalogPriceRulesFixtureTest.php | 13 ++++ .../Unit/Fixtures/CategoriesFixtureTest.php | 13 ++++ .../Unit/Fixtures/ConfigsApplyFixtureTest.php | 12 ++++ .../ConfigurableProductsFixtureTest.php | 14 ++++ .../Unit/Fixtures/CustomersFixtureTest.php | 14 ++++ .../Fixtures/EavVariationsFixtureTest.php | 13 ++++ .../Test/Unit/Fixtures/FixtureModelTest.php | 2 +- .../IndexersStatesApplyFixtureTest.php | 12 ++++ .../Test/Unit/Fixtures/OrdersFixtureTest.php | 72 +++++++++++++------ .../Fixtures/SimpleProductsFixtureTest.php | 14 ++++ .../Test/Unit/Fixtures/StoresFixtureTest.php | 18 +++++ .../Unit/Fixtures/TaxRatesFixtureTest.php | 18 +++++ 13 files changed, 205 insertions(+), 23 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index a8a129f48cda9..54d8046c80dff 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -109,6 +109,19 @@ public function testExecute() public function testNoFixtureConfigValue() { + $ruleMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); + $ruleMock->expects($this->never())->method('save'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('get') + ->with($this->equalTo('Magento\SalesRule\Model\Rule')) + ->willReturn($ruleMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index 06e6c9502c59f..be8a7f156a43c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -104,6 +104,19 @@ public function testExecute() public function testNoFixtureConfigValue() { + $ruleMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); + $ruleMock->expects($this->never())->method('save'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('get') + ->with($this->equalTo('Magento\SalesRule\Model\Rule')) + ->willReturn($ruleMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index 96b1a6f55ec03..30d4bb4e8737c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -121,6 +121,19 @@ public function testExecute() public function testNoFixtureConfigValue() { + $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock->expects($this->never())->method('save'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->with($this->equalTo('Magento\Catalog\Model\Category')) + ->willReturn($categoryMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php index 22bff7a8bd2cd..93d56f2742b64 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php @@ -52,6 +52,18 @@ public function testExecute() public function testNoFixtureConfigValue() { + $configMock = $this->getMock('\Magento\Framework\App\Config\ValueInterface', [], [], '', false); + $configMock->expects($this->never())->method('save'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->willReturn($configMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index 8a99a88f4b2c8..f0cd86010b237 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -108,6 +108,20 @@ public function testExecute() public function testNoFixtureConfigValue() { + $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock->expects($this->never())->method('validateSource'); + $importMock->expects($this->never())->method('importSource'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->with($this->equalTo('Magento\ImportExport\Model\Import')) + ->willReturn($importMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php index 68ba5651304b6..6761be9e0dbd5 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -77,6 +77,20 @@ public function testExecute() public function testNoFixtureConfigValue() { + $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock->expects($this->never())->method('validateSource'); + $importMock->expects($this->never())->method('importSource'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->with($this->equalTo('Magento\ImportExport\Model\Import')) + ->willReturn($importMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php index 2854a4d153ec2..3e8e08002842f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -91,6 +91,19 @@ public function testExecute() public function testNoFixtureConfigValue() { + $attributeMock = $this->getMock('Magento\Catalog\Model\Resource\Eav\Attribute', [], [], '', false); + $attributeMock->expects($this->never())->method('save'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->with($this->equalTo('Magento\Catalog\Model\Resource\Eav\Attribute')) + ->willReturn($attributeMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php index 95a290f6f5960..4ac088271bfad 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php @@ -83,7 +83,7 @@ public function testGetValue() * The method is used in FixtureModel. loadConfig in an if statement. By overriding this method we are able to test * both of the possible cases based on the return value of is_readable. * - * @param $filename + * @param string $filename * @return bool */ function is_readable($filename) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php index 5e06aaf61d677..6d31626bc3733 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php @@ -52,6 +52,18 @@ public function testExecute() public function testNoFixtureConfigValue() { + $cacheInterfaceMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); + $cacheInterfaceMock->expects($this->never())->method('clean'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('get') + ->willReturn($cacheInterfaceMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index d97e1085e6eed..2775d218af70e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -10,23 +10,6 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase { - private $mockObjectNames = [ - 'Magento\Quote\Model\Resource\Quote', - 'Magento\Quote\Model\Resource\Quote\Address', - 'Magento\Quote\Model\Resource\Quote\Item', - 'Magento\Quote\Model\Resource\Quote\Item\Option', - 'Magento\Quote\Model\Resource\Quote\Payment', - 'Magento\Quote\Model\Resource\Quote\Address\Rate', - 'Magento\Reports\Model\Resource\Event', - 'Magento\Sales\Model\Resource\Order', - 'Magento\Sales\Model\Resource\Order\Grid', - 'Magento\Sales\Model\Resource\Order\Item', - 'Magento\Sales\Model\Resource\Order\Payment', - 'Magento\Sales\Model\Resource\Order\Status\History', - '\Magento\Eav\Model\Resource\Entity\Store' - ]; - - private $mockObjects; /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel @@ -51,7 +34,24 @@ public function setUp() */ public function testExecute() { - foreach ($this->mockObjectNames as $mockObjectName) { + $mockObjectNames = [ + 'Magento\Quote\Model\Resource\Quote', + 'Magento\Quote\Model\Resource\Quote\Address', + 'Magento\Quote\Model\Resource\Quote\Item', + 'Magento\Quote\Model\Resource\Quote\Item\Option', + 'Magento\Quote\Model\Resource\Quote\Payment', + 'Magento\Quote\Model\Resource\Quote\Address\Rate', + 'Magento\Reports\Model\Resource\Event', + 'Magento\Sales\Model\Resource\Order', + 'Magento\Sales\Model\Resource\Order\Grid', + 'Magento\Sales\Model\Resource\Order\Item', + 'Magento\Sales\Model\Resource\Order\Payment', + 'Magento\Sales\Model\Resource\Order\Status\History', + '\Magento\Eav\Model\Resource\Entity\Store' + ]; + $mockObjects = []; + + foreach ($mockObjectNames as $mockObjectName) { $mockObject = $this->getMock($mockObjectName, [], [], '', false); $path = explode('\\', $mockObjectName); $name = array_pop($path); @@ -64,7 +64,7 @@ public function testExecute() ->method('getTable') ->willReturn(strtolower($name) . '_table_name'); } - $this->mockObjects[] = [$mockObjectName, $mockObject]; + $mockObjects[] = [$mockObjectName, $mockObject]; } $adapterInterfaceMock = $this->getMockForAbstractClass( @@ -182,7 +182,7 @@ public function testExecute() ->willReturn([1, 1]); array_push( - $this->mockObjects, + $mockObjects, ['Magento\Store\Model\StoreManager', [], $storeManagerMock], ['Magento\Catalog\Model\Category', $categoryMock], ['Magento\Catalog\Model\Product', $productMock], @@ -193,10 +193,10 @@ public function testExecute() $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->exactly(32)) ->method('get') - ->will($this->returnValueMap($this->mockObjects)); + ->will($this->returnValueMap($mockObjects)); $objectManagerMock->expects($this->exactly(2)) ->method('create') - ->will($this->returnValueMap($this->mockObjects)); + ->will($this->returnValueMap($mockObjects)); $this->fixtureModelMock ->expects($this->once()) @@ -212,6 +212,34 @@ public function testExecute() public function testNoFixtureConfigValue() { + $adapterInterfaceMock = $this->getMockForAbstractClass( + '\Magento\Framework\DB\Adapter\AdapterInterface', + [], + '', + true, + true, + true, + [] + ); + $adapterInterfaceMock->expects($this->never()) + ->method('query'); + + $resourceMock = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $resourceMock->expects($this->never()) + ->method('getConnection') + ->with($this->equalTo('write')) + ->willReturn($adapterInterfaceMock); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('get') + ->with($this->equalTo('Magento\Framework\App\Resource')) + ->willReturn($resourceMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManagerMock') + ->willReturn($objectManagerMock); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index f26c416848b72..497a60768893c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -108,6 +108,20 @@ public function testExecute() public function testNoFixtureConfigValue() { + $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock->expects($this->never())->method('validateSource'); + $importMock->expects($this->never())->method('importSource'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->with($this->equalTo('Magento\ImportExport\Model\Import')) + ->willReturn($importMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->will($this->returnValue($objectManagerMock)); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php index 2cec584560505..07cd715489eab 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -138,6 +138,24 @@ public function testExecute() public function testNoFixtureConfigValue() { + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->never())->method('save'); + + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock->expects($this->never()) + ->method('getDefaultStoreView') + ->willReturn($storeMock); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->with($this->equalTo('Magento\Store\Model\StoreManager')) + ->willReturn($storeManagerMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); $this->fixtureModelMock ->expects($this->exactly(3)) ->method('getValue') diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index 0e1442dc3785f..1b7547afbd5e8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -72,6 +72,24 @@ public function testExecute() public function testNoFixtureConfigValue() { + $csvImportHandlerMock = $this->getMock( + 'Magento\TaxImportExport\Model\Rate\CsvImportHandler', + [], + [], + '', + false + ); + $csvImportHandlerMock->expects($this->never())->method('importFromCsvFile'); + + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->never()) + ->method('create') + ->willReturn($csvImportHandlerMock); + + $this->fixtureModelMock + ->expects($this->never()) + ->method('getObjectManager') + ->willReturn($objectManagerMock); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') From b8fda57f4021bb91584fb6f17ab54dfcf51d8db6 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Fri, 26 Jun 2015 09:50:37 -0500 Subject: [PATCH 44/56] MAGETWO-38383: Increase Unit Test Code Coverage -Removed unnecessary is_readable check --- setup/src/Magento/Setup/Fixtures/FixtureModel.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setup/src/Magento/Setup/Fixtures/FixtureModel.php b/setup/src/Magento/Setup/Fixtures/FixtureModel.php index f414e1a2884b3..a51eb57d44e42 100644 --- a/setup/src/Magento/Setup/Fixtures/FixtureModel.php +++ b/setup/src/Magento/Setup/Fixtures/FixtureModel.php @@ -105,11 +105,6 @@ public function reindex(OutputInterface $output) */ public function loadFixtures() { - if (!is_readable(__DIR__)) { - throw new \Exception( - 'Fixtures set directory `' . __DIR__ . '` is not readable or does not exists.' - ); - } $files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN); foreach ($files as $file) { From 832f734c9c8ffbf09298c6a7f2515c715ceccad5 Mon Sep 17 00:00:00 2001 From: Anton Guz Date: Fri, 26 Jun 2015 19:10:08 +0300 Subject: [PATCH 45/56] MAGETWO-38722: Javascript error blocks guest checkout in MLS10S1 When "Enable JavaScript Bundling" is enabled --- .../frontend/layout/checkout_onepage_index.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml index 5db66984f7812..1746781961a42 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml @@ -16,6 +16,9 @@ Magento_Ui/js/form/element/abstract checkoutProvider + + checkoutProvider + ui/form/field ui/form/element/input @@ -60,6 +63,9 @@ Magento_Checkout/js/view/billing-address checkoutProvider + + checkoutProvider + 2 @@ -116,6 +122,9 @@ customerDetails Email + + checkoutProvider + customerDetails.email checkoutProvider 45 @@ -131,6 +140,9 @@ ui/form/element/checkbox Save in address book + + checkoutProvider + checkoutProvider billingAddress.save_in_address_book @@ -147,6 +159,9 @@ Magento_Checkout/js/view/shipping-address + + checkoutProvider + checkoutProvider 3 @@ -209,6 +224,9 @@ ui/form/element/checkbox Save in address book + + checkoutProvider + checkoutProvider shippingAddress.save_in_address_book From 4c4a955d9f0699b60e36ee8c61670215c0e77ced Mon Sep 17 00:00:00 2001 From: Maxim Shikula Date: Wed, 1 Jul 2015 17:33:43 +0300 Subject: [PATCH 46/56] MAGETWO-38793: PR prep and processing: Stories --- .../Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php index 95440ba834dad..1b5c239c17835 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php @@ -47,6 +47,9 @@ public function execute() } $order->save(); $this->messageManager->addSuccess($message); + } else { + $resultRedirect->setPath('sales/*/'); + return $resultRedirect; } } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); From 11e57bb99f4883aa408b803766004e1f45da74c5 Mon Sep 17 00:00:00 2001 From: Olga Nakonechna Date: Wed, 1 Jul 2015 19:04:12 +0300 Subject: [PATCH 47/56] MAGETWO-39138: Tax Rate edit form shows empty selected value instead of * --- app/code/Magento/Tax/Model/Calculation/Rate/Converter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php b/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php index 5fd8da907a5d8..b7dc4920d15cc 100644 --- a/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php +++ b/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php @@ -74,6 +74,10 @@ public function createArrayFromServiceObject( 'zip_is_range' => $returnNumericLogic?0:false, ]; + if ($taxRateFormData['tax_region_id'] === '0') { + $taxRateFormData['tax_region_id'] = ''; + } + if ($taxRate->getZipFrom() && $taxRate->getZipTo()) { $taxRateFormData['zip_is_range'] = $returnNumericLogic?1:true; $taxRateFormData['zip_from'] = $taxRate->getZipFrom(); From a099ff7d1d4f0f5b6f0951ea09884619189dc08f Mon Sep 17 00:00:00 2001 From: Olga Nakonechna Date: Fri, 3 Jul 2015 11:12:54 +0300 Subject: [PATCH 48/56] MAGETWO-38790: Cookie Restriction Mode block is not shown on frontend --- .../Magento/Cookie/View/frontend/templates/html/notices.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cookie/View/frontend/templates/html/notices.phtml b/app/code/Magento/Cookie/View/frontend/templates/html/notices.phtml index ded203df87220..e22d0fa8f092f 100644 --- a/app/code/Magento/Cookie/View/frontend/templates/html/notices.phtml +++ b/app/code/Magento/Cookie/View/frontend/templates/html/notices.phtml @@ -28,7 +28,7 @@ "cookieNotices": { "cookieAllowButtonSelector": "#btn-cookie-allow", "cookieName": "", - "cookieValue": "helper('Magento\Cookie\Helper\Cookie')->getAcceptedSaveCookiesWebsiteIds() ?>", + "cookieValue": helper('Magento\Cookie\Helper\Cookie')->getAcceptedSaveCookiesWebsiteIds() ?>, "cookieLifetime": helper('Magento\Cookie\Helper\Cookie')->getCookieRestrictionLifetime()?>, "noCookiesUrl": "getUrl('cookie/index/noCookies') ?>" } From 5e34290dfa25376841d2a72c136226251105987a Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Fri, 3 Jul 2015 13:43:39 +0300 Subject: [PATCH 49/56] MAGETWO-39684: Gallery missed on Product page for simple product --- lib/web/mage/apply/main.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/web/mage/apply/main.js b/lib/web/mage/apply/main.js index 37a12873c3335..55166b089fd6c 100644 --- a/lib/web/mage/apply/main.js +++ b/lib/web/mage/apply/main.js @@ -67,8 +67,7 @@ define([ .map(getData) .concat(virtuals) .forEach(function (itemContainer) { - var configStack, - element = itemContainer.el; + var element = itemContainer.el; _.each(itemContainer.data, function (obj, key) { if (obj.mixins) { @@ -78,10 +77,10 @@ define([ } delete obj.mixins; - _.each(itemContainer.data, init.bind(null, element)); - }) + init.call(null, element, obj, key); + }); } else { - _.each(itemContainer.data, init.bind(null, element)); + init.call(null, element, obj, key); } } From a3c1a97e619fd7ff0e7e4265bdf6c170f161c1b0 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Fri, 3 Jul 2015 20:49:00 +0300 Subject: [PATCH 50/56] MAGETWO-39669: [IE11] Remove button does not work in mini shopping cart --- .../Checkout/view/frontend/web/js/sidebar.js | 38 +++++++++---------- .../view/frontend/web/js/view/minicart.js | 11 ++++-- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js index 5f93022da11a9..a7242d44933b7 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -24,41 +24,41 @@ define([ }, _initContent: function() { - var self = this; + var self = this, + events = {}; this.element.decorate('list', this.options.isRecursive); - $(this.options.button.close).click(function(event) { + events['click ' + this.options.button.close] = function(event) { event.stopPropagation(); $(self.options.targetElement).dropdownDialog("close"); - }); - - $(this.options.button.checkout).on('click', $.proxy(function() { + }; + events['click ' + this.options.button.checkout] = $.proxy(function() { var cart = customerData.get('cart'), customer = customerData.get('customer'); if (customer() == false && !cart().isGuestCheckoutAllowed) { authenticationPopup.showModal(); + return false; } location.href = this.options.url.checkout; - }, this)); - - $(this.options.button.remove).click(function(event) { + }, this); + events['click ' + this.options.button.remove] = function(event) { event.stopPropagation(); if (confirm(self.options.confirmMessage)) { - self._removeItem($(this)); + self._removeItem($(event.target)); } - }); - - $(this.options.item.qty).keyup(function() { - self._showItemButton($(this)); - }); - $(this.options.item.button).click(function(event) { + }; + events['keyup ' + this.options.item.qty] = function(event) { + self._showItemButton($(event.target)); + }; + events['click ' + this.options.item.button] = function(event) { event.stopPropagation(); - self._updateItemQty($(this)) - }); + self._updateItemQty($(event.target)); + }; + this._on(this.element, events); this._calcHeight(); this._isOverflowed(); }, @@ -122,10 +122,8 @@ define([ * Update content after update qty * * @param elem - * @param response - * @private */ - _updateItemQtyAfter: function(elem, response) { + _updateItemQtyAfter: function(elem) { this._hideItemButton(elem); }, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js index 51e59d8ff6bb3..e1c2e3c57c220 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js @@ -7,21 +7,24 @@ define([ 'Magento_Customer/js/customer-data', 'jquery', 'ko', - 'mage/url' + 'mage/url', + 'sidebar' ], function (Component, customerData, $, ko, url) { 'use strict'; var sidebarInitialized = false; + url.setBaseUrl(window.checkout.baseUrl); function initSidebar() { var minicart = $("[data-block='minicart']"); + minicart.trigger('contentUpdated'); if (sidebarInitialized) { return false; } sidebarInitialized = true; - minicart.mage('sidebar', { + minicart.sidebar({ "targetElement": "div.block.block-minicart", "url": { "checkout": window.checkout.checkoutUrl, @@ -64,12 +67,14 @@ define([ }); }, initSidebar: ko.observable(initSidebar), - closeSidebar: function(element) { + closeSidebar: function() { var minicart = $('[data-block="minicart"]'); + minicart.on('click', '[data-action="close"]', function(event) { event.stopPropagation(); minicart.find('[data-role="dropdownDialog"]').dropdownDialog("close"); }); + return true; }, getItemRenderer: function (productType) { From 085df72e355f3f9bde61964ff0cf49a659b9ddb3 Mon Sep 17 00:00:00 2001 From: yuri kovsher Date: Sat, 4 Jul 2015 15:26:51 +0300 Subject: [PATCH 51/56] MAGETWO-39631: Add Authorize.net payment method --- .../Order/View/Info/FraudDetails.php | 47 + .../Authorizenet/Block/Transparent/Iframe.php | 48 + .../Directpost/Payment/AddConfigured.php | 11 + .../Directpost/Payment/Cancel.php | 11 + .../Payment/ConfigureProductToAdd.php | 11 + .../Payment/ConfigureQuoteItems.php | 11 + .../Authorizenet/Directpost/Payment/Index.php | 11 + .../Directpost/Payment/LoadBlock.php | 11 + .../Authorizenet/Directpost/Payment/Place.php | 150 +++ .../Directpost/Payment/ProcessData.php | 11 + .../Directpost/Payment/Redirect.php | 132 +++ .../Directpost/Payment/Reorder.php | 11 + .../Directpost/Payment/ReturnQuote.php | 41 + .../Authorizenet/Directpost/Payment/Save.php | 11 + .../Directpost/Payment/ShowUpdateResult.php | 11 + .../Authorizenet/Directpost/Payment/Start.php | 11 + .../Controller/Directpost/Payment.php | 151 +++ .../Directpost/Payment/BackendResponse.php | 21 + .../Controller/Directpost/Payment/Place.php | 99 ++ .../Directpost/Payment/Redirect.php | 47 + .../Directpost/Payment/Response.php | 21 + .../Directpost/Payment/ReturnQuote.php | 23 + .../Authorizenet/Helper/Backend/Data.php | 101 ++ app/code/Magento/Authorizenet/Helper/Data.php | 336 +++++++ .../Authorizenet/Helper/DataFactory.php | 54 ++ app/code/Magento/Authorizenet/LICENSE_EE.txt | 437 +++++++++ .../Authorizenet/Model/Authorizenet.php | 512 ++++++++++ app/code/Magento/Authorizenet/Model/Debug.php | 33 + .../Magento/Authorizenet/Model/Directpost.php | 901 ++++++++++++++++++ .../Model/Directpost/Observer.php | 150 +++ .../Authorizenet/Model/Directpost/Request.php | 184 ++++ .../Model/Directpost/Request/Factory.php | 27 + .../Model/Directpost/Response.php | 54 ++ .../Model/Directpost/Response/Factory.php | 27 + .../Authorizenet/Model/Directpost/Session.php | 63 ++ .../Magento/Authorizenet/Model/Request.php | 15 + .../Authorizenet/Model/Request/Factory.php | 51 + .../Authorizenet/Model/Resource/Debug.php | 22 + .../Model/Resource/Debug/Collection.php | 25 + .../Magento/Authorizenet/Model/Response.php | 15 + .../Authorizenet/Model/Response/Factory.php | 51 + .../Authorizenet/Model/Source/Cctype.php | 22 + .../Model/Source/PaymentAction.php | 32 + app/code/Magento/Authorizenet/README.md | 1 + .../Directpost/Payment/RedirectTest.php | 312 ++++++ .../Test/Unit/Helper/Backend/DataTest.php | 138 +++ .../Test/Unit/Helper/DataTest.php | 193 ++++ .../Unit/Model/Directpost/ObserverTest.php | 247 +++++ .../Model/Directpost/Request/FactoryTest.php | 49 + .../Model/Directpost/Response/FactoryTest.php | 49 + .../Unit/Model/Directpost/ResponseTest.php | 130 +++ .../Test/Unit/Model/DirectpostTest.php | 360 +++++++ .../Test/Unit/Model/Request/FactoryTest.php | 49 + .../Test/Unit/Model/Response/FactoryTest.php | 49 + app/code/Magento/Authorizenet/composer.json | 29 + .../Magento/Authorizenet/etc/adminhtml/di.xml | 22 + .../Authorizenet/etc/adminhtml/events.xml | 12 + .../Authorizenet/etc/adminhtml/routes.xml | 14 + .../Authorizenet/etc/adminhtml/system.xml | 92 ++ app/code/Magento/Authorizenet/etc/config.xml | 36 + app/code/Magento/Authorizenet/etc/di.xml | 25 + .../Magento/Authorizenet/etc/frontend/di.xml | 46 + .../Authorizenet/etc/frontend/events.xml | 15 + .../Authorizenet/etc/frontend/page_types.xml | 11 + .../Authorizenet/etc/frontend/routes.xml | 14 + app/code/Magento/Authorizenet/etc/module.xml | 16 + app/code/Magento/Authorizenet/i18n/de_DE.csv | 100 ++ app/code/Magento/Authorizenet/i18n/en_US.csv | 100 ++ app/code/Magento/Authorizenet/i18n/es_ES.csv | 100 ++ app/code/Magento/Authorizenet/i18n/fr_FR.csv | 100 ++ app/code/Magento/Authorizenet/i18n/nl_NL.csv | 100 ++ app/code/Magento/Authorizenet/i18n/pt_BR.csv | 100 ++ app/code/Magento/Authorizenet/i18n/zh_CN.csv | 100 ++ ...thorizenet_directpost_payment_redirect.xml | 12 + .../layout/sales_order_create_index.xml | 17 + ...order_create_load_block_billing_method.xml | 17 + .../adminhtml/layout/sales_order_view.xml | 14 + .../templates/directpost/iframe.phtml | 33 + .../adminhtml/templates/directpost/info.phtml | 119 +++ .../order/view/info/fraud_details.phtml | 44 + .../view/adminhtml/web/js/direct-post.js | 426 +++++++++ ...net_directpost_payment_backendresponse.xml | 12 + ...thorizenet_directpost_payment_redirect.xml | 12 + ...thorizenet_directpost_payment_response.xml | 12 + .../frontend/layout/checkout_index_index.xml | 49 + .../view/frontend/requirejs-config.js | 12 + .../web/js/view/payment/authorizenet.js | 26 + .../authorizenet-directpost.js | 59 ++ .../payment/authorizenet-directpost.html | 70 ++ composer.json | 1 + .../Test/Block/Authorizenet/Form/Cc.php | 18 + .../Test/Block/Authorizenet/Form/Cc.xml | 23 + .../Test/Repository/ConfigData.xml | 63 ++ .../Test/Repository/CreditCard.xml | 18 + .../Test/TestCase/OnePageCheckoutTest.xml | 31 + .../Directpost/Payment/PlaceTest.php | 139 +++ .../Directpost/Payment/PlaceTesting.php | 21 + .../Controller/Directpost/PaymentTest.php | 57 ++ .../Magento/Test/Js/_files/blacklist/core.txt | 1 + .../Magento/Test/Js/_files/whitelist/core.txt | 1 + .../Test/Legacy/_files/obsolete_classes.php | 25 + .../Test/Legacy/_files/obsolete_methods.php | 25 +- 102 files changed, 7978 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php create mode 100644 app/code/Magento/Authorizenet/Block/Transparent/Iframe.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/AddConfigured.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Cancel.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ConfigureProductToAdd.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ConfigureQuoteItems.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Index.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/LoadBlock.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Place.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ProcessData.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Redirect.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Reorder.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ReturnQuote.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Save.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ShowUpdateResult.php create mode 100644 app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Start.php create mode 100644 app/code/Magento/Authorizenet/Controller/Directpost/Payment.php create mode 100644 app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php create mode 100644 app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php create mode 100644 app/code/Magento/Authorizenet/Controller/Directpost/Payment/Redirect.php create mode 100644 app/code/Magento/Authorizenet/Controller/Directpost/Payment/Response.php create mode 100644 app/code/Magento/Authorizenet/Controller/Directpost/Payment/ReturnQuote.php create mode 100644 app/code/Magento/Authorizenet/Helper/Backend/Data.php create mode 100644 app/code/Magento/Authorizenet/Helper/Data.php create mode 100644 app/code/Magento/Authorizenet/Helper/DataFactory.php create mode 100644 app/code/Magento/Authorizenet/LICENSE_EE.txt create mode 100644 app/code/Magento/Authorizenet/Model/Authorizenet.php create mode 100644 app/code/Magento/Authorizenet/Model/Debug.php create mode 100644 app/code/Magento/Authorizenet/Model/Directpost.php create mode 100644 app/code/Magento/Authorizenet/Model/Directpost/Observer.php create mode 100644 app/code/Magento/Authorizenet/Model/Directpost/Request.php create mode 100644 app/code/Magento/Authorizenet/Model/Directpost/Request/Factory.php create mode 100644 app/code/Magento/Authorizenet/Model/Directpost/Response.php create mode 100644 app/code/Magento/Authorizenet/Model/Directpost/Response/Factory.php create mode 100644 app/code/Magento/Authorizenet/Model/Directpost/Session.php create mode 100644 app/code/Magento/Authorizenet/Model/Request.php create mode 100644 app/code/Magento/Authorizenet/Model/Request/Factory.php create mode 100644 app/code/Magento/Authorizenet/Model/Resource/Debug.php create mode 100644 app/code/Magento/Authorizenet/Model/Resource/Debug/Collection.php create mode 100644 app/code/Magento/Authorizenet/Model/Response.php create mode 100644 app/code/Magento/Authorizenet/Model/Response/Factory.php create mode 100644 app/code/Magento/Authorizenet/Model/Source/Cctype.php create mode 100644 app/code/Magento/Authorizenet/Model/Source/PaymentAction.php create mode 100644 app/code/Magento/Authorizenet/README.md create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ObserverTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php create mode 100644 app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php create mode 100644 app/code/Magento/Authorizenet/composer.json create mode 100644 app/code/Magento/Authorizenet/etc/adminhtml/di.xml create mode 100644 app/code/Magento/Authorizenet/etc/adminhtml/events.xml create mode 100644 app/code/Magento/Authorizenet/etc/adminhtml/routes.xml create mode 100644 app/code/Magento/Authorizenet/etc/adminhtml/system.xml create mode 100644 app/code/Magento/Authorizenet/etc/config.xml create mode 100644 app/code/Magento/Authorizenet/etc/di.xml create mode 100644 app/code/Magento/Authorizenet/etc/frontend/di.xml create mode 100644 app/code/Magento/Authorizenet/etc/frontend/events.xml create mode 100644 app/code/Magento/Authorizenet/etc/frontend/page_types.xml create mode 100644 app/code/Magento/Authorizenet/etc/frontend/routes.xml create mode 100644 app/code/Magento/Authorizenet/etc/module.xml create mode 100644 app/code/Magento/Authorizenet/i18n/de_DE.csv create mode 100644 app/code/Magento/Authorizenet/i18n/en_US.csv create mode 100644 app/code/Magento/Authorizenet/i18n/es_ES.csv create mode 100644 app/code/Magento/Authorizenet/i18n/fr_FR.csv create mode 100644 app/code/Magento/Authorizenet/i18n/nl_NL.csv create mode 100644 app/code/Magento/Authorizenet/i18n/pt_BR.csv create mode 100644 app/code/Magento/Authorizenet/i18n/zh_CN.csv create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/layout/adminhtml_authorizenet_directpost_payment_redirect.xml create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_view.xml create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/iframe.phtml create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/templates/order/view/info/fraud_details.phtml create mode 100644 app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js create mode 100644 app/code/Magento/Authorizenet/view/frontend/layout/authorizenet_directpost_payment_backendresponse.xml create mode 100644 app/code/Magento/Authorizenet/view/frontend/layout/authorizenet_directpost_payment_redirect.xml create mode 100644 app/code/Magento/Authorizenet/view/frontend/layout/authorizenet_directpost_payment_response.xml create mode 100644 app/code/Magento/Authorizenet/view/frontend/layout/checkout_index_index.xml create mode 100644 app/code/Magento/Authorizenet/view/frontend/requirejs-config.js create mode 100644 app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/authorizenet.js create mode 100644 app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/method-renderer/authorizenet-directpost.js create mode 100644 app/code/Magento/Authorizenet/view/frontend/web/template/payment/authorizenet-directpost.html create mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Authorizenet/Form/Cc.php create mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Authorizenet/Form/Cc.xml create mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/ConfigData.xml create mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml create mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml create mode 100644 dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTesting.php create mode 100644 dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Directpost/PaymentTest.php diff --git a/app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php b/app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php new file mode 100644 index 0000000000000..e62ac087d0533 --- /dev/null +++ b/app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php @@ -0,0 +1,47 @@ +registry = $registry; + parent::__construct($context, $data); + } + + /** + * @return \Magento\Sales\Model\Order\Payment + */ + public function getPayment() + { + $order = $this->registry->registry('current_order'); + return $order->getPayment(); + } + + /** + * @return string + */ + protected function _toHtml() + { + return ($this->getPayment()->getMethod() === Directpost::METHOD_CODE) ? parent::_toHtml() : ''; + } +} diff --git a/app/code/Magento/Authorizenet/Block/Transparent/Iframe.php b/app/code/Magento/Authorizenet/Block/Transparent/Iframe.php new file mode 100644 index 0000000000000..a98839f5d3912 --- /dev/null +++ b/app/code/Magento/Authorizenet/Block/Transparent/Iframe.php @@ -0,0 +1,48 @@ +dataFactory = $dataFactory; + parent::__construct($context, $registry, $data); + } + + /** + * Get helper data + * + * @param string $area + * @return \Magento\Authorizenet\Helper\Backend\Data|\Magento\Authorizenet\Helper\Data + */ + public function getHelper($area) + { + return $this->dataFactory->create($area); + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/AddConfigured.php b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/AddConfigured.php new file mode 100644 index 0000000000000..a0915a18f0cf7 --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/AddConfigured.php @@ -0,0 +1,11 @@ +helper = $helper; + parent::__construct($context, $productHelper, $escaper, $resultPageFactory, $resultForwardFactory); + } + + /** + * Send request to authorize.net + * + * @return void + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + public function execute() + { + $paymentParam = $this->getRequest()->getParam('payment'); + $controller = $this->getRequest()->getParam('controller'); + $this->getRequest()->setPostValue('collect_shipping_rates', 1); + $this->_processActionData('save'); + + //get confirmation by email flag + $orderData = $this->getRequest()->getPost('order'); + $sendConfirmationFlag = 0; + if ($orderData) { + $sendConfirmationFlag = !empty($orderData['send_confirmation']) ? 1 : 0; + } else { + $orderData = []; + } + + if (isset($paymentParam['method'])) { + $result = []; + //create order partially + $this->_getOrderCreateModel()->setPaymentData($paymentParam); + $this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentParam); + + $orderData['send_confirmation'] = 0; + $this->getRequest()->setPostValue('order', $orderData); + + try { + //do not cancel old order. + $oldOrder = $this->_getOrderCreateModel()->getSession()->getOrder(); + $oldOrder->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_CANCEL, false); + + $order = $this->_getOrderCreateModel()->setIsValidate( + true + )->importPostData( + $this->getRequest()->getPost('order') + )->createOrder(); + + $payment = $order->getPayment(); + if ($payment && $payment->getMethod() == $this->_objectManager->create( + 'Magento\Authorizenet\Model\Directpost' + )->getCode() + ) { + //return json with data. + $session = $this->_objectManager->get('Magento\Authorizenet\Model\Directpost\Session'); + $session->addCheckoutOrderIncrementId($order->getIncrementId()); + $session->setLastOrderIncrementId($order->getIncrementId()); + + /** @var \Magento\Authorizenet\Model\Directpost $method */ + $method = $payment->getMethodInstance(); + $method->setDataHelper($this->helper); + $requestToAuthorizenet = $method->generateRequestFromOrder($order); + $requestToAuthorizenet->setControllerActionName($controller); + $requestToAuthorizenet->setOrderSendConfirmation($sendConfirmationFlag); + $requestToAuthorizenet->setStoreId($this->_getOrderCreateModel()->getQuote()->getStoreId()); + + $adminUrl = $this->_objectManager->get('Magento\Backend\Model\UrlInterface'); + if ($adminUrl->useSecretKey()) { + $requestToAuthorizenet->setKey( + $adminUrl->getSecretKey('adminhtml', 'authorizenet_directpost_payment', 'redirect') + ); + } + $result['directpost'] = ['fields' => $requestToAuthorizenet->getData()]; + } + + $result['success'] = 1; + $isError = false; + } catch (\Magento\Framework\Exception\LocalizedException $e) { + $message = $e->getMessage(); + if (!empty($message)) { + $this->messageManager->addError($message); + } + $isError = true; + } catch (\Exception $e) { + $this->messageManager->addException($e, __('Order saving error: %1', $e->getMessage())); + $isError = true; + } + + if ($isError) { + $result['success'] = 0; + $result['error'] = 1; + $result['redirect'] = $this->_objectManager->get( + 'Magento\Backend\Model\UrlInterface' + )->getUrl( + 'sales/order_create/' + ); + } + + $this->getResponse()->representJson( + $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) + ); + } else { + $result = ['error_messages' => __('Please choose a payment method.')]; + $this->getResponse()->representJson( + $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) + ); + } + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ProcessData.php b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ProcessData.php new file mode 100644 index 0000000000000..25668a9cc3393 --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ProcessData.php @@ -0,0 +1,11 @@ +_coreRegistry = $coreRegistry; + $this->resultLayoutFactory = $resultLayoutFactory; + $this->helper = $helper; + parent::__construct( + $context, + $productHelper, + $escaper, + $resultPageFactory, + $resultForwardFactory + ); + } + + /** + * Return quote + * + * @param bool $cancelOrder + * @param string $errorMsg + * @return void + */ + protected function _returnQuote($cancelOrder, $errorMsg) + { + $directpostSession = $this->_objectManager->get('Magento\Authorizenet\Model\Directpost\Session'); + $incrementId = $directpostSession->getLastOrderIncrementId(); + if ($incrementId && $directpostSession->isCheckoutOrderIncrementIdExist($incrementId)) { + /* @var $order \Magento\Sales\Model\Order */ + $order = $this->_objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($incrementId); + if ($order->getId()) { + $directpostSession->removeCheckoutOrderIncrementId($order->getIncrementId()); + if ($cancelOrder && $order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) { + $order->registerCancellation($errorMsg)->save(); + } + } + } + } + + /** + * Retrieve params and put javascript into iframe + * + * @return \Magento\Framework\View\Result\Layout + */ + public function execute() + { + $redirectParams = $this->getRequest()->getParams(); + $params = []; + if (!empty($redirectParams['success']) + && isset($redirectParams['x_invoice_num']) + && isset($redirectParams['controller_action_name']) + ) { + $params['redirect_parent'] = $this->helper->getSuccessOrderUrl($redirectParams); + $directpostSession = $this->_objectManager->get('Magento\Authorizenet\Model\Directpost\Session'); + $directpostSession->unsetData('quote_id'); + //cancel old order + $oldOrder = $this->_getOrderCreateModel()->getSession()->getOrder(); + if ($oldOrder->getId()) { + /* @var $order \Magento\Sales\Model\Order */ + $order = $this->_objectManager->create('Magento\Sales\Model\Order') + ->loadByIncrementId($redirectParams['x_invoice_num']); + + if ($order->getId()) { + $oldOrder->cancel()->save(); + $order->save(); + $this->_getOrderCreateModel()->getSession()->unsOrderId(); + } + } + //clear sessions + $this->_getSession()->clearStorage(); + $directpostSession->removeCheckoutOrderIncrementId($redirectParams['x_invoice_num']); + $this->_objectManager->get('Magento\Backend\Model\Session')->clearStorage(); + $this->messageManager->addSuccess(__('You created the order.')); + } + + if (!empty($redirectParams['error_msg'])) { + $cancelOrder = empty($redirectParams['x_invoice_num']); + $this->_returnQuote($cancelOrder, $redirectParams['error_msg']); + } + + $this->_coreRegistry->register(Iframe::REGISTRY_KEY, array_merge($params, $redirectParams)); + return $this->resultLayoutFactory->create(); + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Reorder.php b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Reorder.php new file mode 100644 index 0000000000000..4b485b09e257b --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Reorder.php @@ -0,0 +1,11 @@ +_objectManager->get('Magento\Authorizenet\Model\Directpost\Session'); + $incrementId = $directpostSession->getLastOrderIncrementId(); + if ($incrementId && $directpostSession->isCheckoutOrderIncrementIdExist($incrementId)) { + /* @var $order \Magento\Sales\Model\Order */ + $order = $this->_objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($incrementId); + if ($order->getId()) { + $directpostSession->removeCheckoutOrderIncrementId($order->getIncrementId()); + } + } + } + + /** + * Return order quote by ajax + * + * @return void + */ + public function execute() + { + $this->_returnQuote(); + $this->getResponse()->representJson( + $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode(['success' => 1]) + ); + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Save.php b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Save.php new file mode 100644 index 0000000000000..72a332f26b2e3 --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Save.php @@ -0,0 +1,11 @@ + + */ +class Payment extends \Magento\Framework\App\Action\Action +{ + /** + * Core registry + * + * @var \Magento\Framework\Registry + */ + protected $_coreRegistry = null; + + /** + * @var \Magento\Authorizenet\Helper\DataFactory + */ + protected $dataFactory; + + /** + * Constructor + * + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Framework\Registry $coreRegistry + * @param \Magento\Authorizenet\Helper\DataFactory $dataFactory + */ + public function __construct( + \Magento\Framework\App\Action\Context $context, + \Magento\Framework\Registry $coreRegistry, + \Magento\Authorizenet\Helper\DataFactory $dataFactory + ) { + $this->_coreRegistry = $coreRegistry; + $this->dataFactory = $dataFactory; + parent::__construct($context); + } + + /** + * @return \Magento\Checkout\Model\Session + */ + protected function _getCheckout() + { + return $this->_objectManager->get('Magento\Checkout\Model\Session'); + } + + /** + * Get session model + * + * @return \Magento\Authorizenet\Model\Directpost\Session + */ + protected function _getDirectPostSession() + { + return $this->_objectManager->get('Magento\Authorizenet\Model\Directpost\Session'); + } + + /** + * Response action. + * Action for Authorize.net SIM Relay Request. + * + * @param string $area + * @return void + */ + protected function _responseAction($area = 'frontend') + { + $helper = $this->dataFactory->create($area); + + $params = []; + $data = $this->getRequest()->getPostValue(); + /* @var $paymentMethod \Magento\Authorizenet\Model\DirectPost */ + $paymentMethod = $this->_objectManager->create('Magento\Authorizenet\Model\Directpost'); + + $result = []; + if (!empty($data['x_invoice_num'])) { + $result['x_invoice_num'] = $data['x_invoice_num']; + $params['order_success'] = $helper->getSuccessOrderUrl($result); + } + + try { + if (!empty($data['store_id'])) { + $paymentMethod->setStore($data['store_id']); + } + $paymentMethod->process($data); + $result['success'] = 1; + } catch (\Magento\Framework\Exception\LocalizedException $e) { + $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $result['success'] = 0; + $result['error_msg'] = $e->getMessage(); + } catch (\Exception $e) { + $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); + $result['success'] = 0; + $result['error_msg'] = __('We can\'t process your order right now. Please try again later.'); + } + + if (!empty($data['controller_action_name']) + && strpos($data['controller_action_name'], 'sales_order_') === false + ) { + if (!empty($data['key'])) { + $result['key'] = $data['key']; + } + $result['controller_action_name'] = $data['controller_action_name']; + $result['is_secure'] = isset($data['is_secure']) ? $data['is_secure'] : false; + $params['redirect'] = $helper->getRedirectIframeUrl($result); + } + + $this->_coreRegistry->register(Iframe::REGISTRY_KEY, $params); + $this->_view->addPageLayoutHandles(); + $this->_view->loadLayout(false)->renderLayout(); + } + + /** + * Return customer quote + * + * @param bool $cancelOrder + * @param string $errorMsg + * @return void + */ + protected function _returnCustomerQuote($cancelOrder = false, $errorMsg = '') + { + $incrementId = $this->_getDirectPostSession()->getLastOrderIncrementId(); + if ($incrementId && $this->_getDirectPostSession()->isCheckoutOrderIncrementIdExist($incrementId)) { + /* @var $order \Magento\Sales\Model\Order */ + $order = $this->_objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($incrementId); + if ($order->getId()) { + try { + /** @var \Magento\Quote\Model\QuoteRepository $quoteRepository */ + $quoteRepository = $this->_objectManager->create('Magento\Quote\Model\QuoteRepository'); + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $quoteRepository->get($order->getQuoteId()); + + $quote->setIsActive(1)->setReservedOrderId(null); + $quoteRepository->save($quote); + $this->_getCheckout()->replaceQuote($quote); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + } + $this->_getDirectPostSession()->removeCheckoutOrderIncrementId($incrementId); + $this->_getDirectPostSession()->unsetData('quote_id'); + if ($cancelOrder) { + $order->registerCancellation($errorMsg)->save(); + } + } + } + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php new file mode 100644 index 0000000000000..6f0696fbf9d1e --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php @@ -0,0 +1,21 @@ +_responseAction('adminhtml'); + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php new file mode 100644 index 0000000000000..a51be3b1c9122 --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php @@ -0,0 +1,99 @@ +eventManager = $context->getEventManager(); + $this->cartManagement = $cartManagement; + parent::__construct($context, $coreRegistry, $dataFactory); + } + + /** + * Send request to authorize.net + * + * @return string + */ + public function execute() + { + $paymentParam = $this->getRequest()->getParam('payment'); + $controller = $this->getRequest()->getParam('controller'); + if (isset($paymentParam['method'])) { + $this->_getDirectPostSession()->setQuoteId($this->_getCheckout()->getQuote()->getId()); + + if ($controller == \Magento\Payment\Model\IframeConfigProvider::CHECKOUT_IDENTIFIER) { + return $this->placeCheckoutOrder(); + } + + $params = $this->_objectManager->get( + 'Magento\Authorizenet\Helper\Data' + )->getSaveOrderUrlParams( + $controller + ); + $this->_forward( + $params['action'], + $params['controller'], + $params['module'], + $this->getRequest()->getParams() + ); + } else { + $result = ['error_messages' => __('Please choose a payment method.'), 'goto_section' => 'payment']; + $this->getResponse()->representJson( + $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) + ); + } + } + + /** + * Place order for checkout flow + * + * @return string + */ + protected function placeCheckoutOrder() + { + $result = new \Magento\Framework\Object(); + try { + $this->cartManagement->placeOrder($this->_getCheckout()->getQuote()->getId()); + $result->setData('success', true); + $this->eventManager->dispatch( + 'checkout_directpost_placeOrder', + [ + 'result' => $result, + 'action' => $this + ] + ); + } catch (\Exception $exception) { + $result->setData('error', true); + $result->setData('error_messages', __('Cannot place order.')); + } + $this->getResponse()->representJson( + $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) + ); + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Redirect.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Redirect.php new file mode 100644 index 0000000000000..0a0fc1a990668 --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Redirect.php @@ -0,0 +1,47 @@ +dataFactory->create('frontend'); + + $redirectParams = $this->getRequest()->getParams(); + $params = []; + if (!empty($redirectParams['success']) + && isset($redirectParams['x_invoice_num']) + && isset($redirectParams['controller_action_name']) + ) { + $this->_getDirectPostSession()->unsetData('quote_id'); + $params['redirect_parent'] = $helper->getSuccessOrderUrl([]); + } + if (!empty($redirectParams['error_msg'])) { + $cancelOrder = empty($redirectParams['x_invoice_num']); + $this->_returnCustomerQuote($cancelOrder, $redirectParams['error_msg']); + } + + if (isset($redirectParams['controller_action_name']) + && strpos($redirectParams['controller_action_name'], 'sales_order_') !== false + ) { + unset($redirectParams['controller_action_name']); + unset($params['redirect_parent']); + } + + $this->_coreRegistry->register(Iframe::REGISTRY_KEY, array_merge($params, $redirectParams)); + $this->_view->addPageLayoutHandles(); + $this->_view->loadLayout(false)->renderLayout(); + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Response.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Response.php new file mode 100644 index 0000000000000..7a25db11b46f6 --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Response.php @@ -0,0 +1,21 @@ +_responseAction('frontend'); + } +} diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/ReturnQuote.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/ReturnQuote.php new file mode 100644 index 0000000000000..1cef3b032864d --- /dev/null +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/ReturnQuote.php @@ -0,0 +1,23 @@ +_returnCustomerQuote(); + $this->getResponse()->representJson( + $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode(['success' => 1]) + ); + } +} diff --git a/app/code/Magento/Authorizenet/Helper/Backend/Data.php b/app/code/Magento/Authorizenet/Helper/Backend/Data.php new file mode 100644 index 0000000000000..1adfc4a25d95a --- /dev/null +++ b/app/code/Magento/Authorizenet/Helper/Backend/Data.php @@ -0,0 +1,101 @@ +_urlBuilder = $backendUrl; + parent::__construct($context, $storeManager, $orderFactory); + } + + /** + * Return URL for admin area + * + * @param string $route + * @param array $params + * @return string + */ + protected function _getUrl($route, $params = []) + { + return $this->_urlBuilder->getUrl($route, $params); + } + + /** + * Retrieve place order url in admin + * + * @return string + */ + public function getPlaceOrderAdminUrl() + { + return $this->_getUrl('adminhtml/authorizenet_directpost_payment/place', []); + } + + /** + * Retrieve place order url + * + * @param array $params + * @return string + */ + public function getSuccessOrderUrl($params) + { + $param = []; + $route = 'sales/order/view'; + $order = $this->orderFactory->create()->loadByIncrementId($params['x_invoice_num']); + $param['order_id'] = $order->getId(); + return $this->_getUrl($route, $param); + } + + /** + * Retrieve redirect iframe url + * + * @param array $params + * @return string + */ + public function getRedirectIframeUrl($params) + { + return $this->_getUrl('adminhtml/authorizenet_directpost_payment/redirect', $params); + } + + /** + * Get direct post relay url + * + * @param null|int|string $storeId + * @return string + */ + public function getRelayUrl($storeId = null) + { + $defaultStore = $this->storeManager->getDefaultStoreView(); + if (!$defaultStore) { + $allStores = $this->storeManager->getStores(); + if (isset($allStores[0])) { + $defaultStore = $allStores[0]; + } + } + $baseUrl = $defaultStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK); + return $baseUrl . 'authorizenet/directpost_payment/backendResponse'; + } +} diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php new file mode 100644 index 0000000000000..ae9e7b55ffb78 --- /dev/null +++ b/app/code/Magento/Authorizenet/Helper/Data.php @@ -0,0 +1,336 @@ + 'Authorized/Pending Capture', + 'capturedPendingSettlement' => 'Captured/Pending Settlement', + 'refundSettledSuccessfully' => 'Refund/Settled Successfully', + 'refundPendingSettlement' => 'Refund/Pending Settlement', + 'declined' => 'Declined', + 'expired' => 'Expired', + 'voided' => 'Voided', + 'FDSPendingReview' => 'FDS - Pending Review', + 'FDSAuthorizedPendingReview' => 'FDS - Authorized/Pending Review' + ]; + + /** + * Fraud filter actions key to value map + * + * @var array + */ + protected $fdsFilterActions = [ + 'decline ' => 'Decline', + 'hold' => 'Hold', + 'authAndHold' => 'Authorize and Hold', + 'report' => 'Report Only' + ]; + + /** + * @param \Magento\Framework\App\Helper\Context $context + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Sales\Model\OrderFactory $orderFactory + */ + public function __construct( + Context $context, + StoreManagerInterface $storeManager, + OrderFactory $orderFactory + ) { + $this->storeManager = $storeManager; + $this->orderFactory = $orderFactory; + parent::__construct($context); + } + + /** + * Set secure url checkout is secure for current store. + * + * @param string $route + * @param array $params + * @return string + */ + protected function _getUrl($route, $params = []) + { + $params['_type'] = \Magento\Framework\UrlInterface::URL_TYPE_LINK; + if (isset($params['is_secure'])) { + $params['_secure'] = (bool)$params['is_secure']; + } elseif ($this->storeManager->getStore()->isCurrentlySecure()) { + $params['_secure'] = true; + } + return parent::_getUrl($route, $params); + } + + /** + * Retrieve save order url params + * + * @param string $controller + * @return array + */ + public function getSaveOrderUrlParams($controller) + { + $route = []; + switch ($controller) { + case 'onepage': + $route['action'] = 'saveOrder'; + $route['controller'] = 'onepage'; + $route['module'] = 'checkout'; + break; + + case 'sales_order_create': + case 'sales_order_edit': + $route['action'] = 'save'; + $route['controller'] = 'sales_order_create'; + $route['module'] = 'admin'; + break; + + default: + break; + } + + return $route; + } + + /** + * Retrieve redirect iframe url + * + * @param array $params + * @return string + */ + public function getRedirectIframeUrl($params) + { + return $this->_getUrl('authorizenet/directpost_payment/redirect', $params); + } + + /** + * Retrieve place order url + * + * @param array $params + * @return string + */ + public function getSuccessOrderUrl($params) + { + return $this->_getUrl('checkout/onepage/success', $params); + } + + /** + * Update all child and parent order's edit increment numbers. + * Needed for Admin area. + * + * @param \Magento\Sales\Model\Order $order + * @return void + */ + public function updateOrderEditIncrements(\Magento\Sales\Model\Order $order) + { + if ($order->getId() && $order->getOriginalIncrementId()) { + $collection = $order->getCollection(); + $quotedIncrId = $collection->getConnection()->quote($order->getOriginalIncrementId()); + $collection->getSelect()->where( + "original_increment_id = {$quotedIncrId} OR increment_id = {$quotedIncrId}" + ); + + foreach ($collection as $orderToUpdate) { + $orderToUpdate->setEditIncrement($order->getEditIncrement()); + $orderToUpdate->save(); + } + } + } + + /** + * Converts a lot of messages to message + * + * @param array $messages + * @return string + */ + public function convertMessagesToMessage($messages) + { + return implode(' | ', $messages); + } + + /** + * Return message for gateway transaction request + * + * @param \Magento\Payment\Model\InfoInterface $payment + * @param string $requestType + * @param string $lastTransactionId + * @param \Magento\Framework\Object $card + * @param bool|float $amount + * @param bool|string $exception + * @param bool|string $additionalMessage + * @return bool|string + */ + public function getTransactionMessage( + $payment, + $requestType, + $lastTransactionId, + $card, + $amount = false, + $exception = false, + $additionalMessage = false + ) { + $message[] = __('Credit Card: xxxx-%1', $card->getCcLast4()); + if ($amount) { + $message[] = __('amount %1', $this->formatPrice($payment, $amount)); + } + $operation = $this->getOperation($requestType); + if (!$operation) { + return false; + } else { + $message[] = $operation; + } + $message[] = ($exception) ? '- ' . __('failed.') : '- ' . __('successful.'); + if ($lastTransactionId !== null) { + $message[] = __('Authorize.Net Transaction ID %1.', $lastTransactionId); + } + if ($additionalMessage) { + $message[] = $additionalMessage; + } + if ($exception) { + $message[] = $exception; + } + return implode(' ', $message); + } + + /** + * Return operation name for request type + * + * @param string $requestType + * @return \Magento\Framework\Phrase|bool + */ + protected function getOperation($requestType) + { + switch ($requestType) { + case Authorizenet::REQUEST_TYPE_AUTH_ONLY: + return __('authorize'); + case Authorizenet::REQUEST_TYPE_AUTH_CAPTURE: + return __('authorize and capture'); + case Authorizenet::REQUEST_TYPE_PRIOR_AUTH_CAPTURE: + return __('capture'); + case Authorizenet::REQUEST_TYPE_CREDIT: + return __('refund'); + case Authorizenet::REQUEST_TYPE_VOID: + return __('void'); + default: + return false; + } + } + + /** + * Format price with currency sign + * @param \Magento\Payment\Model\InfoInterface $payment + * @param float $amount + * @return string + */ + protected function formatPrice($payment, $amount) + { + return $payment->getOrder()->getBaseCurrency()->formatTxt($amount); + } + + /** + * Get payment method step html + * + * @param \Magento\Framework\App\ViewInterface $view + * @return string + */ + public function getPaymentMethodsHtml(\Magento\Framework\App\ViewInterface $view) + { + $layout = $view->getLayout(); + $update = $layout->getUpdate(); + $update->load('checkout_onepage_paymentmethod'); + $layout->generateXml(); + $layout->generateElements(); + $output = $layout->getOutput(); + return $output; + } + + /** + * Get direct post relay url + * + * @param null|int|string $storeId + * @return string + */ + public function getRelayUrl($storeId = null) + { + $baseUrl = $this->storeManager->getStore($storeId) + ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK); + return $baseUrl . 'authorizenet/directpost_payment/response'; + } + + /** + * Get allowed currencies + * + * @return array + */ + public function getAllowedCurrencyCodes() + { + return $this->allowedCurrencyCodes; + } + + /** + * Get translated filter action label + * + * @param string $key + * @return \Magento\Framework\Phrase|string + */ + public function getFdsFilterActionLabel($key) + { + return isset($this->fdsFilterActions[$key]) ? __($this->fdsFilterActions[$key]) : $key; + } + + /** + * Get translated transaction status label + * + * @param string $key + * @return \Magento\Framework\Phrase|string + */ + public function getTransactionStatusLabel($key) + { + return isset($this->transactionStatuses[$key]) ? __($this->transactionStatuses[$key]) : $key; + } + + /** + * Gateway error response wrapper + * + * @param string $text + * @return \Magento\Framework\Phrase + */ + public function wrapGatewayError($text) + { + return __('Gateway error: %1', $text); + } +} diff --git a/app/code/Magento/Authorizenet/Helper/DataFactory.php b/app/code/Magento/Authorizenet/Helper/DataFactory.php new file mode 100644 index 0000000000000..9e2bb3ef195eb --- /dev/null +++ b/app/code/Magento/Authorizenet/Helper/DataFactory.php @@ -0,0 +1,54 @@ + 'Magento\Authorizenet\Helper\Data', + 'adminhtml' => 'Magento\Authorizenet\Helper\Backend\Data' + ]; + + /** + * Constructor + * + * @param ObjectManagerInterface $objectManager + */ + public function __construct(ObjectManagerInterface $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Create data helper + * + * @param string $area + * @return \Magento\Authorizenet\Helper\Backend\Data|\Magento\Authorizenet\Helper\Data + * @throws LocalizedException + */ + public function create($area) + { + if (!isset($this->helperMap[$area])) { + throw new LocalizedException(__(sprintf('For this area <%s> no suitable helper', $area))); + } + + return $this->objectManager->get($this->helperMap[$area]); + } +} diff --git a/app/code/Magento/Authorizenet/LICENSE_EE.txt b/app/code/Magento/Authorizenet/LICENSE_EE.txt new file mode 100644 index 0000000000000..2bddf5feda6ba --- /dev/null +++ b/app/code/Magento/Authorizenet/LICENSE_EE.txt @@ -0,0 +1,437 @@ +MAGENTO(tm) ENTERPRISE EDITION +END USER LICENSE AGREEMENT + +This End User License Agreement ("Agreement") is entered into by and between X.commerce, Inc. +through its Magento division ("Magento"), and the Licensee executing the Magento Order Form +(defined below). The parties agree as follows: + +TERMS AND CONDITIONS + +1. License + 1.1. Subject to Licensee's payment of the applicable fees and to Licensee's compliance with + other terms and conditions of this Agreement, Magento grants Licensee a non-transferable, + non-assignable, non-sublicensable, worldwide license to copy the Software for the purpose of + installing and using it on a computer and solely for internal purposes, in accordance with the + Software's technical documentation and solely during the periods and on the maximum number + of Designated Servers specified in one or more applicable Magento or Magento-authorized + reseller ordering schedules (the "Magento Order Form") executed with Licensee. + + 1.2. In the event that Licensee's actual number of Servers of a particular Software license + exceeds the licensed number of Designated Servers on such license, Licensee shall promptly + provide Magento with written notice and pay Magento the fees required to license such + additional Server(s) in accordance with the commercial terms set out in the Magento Order + Form. + + 1.3. Licensee shall implement reasonable controls to ensure that it does not exceed the + maximum number of licensed Servers of the Software. Magento reserves the right to audit + Licensee's use of the Software during normal business hours and with reasonable notice and to + include means within the Software to limit Licensee's use of the Software to the licensed + number of Servers. + + 1.4. Magento shall provide to Licensee an initial copy of the Software, including the associated + technical documentation, for use by Licensee in accordance with this Agreement. Subject to + Sections 1.1-1.3 above, Licensee is authorized to make a reasonable number of non-Server + copies of the Software, e.g., onto a local pc, as it requires for purpose of exercising its rights + under this Agreement. + + 1.5. Licensee is authorized to use the Software on a single substitute or backup Server on a + temporary basis without charge any time a Designated Server is inoperative due to a + malfunction beyond the control of Licensee. Licensee may transfer the Software on a + permanent basis to a single replacement Server without charge. Licensee agrees to provide + Magento with written notice, including the Server type and operating system, of any such + transfer to a backup or replacement Server within five (5) days thereafter. + + 1.6. Licensee acknowledges that portions of the Software are also freely available to the public + under Magento's open source version of the Software, known as Magento Community Edition, + subject to certain conditions, with limited warranties and other limited assurances, and without + service or support. As an express condition for the license granted hereunder, Licensee agrees + that any use during the term of this Agreement of such open source versions of the Software, + whether in a Production Server Instance or a Non-Production Server Instance, shall be deemed + use of the Software for purposes of the calculation of fees payable under the Agreement. + + 1.7. Magento also grants Licensee the right to modify and create derivative works of the + Software. Licensee may contribute the rights in any of those derivative works back to Magento. + Licensee may contact Magento for more information regarding contributions of derivative + works rights to Magento. Regardless of whether Licensee contributes such derivative works + rights to Magento, Licensee hereby grants Magento a perpetual and irrevocable (irrespective of + the expiration or termination of this Agreement), nonexclusive, transferable, worldwide, and + royalty-free license to reproduce, create derivative works of, distribute, perform, and display + any derivative works of the Software developed by or for Licensee, and to use, make, have + made, sell, offer to sell, import, export, and otherwise exploit any product based on any such + derivative works. + +2. License Exclusions + 2.1 Except as expressly authorized herein, Licensee shall not: + a. use or deploy the Software on any Server in excess of the number of Designated Servers + specified in the applicable Magento Order Form; + + b. distribute, sublicense, disclose, market, rent, lease, or offer remote computing services, + networking, batch processing or transfer of, the Software to any third party, or permit any + person or entity to have access to the Software by means of a time sharing, remote + computing services, networking, batch processing, service bureau or time sharing + arrangement; + + c. export the Software in violation of U.S. Department of Commerce export administration + regulations. + + 2.2. No license, right or interest in any Magento trademark, trade name or service mark is + granted hereunder. + +3. Fees and Payment Terms + Licensee agrees to the fees and payment terms that are described in each Magento Order Form + executed by Licensee. + +4. Title and Protection + 4.1. Magento (or its third party providers) retains title to all portions of the Software and other + Proprietary Materials and any copies thereof. The Proprietary Materials contain valuable + proprietary information, and Licensee shall not disclose them to anyone other than those of its + employees or consultants under written nondisclosure obligations at least as restrictive as + those contained in this Agreement, having a need to know for purposes consistent with this + Agreement. Licensee shall be responsible for the compliance of such employees or consultants. + Licensee shall affix, to each full or partial copy of the Software made by Licensee, all copyright + and proprietary information notices as were affixed to the original. The obligations set forth in + this Section shall survive termination of this Agreement. + + 4.2. Licensee acknowledges that the Software includes certain open source software which is + governed by the applicable license terms thereof. A list of such open source software, as + amended from time to time, including the links applicable to such open source software is + specified in the product software bundled within the Software, and the Software is subject to + the provisions of such license agreements, and in the event of any contradiction between the + provisions of this Agreement and the provisions of such applicable license agreement, the + provisions of the applicable open source license agreement shall prevail solely with respect to + such open source software products. + + 4.3. If the Software is acquired by or on behalf of a unit or agency of the U.S. Government (the + "Government"), the Government agrees that such Product is "commercial computer software" + or "commercial computer software documentation" and that, absent a written agreement to + the contrary, the Government's rights with respect thereto are limited by the terms of this + Agreement, pursuant to applicable FAR and/or DFARS and successor regulations. + +5. Patent and Copyright Indemnity + Subject to the limitations in Section 8, for such time as Licensee is entitled to receive Support + Services (as defined below), Magento shall indemnify and defend Licensee against any claims made + by a third party that Licensee's reproduction of the Software (which, for the purposes of this Section + 5, means the Software as delivered by Magento, excluding the open source software programs + described in Section 4.2) as permitted in this Agreement directly infringes such third party's United + States patent or copyright, provided that Licensee complies with the requirements of this Section. + Licensee will (a) provide Magento prompt written notice of any claim that the Software infringes any + intellectual property rights, (b) provide Magento with all information and assistance requested of it + with respect to any such claim, and (c) offer Magento sole and complete authority to defend and/or + settle any and all such claims. + + In the event that a court holds that the Software, or if Magento believes a court may hold that the + Software, infringes the intellectual property rights of any third party, Magento may (but is not + obligated to), in its sole discretion, do any of the following: obtain for Licensee the right to continue + using the Software, replace or modify the Software so that it becomes non-infringing while providing + substantially equivalent performance or, accept return of the Software, terminate this Agreement, + and refund Licensee an amount equal to the license fees paid to Magento multiplied by the + percentage of the term of the license for the Software that Licensee did not enjoy due to the early + termination by Magento. + + Magento shall have no liability or obligation under this Agreement to the extent the alleged + infringement is based on (i) a modification or derivative work of the Software developed by anyone + other than Magento; (ii), a combination of the Software with any product or service not provided by + Magento; (ii) use of the Software with one or more Servers not listed in a Magento Order Form; (iii) + use of the Software other than in accordance with this Agreement or the documentation; (iv) + indirect or willful infringement; or (v) any open source code, as described in Section 4.2. + + This Section 5 states Magento's entire liability and Licensee's exclusive remedy for any infringement + related to the Software. + +6. Default and Termination + 6.1. An event of default shall be deemed to occur if: (i) Licensee fails to perform any of its + obligations under the Sections entitled "License Exclusions" or "Title and Protection"; (ii) + Licensee fails to pay amounts due pursuant to its agreement to the fees and payment terms in + Section 3 of this Agreement within seven (7) days of the relevant due date; or (iii) either party + fails to perform any other material obligation under this Agreement and such failure remains + uncured for more than thirty (30) days after receipt of written notice thereof. + + 6.2. If an event of default occurs, the non-defaulting party, in addition to any other rights + available to it under the law, may terminate this Agreement and all licenses granted hereunder + by written notice to the defaulting party. + + 6.3. Within thirty (30) days after termination of the Software license or this Agreement or + expiration of the license term as specified in the Magento Order Form, Licensee shall certify in + writing to Magento that Licensee has ceased use of any and all Proprietary Materials and that + all copies or embodiments thereof in any form, including partial copies within modified + versions, have been destroyed. + +7. Warranty + 7.1. Warranty for Software. Magento warrants for a single period of ninety (90) days + commencing upon Magento's electronic delivery of the Software to Licensee that the Software, + as delivered, will in all material respects perform the functions described in the specifications + contained in the documentation provided with the Software. In the event that the Software + does not, in all material respects, perform the functions therein described, Magento or its + authorized reseller will undertake to correct any reported error in accordance with the Support + Services Terms and Conditions set forth below in Section 9, which shall be Magento's entire + liability and Licensee's exclusive remedy for breach of this warranty. Magento does not warrant + that the Software will meet Licensee's requirements, that the Software will operate in the + combinations which Licensee may select for use, that the operation of the Software will be + uninterrupted or error-free, or that all error conditions will be corrected. EXCEPT AS PROVIDED + IN THIS SECTION ALL SOFTWARE PROVIDED HEREUNDER IS PROVIDED "AS IS". + + 7.2. DISCLAIMER. THE EXPRESS WARRANTIES SET FORTH IN THIS SECTION 7 ARE THE ONLY + WARRANTIES MADE BY MAGENTO WITH RESPECT TO THE SOFTWARE PROVIDED BY MAGENTO. + MAGENTO MAKES NO OTHER WARRANTIES, EXPRESS, IMPLIED OR ARISING BY CUSTOM OR + TRADE USAGE, AND, SPECIFICALLY, MAKES NO WARRANTY OF TITLE, NON-INFRINGEMENT, + ACCURACY, QUIET ENJOYMENT, MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR + PURPOSE. MAGENTO'S EXPRESS WARRANTIES SHALL NOT BE ENLARGED, DIMINISHED OR + AFFECTED BY, AND NO OBLIGATION OR LIABILITY SHALL ARISE OUT OF, MAGENTO RENDERING + TECHNICAL OR OTHER ADVICE OR SERVICE IN CONNECTION WITH THE SOFTWARE. + +8. Limitation of Liability + 8.1. LIABILITY EXCLUSIONS. UNDER NO CIRCUMSTANCES WILL MAGENTO BE LIABLE FOR: LOSS + OF REVENUE; LOSS OF ACTUAL OR ANTICIPATED PROFITS; LOSS OF CONTRACTS; LOSS OF THE + USE OF MONEY; LOSS OF ANTICIPATED SAVINGS; LOSS OF BUSINESS; LOSS OF OPPORTUNITY; + LOSS OF GOODWILL; LOSS OF REPUTATION; LOSS OF, DAMAGE TO OR CORRUPTION OF DATA; + OR CONSEQUENTIAL OR INDIRECT LOSS OR SPECIAL, PUNITIVE, OR INCIDENTAL DAMAGES + (INCLUDING, FOR THE AVOIDANCE OF DOUBT, WHERE SUCH LOSS OR DAMAGE IS ALSO OF A + CATEGORY OF LOSS OR DAMAGE ALREADY LISTED), WHETHER FORESEEABLE OR + UNFORESEEABLE, BASED ON CLAIMS OF LICENSEE, MAGENTO OR ANY THIRD PARTY ARISING + OUT OF ANY BREACH OR FAILURE OF EXPRESS OR IMPLIED WARRANTY CONDITIONS OR OTHER + TERM, BREACH OF CONTRACT, MISREPRESENTATION, NEGLIGENCE, OTHER LIABILITY IN TORT, + FAILURE OF ANY REMEDY TO ACHIEVE ITS ESSENTIAL PURPOSE, OR OTHERWISE. + + 8.2. LIABILITY CAP. NOTWITHSTANDING THE FORM (E.G., CONTRACT, TORT, OR OTHERWISE) IN + WHICH ANY LEGAL OR EQUITABLE ACTION MAY BE BROUGHT, IN NO EVENT (INCLUDING WITH + RESPECT TO OBLIGATIONS ARISING UNDER SECTION 5) WILL MAGENTO OR ITS SUPPLIERS BE + LIABLE FOR DAMAGES, EXPENSES, COSTS, LIABILITIES, SUITS, CLAIMS, RESTITUTION OR LOSSES, + THAT EXCEED, IN THE AGGREGATE, THE AMOUNT OF FEES PAID BY LICENSEE FOR THE + SOFTWARE LICENSE IN THE FIRST TWELVE (12) MONTH PERIOD AFTER THE EFFECTIVE DATE. + +9. Support Services Terms and Conditions + For the periods specified in the Magento Order Form, Magento or its authorized reseller will provide + support services and Updates for the Software as described in Magento's standard Support Services + Terms and Conditions, which follow. Magento will have no obligation to provide support for any + modifications or derivative works of the Software developed by anyone other than Magento. + +10. Customer References + Licensee hereby grants Magento the right to display Licensee's logos as part of Magento's customer + lists and other related marketing materials. The parties shall cooperate to undertake mutually- + agreed joint marketing activities. + +11. Notices + All notices shall be in writing and sent by first class mail or overnight mail (or courier), transmitted by + facsimile (if confirmed by such mailing), or email, to the addresses indicated on the Magento Order + Form, or such other address as either party may indicate by at least ten (10) days prior written + notice to the other party. Notices to Magento shall be sent to the Contracts Administration + Department. + +12. Assignment + Licensee may not assign this Agreement without the prior written consent of Magento; provided + that such consent shall not be required for assignment to a purchaser of all or substantially all of the + assets or equity securities of Licensee who undertakes in writing to be bound by all the terms and + conditions of this Agreement. Any prohibited assignment shall be null and void. + +13. Entire Agreement + Along with Magento's standard Support Services Terms and Conditions, which follow, and the + Magento Order Form, this Agreement is the complete and exclusive agreement between the parties, + which supersedes all proposals or prior agreements, oral or written, including any online (click- + through) agreement which Licensee may have accepted in conjunction with the downloading of the + Software, and all other communications between the parties relating to the subject matter hereof. + No purchase order, other ordering document or any hand written or typewritten text which purports + to modify or supplement the printed text hereof or Magento Order Form shall add to or vary the + terms thereof and Magento hereby rejects same. Except as contained in a writing signed by both + parties, all such proposed variations or additions are objected to and shall have no force or effect. + +14. General + This Agreement is made in and shall be governed by the laws of the State of California, without + giving effect to any principles that provide for the application of the law of another jurisdiction. All + proceedings shall be conducted in English. Venue for all proceedings shall be Santa Clara County, + California, provided that Magento may seek injunctive relief in any court of competent jurisdiction. + The United Nations Convention for the International Sale of Goods shall not apply. The section + headings herein are provided for convenience only and have no substantive effect on the + construction of this Agreement. Except for Licensee's obligation to pay Magento, neither party shall + be liable for any failure to perform due to causes beyond its reasonable control. If any provision of + this Agreement is held to be unenforceable, this Agreement shall be construed without such + provision. The failure by a party to exercise any right hereunder shall not operate as a waiver of such + party's right to exercise such right or any other right in the future. This Agreement may be amended + only by a written document executed by a duly authorized representative of each of the parties. The + parties agree to receive electronic documents and accept electronic signatures (information + attached or logically associated with such document and clicked or otherwise adopted with an intent + to sign) including in counterparts which shall be valid substitutes for paper-based documents and + signatures, and the legal validity of a transaction will not be denied on the ground that it is not in + writing. + +15. Definitions + "Designated Server" shall mean the Server specified in a Magento Order Form with respect to a + particular Software license. Such Server may be that of a third-party under nondisclosure obligations + that will host the Software for the benefit of Licensee. + + "Modifications" means any code developed by Licensee or any third party, including without + limitation, configuration, integrations, implementations, or localizations to the external layer of the + core, baseline Software product. The term "Modifications" excludes Updates. + + "Proprietary Material" means the Software, related documentation, and all parts, copies and + modifications thereof, and any other information, in whatever form, received by Licensee + hereunder, provided, however, such information shall not be deemed Proprietary Material if it (a) is + or becomes a part of the public domain through no act or omission of Licensee; or (b) was in + Licensee's lawful possession prior to the disclosure and had not been obtained by Licensee from + Magento; or (c) is lawfully disclosed to Licensee by a third party without restriction on disclosure; or + (d) is independently developed by Licensee without reference to or use of Magento's Proprietary + Material. + + "Server" means each physical or virtual server from which a single instance of the Software is + accessed and used either for production purposes ("Production Server Instance") or for non- + production purposes, such as development, testing, training and other non-operational business + transactions ("Non-Production Server Instance"). For example, if one server contains two (2) + instances of the Software, i.e., one Production Server Instance and one Non-Production Server + Instance, then a Server license is required for each of such instances; development in-house and by + third-party consultants requires licenses for two Non-Production Server Instances. + + "Software" means Magento's proprietary e-commerce software solution known as the Magento(tm) + Enterprise Edition, provided solely in source code, including associated technical documentation, + and all Updates thereof furnished to Licensee as part of Support Services. Except as otherwise + specified herein, the term Software includes certain open source software programs described in + Section 4.2. "Software" does not include any Modifications. + + "Updates" means all published revisions and corrections to the printed documentation and + corrections and new releases of the Software which are generally made available to Magento's + supported customers at no additional cost or for media and handling charges only. Updates shall not + include any options or future products which Magento sells separately. + + +SUPPORT SERVICES TERMS AND CONDITIONS + +Unless otherwise defined herein, all capitalized terms will have the meanings set forth in the +Agreement. + +1. "Support Services" consists of: + a. Advice regarding the downloading, installation and configuration of the Software (including + Updates provided by Magento, but excluding for the avoidance of doubt any Modifications to + the Software), when used by Licensee on systems that meet the Software's "System + Requirements" specified on Magento's website at www.magentocommerce.com/system- + requirements. + + b. Facilities for bug tracking, escalation of problems for priority attention, and access to + community-supported FAQs and Forums relating to the Software. + + c. Assistance with troubleshooting to diagnose and fix errors in the Software. + + d. Access to Magento documentation relating to the Software, including authorization to make + copies of that documentation for internal use as specified in the Agreement. + +2. Exclusions from Support Services. + Magento shall have no obligation to support (i) versions of the + Software other than the then-current and immediately previous releases, which are operated on a + supported hardware/operating system platform specified in the release notes for the Software; (ii) + altered or modified Software; (iii) Software accessed on unlicensed Servers; (iv) problems caused by + Licensee's negligence, misuse, or hardware malfunction; or (v) use of the Software inconsistent with + Magento's instructions. Magento is not responsible for hardware changes necessitated by changes + to the Software. Support Services does not include: + a. Assistance in the development or debugging of Licensee's system, including the operating + system and support tools. + + b. Information and assistance on technical issues related to the installation, administration, and + use of enabling technologies such as databases, computer networks, and communications. + + c. Assistance with the installation and configuration of hardware including, but not limited to + computers, hard disks, networks, and printers. + +3. Subcontractors. + Magento or its authorized resellers reserve the right to subcontract any or all of + the work to be performed under these Support Terms, and Magento retains responsibility for any + work so subcontracted. + +4. Licensee Responsibilities. + Licensee shall provide commercially reasonable cooperation and full + information to Magento or its authorized resellers with respect to the furnishing of Support Services + under this Agreement. + +5. Support Contacts. + Licensee shall designate one or more support contacts that are authorized to + submit Software problems. If Licensee has purchased the license from a Magento-authorized + reseller, Licensee shall contact that party for assistance. If Licensee has purchased the license + directly from Magento, Licensee may contact Magento on the www.magentocommere.com website + or at its toll-free Support telephone number. + +6. Problem Priority. + Upon receipt of a properly submitted Software problem, as specified on + Magento's website at www.magentocommerce.com, Magento or its authorized reseller shall + prioritize it in accordance with the guidelines below: + + a. Priority 1 (P1) - A P1 is a catastrophic production problem within the Software that severely + impacts the Licensee's Production Server Instance, or because of which Licensee's Production + Server Instance is down or not functioning, or that results in a loss of production data and no + work around exists. P1 problems must be reported on Magento's toll-free support telephone + number in order to expedite resolution. Magento will use continuous efforts during its normal + hours of operation, with appropriate escalation to senior management, to provide a resolution + for any P1 problem as soon as is commercially reasonable. + + b. Priority 2 (P2) - A P2 is a problem within the Software where the Licensee's system is + functioning but in a reduced capacity, or the Problem is causing significant impact to portions of + the Licensee's business operations and productivity, or the Software is exposed to potential loss + or interruption of service. Problems existing in a non-production environment that would + otherwise qualify as a P1 if they were in a production system qualify as P2. Magento will use + reasonable efforts during its normal hours of operation to provide a resolution for any P2 + problem as soon as is commercially reasonable. + + c. Priority 3 (P3) - A P3 is a medium-to-low impact problem that involves partial and/or non- + critical loss of functionality, or that impairs some operations but allows Licensee's operations to + continue to function. Problems for which there is limited or no loss or functionality or impact to + Licensee's operation and for which there is an easy work-around qualify as P3. Magento will use + reasonable efforts during its normal hours of operation to provide a resolution for any P3 + problem in time for the next minor release of the Software. + + d. Priority 4 (P4) - A P4 is for a general usage question or issue that may be cosmetic in nature + or documentation related, but the Software works without normal hours of operation to + provide a resolution for any P4 problem in time for the next major release of the Software. + + e. Enhancement Request (ER) - An ER is a recommendation for future product enhancement or + modification to add official support and documentation for unsupported or undocumented + feature, or features that do not exist in the Software. Magento will take ERs into consideration + in the product management process, but has no obligation to deliver enhancements based on + any ER. + +7. Response Times. + Magento or its authorized reseller shall exercise commercially reasonable efforts + to meet the response times specified below for Gold Support (unless Licensee has upgraded to + Platinum Support, as provided in the Magento Order Form), following receipt of a Software problem + properly submitted by Licensee: + + Magento GOLD Support Response Times + WEB Ticket Submission 24 x 7 x 365 + WEB Ticket Response Time* 24 business hours + North American Telephone Support Hours M-F 08:00 - 17:00 (PT) + European Telephone Support Hours M-F 08:30 - 17:30 (CET) + Telephone Response Time P1 Issues* 4 business hours + Response Time P2-P4 Issues* 24 business hours + *From initial contact + + + Magento PLATINUM Support Response Times + WEB Ticket Submission 24 x 7 x 365 + WEB Ticket Response Time* 24 business hours + Telephone Support Hours 24 hours + Telephone Response Time P1 Issues* Up to 2 hours + Response Time P2-P4 Issues* 4 business hours + *From initial contact + + +8. Prohibited Use. + As a condition of Licensee's use of the Forums, Licensee will not use (and will + prohibit its customers from using) the Forums (i) to violate any applicable law, statute, ordinance or + regulation; (ii) to disseminate content that is harmful, threatening, abusive, harassing, tortuous, + defamatory, vulgar, obscene, libelous, or otherwise objectionable; (iii) to disseminate any software + viruses or any other computer code, files or programs that may interrupt, destroy or limit the + functionality of any computer software or hardware or telecommunications equipment; (iv) to + infringe the intellectual property rights or proprietary rights, or rights of publicity or privacy, of any + third party; or (v) use the Forums for any purpose other than their intended use. + +9. Term and Termination. + Magento will provide Support Services and any Updates to Licensee + during the periods identified in the Magento Order Form, subject to Licensee's payment of the + applicable fees. In the event Licensee fails to pay such fees to Magento or in the event Licensee + materially breaches the Support Services provisions and does not cure such breach within thirty (30) + days of its receipt of Magento's notice of same, Magento may suspend or cancel Support Services. + +10. General. + Magento shall not be liable for any failure or delay in performance under these Support + Terms due to causes beyond its reasonable control. Any illegal or unenforceable provision shall be + severed from these Support Terms. Licensee agrees that any information received pursuant to these + Support Terms shall be deemed to be subject to the non-disclosure obligations set forth in the + License Agreement. Licensee's obligation of payment of moneys due under these Support Terms + shall survive termination of these Support Terms or the License Agreement. These Support Terms + state the entire agreement regarding provision of Support Services to Licensee and may be amended + only by a written amendment set forth on a separate document executed by authorized + representatives of both parties. diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php new file mode 100644 index 0000000000000..a10f6ef75a2fa --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -0,0 +1,512 @@ +dataHelper = $dataHelper; + $this->requestFactory = $requestFactory; + $this->responseFactory = $responseFactory; + + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $paymentData, + $scopeConfig, + $logger, + $moduleList, + $localeDate, + $resource, + $resourceCollection, + $data + ); + } + + /** + * Check method for processing with base currency + * + * @param string $currencyCode + * @return bool + */ + public function canUseForCurrency($currencyCode) + { + if (!in_array($currencyCode, $this->getAcceptedCurrencyCodes())) { + return false; + } + return true; + } + + /** + * Return array of currency codes supplied by Payment Gateway + * + * @return array + */ + public function getAcceptedCurrencyCodes() + { + if (!$this->hasData('_accepted_currency')) { + $acceptedCurrencyCodes = $this->dataHelper->getAllowedCurrencyCodes(); + $acceptedCurrencyCodes[] = $this->getConfigData('currency'); + $this->setData('_accepted_currency', $acceptedCurrencyCodes); + } + return $this->_getData('_accepted_currency'); + } + + /** + * Cancel the payment through gateway + * + * @param \Magento\Payment\Model\InfoInterface $payment + * @return $this + */ + public function cancel(\Magento\Payment\Model\InfoInterface $payment) + { + return $this->void($payment); + } + + /** + * Fetch fraud details + * + * @param string $transactionId + * @return \Magento\Framework\Object + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function fetchTransactionFraudDetails($transactionId) + { + $responseXmlDocument = $this->getTransactionDetails($transactionId); + $response = new \Magento\Framework\Object(); + + if (empty($responseXmlDocument->transaction->FDSFilters->FDSFilter)) { + return $response; + } + + $response->setFdsFilterAction( + $this->dataHelper->getFdsFilterActionLabel((string)$responseXmlDocument->transaction->FDSFilterAction) + ); + $response->setAvsResponse((string)$responseXmlDocument->transaction->AVSResponse); + $response->setCardCodeResponse((string)$responseXmlDocument->transaction->cardCodeResponse); + $response->setCavvResponse((string)$responseXmlDocument->transaction->CAVVResponse); + $response->setFraudFilters($this->getFraudFilters($responseXmlDocument->transaction->FDSFilters)); + + return $response; + } + + /** + * Get fraud filters + * + * @param \Magento\Framework\Simplexml\Element $fraudFilters + * @return array + */ + protected function getFraudFilters($fraudFilters) + { + $result = []; + + foreach ($fraudFilters->FDSFilter as $filer) { + $result[] = [ + 'name' => (string)$filer->name, + 'action' => $this->dataHelper->getFdsFilterActionLabel((string)$filer->action) + ]; + } + + return $result; + } + + /** + * Return authorize payment request + * + * @return \Magento\Authorizenet\Model\Request + */ + protected function getRequest() + { + $request = $this->requestFactory->create() + ->setXVersion(3.1) + ->setXDelimData('True') + ->setXRelayResponse('False') + ->setXTestRequest($this->getConfigData('test') ? 'TRUE' : 'FALSE') + ->setXLogin($this->getConfigData('login')) + ->setXTranKey($this->getConfigData('trans_key')); + return $request; + } + + /** + * Prepare request to gateway + * + * @param \Magento\Framework\Object|\Magento\Payment\Model\InfoInterface $payment + * @return \Magento\Authorizenet\Model\Request + * @link http://www.authorize.net/support/AIM_guide.pdf + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + protected function buildRequest(\Magento\Framework\Object $payment) + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $payment->getOrder(); + $this->setStore($order->getStoreId()); + $request = $this->getRequest() + ->setXType($payment->getAnetTransType()) + ->setXMethod(self::REQUEST_METHOD_CC); + + if ($order && $order->getIncrementId()) { + $request->setXInvoiceNum($order->getIncrementId()); + } + + if ($payment->getAmount()) { + $request->setXAmount($payment->getAmount(), 2); + $request->setXCurrencyCode($order->getBaseCurrencyCode()); + } + + switch ($payment->getAnetTransType()) { + case self::REQUEST_TYPE_AUTH_CAPTURE: + $request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False'); + break; + case self::REQUEST_TYPE_AUTH_ONLY: + $request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False'); + break; + case self::REQUEST_TYPE_CREDIT: + /** + * Send last 4 digits of credit card number to authorize.net + * otherwise it will give an error + */ + $request->setXCardNum($payment->getCcLast4()); + $request->setXTransId($payment->getXTransId()); + break; + case self::REQUEST_TYPE_VOID: + $request->setXTransId($payment->getXTransId()); + break; + case self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE: + $request->setXTransId($payment->getXTransId()); + break; + case self::REQUEST_TYPE_CAPTURE_ONLY: + $request->setXAuthCode($payment->getCcAuthCode()); + break; + } + + if (!empty($order)) { + $billing = $order->getBillingAddress(); + if (!empty($billing)) { + $request->setXFirstName($billing->getFirstname()) + ->setXLastName($billing->getLastname()) + ->setXCompany($billing->getCompany()) + ->setXAddress($billing->getStreetLine(1)) + ->setXCity($billing->getCity()) + ->setXState($billing->getRegion()) + ->setXZip($billing->getPostcode()) + ->setXCountry($billing->getCountry()) + ->setXPhone($billing->getTelephone()) + ->setXFax($billing->getFax()) + ->setXCustId($order->getCustomerId()) + ->setXCustomerIp($order->getRemoteIp()) + ->setXCustomerTaxId($billing->getTaxId()) + ->setXEmail($order->getCustomerEmail()) + ->setXEmailCustomer($this->getConfigData('email_customer')) + ->setXMerchantEmail($this->getConfigData('merchant_email')); + } + + $shipping = $order->getShippingAddress(); + if (!empty($shipping)) { + $request->setXShipToFirstName($shipping->getFirstname()) + ->setXShipToLastName($shipping->getLastname()) + ->setXShipToCompany($shipping->getCompany()) + ->setXShipToAddress($shipping->getStreetLine(1)) + ->setXShipToCity($shipping->getCity()) + ->setXShipToState($shipping->getRegion()) + ->setXShipToZip($shipping->getPostcode()) + ->setXShipToCountry($shipping->getCountry()); + } + + $request->setXPoNum($payment->getPoNumber()) + ->setXTax($order->getBaseTaxAmount()) + ->setXFreight($order->getBaseShippingAmount()); + } + + if ($payment->getCcNumber()) { + $request->setXCardNum($payment->getCcNumber()) + ->setXExpDate(sprintf('%02d-%04d', $payment->getCcExpMonth(), $payment->getCcExpYear())) + ->setXCardCode($payment->getCcCid()); + } + + return $request; + } + + /** + * Post request to gateway and return response + * + * @param \Magento\Authorizenet\Model\Request $request + * @return \Magento\Authorizenet\Model\Response + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function postRequest(\Magento\Authorizenet\Model\Request $request) + { + $debugData = ['request' => $request->getData()]; + $result = $this->responseFactory->create(); + $client = new \Magento\Framework\HTTP\ZendClient(); + $uri = $this->getConfigData('cgi_url'); + $client->setUri($uri ? $uri : self::CGI_URL); + $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); + + foreach ($request->getData() as $key => $value) { + $request->setData($key, str_replace(self::RESPONSE_DELIM_CHAR, '', $value)); + } + + $request->setXDelimChar(self::RESPONSE_DELIM_CHAR); + $client->setParameterPost($request->getData()); + $client->setMethod(\Zend_Http_Client::POST); + + try { + $response = $client->request(); + } catch (\Exception $e) { + $result->setXResponseCode(-1) + ->setXResponseReasonCode($e->getCode()) + ->setXResponseReasonText($e->getMessage()); + + $debugData['result'] = $result->getData(); + $this->_debug($debugData); + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($e->getMessage()) + ); + } + + $responseBody = $response->getBody(); + $r = explode(self::RESPONSE_DELIM_CHAR, $responseBody); + + if ($r) { + $result->setXResponseCode((int)str_replace('"', '', $r[0])) + ->setXResponseReasonCode((int)str_replace('"', '', $r[2])) + ->setXResponseReasonText($r[3]) + ->setXAvsCode($r[5]) + ->setXTransId($r[6]) + ->setXInvoiceNum($r[7]) + ->setXAmount($r[9]) + ->setXMethod($r[10]) + ->setXType($r[11]) + ->setData('x_MD5_Hash', $r[37]) + ->setXAccountNumber($r[50]); + } else { + throw new \Magento\Framework\Exception\LocalizedException( + __('Something went wrong in the payment gateway.') + ); + } + + $debugData['result'] = $result->getData(); + $this->_debug($debugData); + + return $result; + } + + /** + * If gateway actions are locked return true + * + * @param \Magento\Payment\Model\InfoInterface $payment + * @return bool + */ + protected function isGatewayActionsLocked($payment) + { + return $payment->getAdditionalInformation(self::GATEWAY_ACTIONS_LOCKED_STATE_KEY); + } + + /** + * This function returns full transaction details for a specified transaction ID. + * + * @param string $transactionId + * @return \Magento\Framework\Object + * @throws \Magento\Framework\Exception\LocalizedException + * @link http://www.authorize.net/support/ReportingGuide_XML.pdf + * @link http://developer.authorize.net/api/transaction_details/ + */ + protected function getTransactionResponse($transactionId) + { + $responseXmlDocument = $this->getTransactionDetails($transactionId); + + $response = new \Magento\Framework\Object(); + $response->setXResponseCode((string)$responseXmlDocument->transaction->responseCode) + ->setXResponseReasonCode((string)$responseXmlDocument->transaction->responseReasonCode) + ->setTransactionStatus((string)$responseXmlDocument->transaction->transactionStatus); + + return $response; + } + + /** + * Load transaction details + * + * @param string $transactionId + * @return \Magento\Framework\Simplexml\Element + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function loadTransactionDetails($transactionId) + { + $requestBody = sprintf( + '' . + '' . + '%s%s' . + '%s' . + '', + $this->getConfigData('login'), + $this->getConfigData('trans_key'), + $transactionId + ); + + $client = new \Magento\Framework\HTTP\ZendClient(); + $uri = $this->getConfigData('cgi_url_td'); + $client->setUri($uri ? $uri : self::CGI_URL_TD); + $client->setConfig(['timeout' => 45]); + $client->setHeaders(['Content-Type: text/xml']); + $client->setMethod(\Zend_Http_Client::POST); + $client->setRawData($requestBody); + + $debugData = ['request' => $requestBody]; + + try { + $responseBody = $client->request()->getBody(); + $debugData['result'] = $responseBody; + $this->_debug($debugData); + libxml_use_internal_errors(true); + $responseXmlDocument = new \Magento\Framework\Simplexml\Element($responseBody); + libxml_use_internal_errors(false); + } catch (\Exception $e) { + throw new \Magento\Framework\Exception\LocalizedException(__('Payment updating error.')); + } + + $this->transactionDetails[$transactionId] = $responseXmlDocument; + return $responseXmlDocument; + } + + /** + * Get transaction information + * + * @param string $transactionId + * @return \Magento\Framework\Simplexml\Element + */ + protected function getTransactionDetails($transactionId) + { + return isset($this->transactionDetails[$transactionId]) + ? $this->transactionDetails[$transactionId] + : $this->loadTransactionDetails($transactionId); + } +} diff --git a/app/code/Magento/Authorizenet/Model/Debug.php b/app/code/Magento/Authorizenet/Model/Debug.php new file mode 100644 index 0000000000000..4cde70deb0fd6 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Debug.php @@ -0,0 +1,33 @@ +_init('Magento\Authorizenet\Model\Resource\Debug'); + } +} diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php new file mode 100644 index 0000000000000..27270490c51a0 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -0,0 +1,901 @@ +orderFactory = $orderFactory; + $this->storeManager = $storeManager; + $this->quoteRepository = $quoteRepository; + $this->response = $responseFactory->create(); + $this->orderSender = $orderSender; + $this->_code = static::METHOD_CODE; + + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $paymentData, + $scopeConfig, + $logger, + $moduleList, + $localeDate, + $dataHelper, + $requestFactory, + $responseFactory, + $resource, + $resourceCollection, + $data + ); + } + + /** + * Set data helper + * + * @param \Magento\Authorizenet\Helper\Data $dataHelper + * @return void + */ + public function setDataHelper(\Magento\Authorizenet\Helper\Data $dataHelper) + { + $this->dataHelper = $dataHelper; + } + + /** + * Do not validate payment form using server methods + * + * @return bool + */ + public function validate() + { + return true; + } + + /** + * Send authorize request to gateway + * + * @param \Magento\Framework\Object|\Magento\Payment\Model\InfoInterface $payment + * @param float $amount + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount) + { + $payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action')); + } + + /** + * Send capture request to gateway + * + * @param \Magento\Framework\Object|\Magento\Payment\Model\InfoInterface $payment + * @param float $amount + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount) + { + if ($amount <= 0) { + throw new \Magento\Framework\Exception\LocalizedException(__('Invalid amount for capture.')); + } + + $payment->setAmount($amount); + + if ($payment->getParentTransactionId()) { + $payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE); + $payment->setXTransId($this->getRealParentTransactionId($payment)); + } else { + $payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE); + } + + $result = $this->getResponse(); + if (empty($result->getData())) { + $request = $this->buildRequest($payment); + $result = $this->postRequest($request); + } + + return $this->processCapture($result, $payment); + } + + /** + * Process capture request + * + * @param \Magento\Authorizenet\Model\Directpost\Response $result + * @param \Magento\Payment\Model\InfoInterface $payment + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function processCapture($result, $payment) + { + switch ($result->getXResponseCode()) { + case self::RESPONSE_CODE_APPROVED: + case self::RESPONSE_CODE_HELD: + if ( + in_array( + $result->getXResponseReasonCode(), + [ + self::RESPONSE_REASON_CODE_APPROVED, + self::RESPONSE_REASON_CODE_PENDING_REVIEW, + self::RESPONSE_REASON_CODE_PENDING_REVIEW_AUTHORIZED + ] + ) + ) { + if (!$payment->getParentTransactionId() + || $result->getXTransId() != $payment->getParentTransactionId() + ) { + $payment->setTransactionId($result->getXTransId()); + } + $payment->setIsTransactionClosed(0) + ->setTransactionAdditionalInfo( + self::REAL_TRANSACTION_ID_KEY, + $result->getXTransId() + ); + return $this; + } + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($result->getXResponseReasonText()) + ); + case self::RESPONSE_CODE_DECLINED: + case self::RESPONSE_CODE_ERROR: + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($result->getXResponseReasonText()) + ); + default: + throw new \Magento\Framework\Exception\LocalizedException(__('Payment capturing error.')); + } + } + + /** + * Void the payment through gateway + * + * @param \Magento\Framework\Object|\Magento\Payment\Model\InfoInterface $payment + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function void(\Magento\Payment\Model\InfoInterface $payment) + { + if (!$payment->getParentTransactionId()) { + throw new \Magento\Framework\Exception\LocalizedException(__('Invalid transaction ID.')); + } + + $payment->setAnetTransType(self::REQUEST_TYPE_VOID); + $payment->setXTransId($this->getRealParentTransactionId($payment)); + + $request = $this->buildRequest($payment); + $result = $this->postRequest($request); + + switch ($result->getXResponseCode()) { + case self::RESPONSE_CODE_APPROVED: + if ($result->getXResponseReasonCode() == self::RESPONSE_REASON_CODE_APPROVED) { + if ($result->getXTransId() != $payment->getParentTransactionId()) { + $payment->setTransactionId($result->getXTransId()); + } + $payment->setIsTransactionClosed(1) + ->setShouldCloseParentTransaction(1) + ->setTransactionAdditionalInfo(self::REAL_TRANSACTION_ID_KEY, $result->getXTransId()); + return $this; + } + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($result->getXResponseReasonText()) + ); + case self::RESPONSE_CODE_DECLINED: + case self::RESPONSE_CODE_ERROR: + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($result->getXResponseReasonText()) + ); + default: + throw new \Magento\Framework\Exception\LocalizedException(__('Payment voiding error.')); + } + } + + /** + * Refund the amount + * Need to decode last 4 digits for request. + * + * @param \Magento\Framework\Object|\Magento\Payment\Model\InfoInterface $payment + * @param float $amount + * @return $this + * @throws \Exception + */ + public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) + { + $last4 = $payment->getCcLast4(); + $payment->setCcLast4($payment->decrypt($last4)); + try { + $this->processRefund($payment, $amount); + } catch (\Exception $e) { + $payment->setCcLast4($last4); + throw $e; + } + $payment->setCcLast4($last4); + return $this; + } + + /** + * Refund the amount with transaction id + * + * @param \Magento\Framework\Object $payment + * @param float $amount + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function processRefund(\Magento\Framework\Object $payment, $amount) + { + if ($amount <= 0) { + throw new \Magento\Framework\Exception\LocalizedException(__('Invalid amount for refund.')); + } + + if (!$payment->getParentTransactionId()) { + throw new \Magento\Framework\Exception\LocalizedException(__('Invalid transaction ID.')); + } + + $payment->setAnetTransType(self::REQUEST_TYPE_CREDIT); + $payment->setAmount($amount); + $payment->setXTransId($this->getRealParentTransactionId($payment)); + + $request = $this->buildRequest($payment); + $result = $this->postRequest($request); + + switch ($result->getXResponseCode()) { + case self::RESPONSE_CODE_APPROVED: + if ($result->getXResponseReasonCode() == self::RESPONSE_REASON_CODE_APPROVED) { + if ($result->getXTransId() != $payment->getParentTransactionId()) { + $payment->setTransactionId($result->getXTransId()); + } + $shouldCloseCaptureTransaction = $payment->getOrder()->canCreditmemo() ? 0 : 1; + $payment->setIsTransactionClosed(1) + ->setShouldCloseParentTransaction($shouldCloseCaptureTransaction) + ->setTransactionAdditionalInfo(self::REAL_TRANSACTION_ID_KEY, $result->getXTransId()); + return $this; + } + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($result->getXResponseReasonText()) + ); + case self::RESPONSE_CODE_DECLINED: + case self::RESPONSE_CODE_ERROR: + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($result->getXResponseReasonText()) + ); + default: + throw new \Magento\Framework\Exception\LocalizedException(__('Payment refunding error.')); + } + } + + /** + * Get CGI url + * + * @return string + */ + public function getCgiUrl() + { + $uri = $this->getConfigData('cgi_url'); + return $uri ? $uri : self::CGI_URL; + } + + /** + * Return URL on which Authorize.net server will return payment result data in hidden request. + * + * @param int $storeId + * @return string + */ + public function getRelayUrl($storeId = null) + { + if ($storeId == null && $this->getStore()) { + $storeId = $this->getStore(); + } + return $this->dataHelper->getRelayUrl($storeId); + } + + /** + * Return response. + * + * @return \Magento\Authorizenet\Model\Directpost\Response + */ + public function getResponse() + { + return $this->response; + } + + /** + * Instantiate state and set it to state object + * + * @param string $paymentAction + * @param \Magento\Framework\Object $stateObject + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function initialize($paymentAction, $stateObject) + { + $requestType = null; + switch ($paymentAction) { + case self::ACTION_AUTHORIZE: + $requestType = self::REQUEST_TYPE_AUTH_ONLY; + //intentional + case self::ACTION_AUTHORIZE_CAPTURE: + $requestType = $requestType ?: self::REQUEST_TYPE_AUTH_CAPTURE; + $payment = $this->getInfoInstance(); + $order = $payment->getOrder(); + $order->setCanSendNewEmailFlag(false); + $payment->setBaseAmountAuthorized($order->getBaseTotalDue()); + $payment->setAmountAuthorized($order->getTotalDue()); + $payment->setAnetTransType($requestType); + break; + default: + break; + } + } + + /** + * Generate request object and fill its fields from Quote or Order object + * + * @param \Magento\Sales\Model\Order $order Quote or order object. + * @return \Magento\Authorizenet\Model\Directpost\Request + */ + public function generateRequestFromOrder(\Magento\Sales\Model\Order $order) + { + $request = $this->requestFactory->create() + ->setConstantData($this) + ->setDataFromOrder($order, $this) + ->signRequestData(); + + $this->_debug(['request' => $request->getData()]); + + return $request; + } + + /** + * Fill response with data. + * + * @param array $postData + * @return $this + */ + public function setResponseData(array $postData) + { + $this->getResponse()->setData($postData); + return $this; + } + + /** + * Validate response data. Needed in controllers. + * + * @return bool true in case of validation success. + * @throws \Magento\Framework\Exception\LocalizedException In case of validation error + */ + public function validateResponse() + { + $response = $this->getResponse(); + //md5 check + if ( + !$this->getConfigData('trans_md5') + || !$this->getConfigData('login') + || !$response->isValidHash($this->getConfigData('trans_md5'), $this->getConfigData('login')) + ) { + throw new \Magento\Framework\Exception\LocalizedException( + __('The transaction was declined because the response hash validation failed.') + ); + } + return true; + } + + /** + * Operate with order using data from $_POST which came from authorize.net by Relay URL. + * + * @param array $responseData data from Authorize.net from $_POST + * @return void + * @throws \Magento\Framework\Exception\LocalizedException In case of validation error or order creation error + */ + public function process(array $responseData) + { + $this->_debug(['response' => $responseData]); + + $this->setResponseData($responseData); + + //check MD5 error or others response errors + //throws exception on false. + $this->validateResponse(); + + $response = $this->getResponse(); + //operate with order + $orderIncrementId = $response->getXInvoiceNum(); + $responseText = $this->dataHelper->wrapGatewayError($response->getXResponseReasonText()); + $isError = false; + if ($orderIncrementId) { + /* @var $order \Magento\Sales\Model\Order */ + $order = $this->orderFactory->create()->loadByIncrementId($orderIncrementId); + //check payment method + $payment = $order->getPayment(); + if (!$payment || $payment->getMethod() != $this->getCode()) { + throw new \Magento\Framework\Exception\LocalizedException( + __('This payment didn\'t work out because we can\'t find this order.') + ); + } + if ($order->getId()) { + //operate with order + $this->processOrder($order); + } else { + $isError = true; + } + } else { + $isError = true; + } + + if ($isError) { + $responseText = $responseText && !$response->isApproved() + ? $responseText + : __('This payment didn\'t work out because we can\'t find this order.'); + throw new \Magento\Framework\Exception\LocalizedException($responseText); + } + } + + /** + * Fill payment with credit card data from response from Authorize.net. + * + * @param \Magento\Framework\Object $payment + * @return void + */ + protected function fillPaymentByResponse(\Magento\Framework\Object $payment) + { + $response = $this->getResponse(); + $payment->setTransactionId($response->getXTransId()) + ->setParentTransactionId(null) + ->setIsTransactionClosed(0) + ->setTransactionAdditionalInfo(self::REAL_TRANSACTION_ID_KEY, $response->getXTransId()); + + if ($response->getXMethod() == self::REQUEST_METHOD_CC) { + $payment->setCcAvsStatus($response->getXAvsCode()) + ->setCcLast4($payment->encrypt(substr($response->getXAccountNumber(), -4))); + } + + if ($response->getXResponseCode() == self::RESPONSE_CODE_HELD) { + $payment->setIsTransactionPending(true) + ->setIsFraudDetected(true); + } + } + + /** + * Check response code came from Authorize.net. + * + * @return true in case of Approved response + * @throws \Magento\Framework\Exception\LocalizedException In case of Declined or Error response from Authorize.net + */ + public function checkResponseCode() + { + switch ($this->getResponse()->getXResponseCode()) { + case self::RESPONSE_CODE_APPROVED: + case self::RESPONSE_CODE_HELD: + return true; + case self::RESPONSE_CODE_DECLINED: + case self::RESPONSE_CODE_ERROR: + throw new \Magento\Framework\Exception\LocalizedException( + $this->dataHelper->wrapGatewayError($this->getResponse()->getXResponseReasonText()) + ); + default: + throw new \Magento\Framework\Exception\LocalizedException( + __('There was a payment authorization error.') + ); + } + } + + /** + * Check transaction id came from Authorize.net + * + * @return true in case of right transaction id + * @throws \Magento\Framework\Exception\LocalizedException In case of bad transaction id. + */ + public function checkTransId() + { + if (!$this->getResponse()->getXTransId()) { + throw new \Magento\Framework\Exception\LocalizedException( + __('Please enter a transaction ID to authorize this payment.') + ); + } + return true; + } + + /** + * Compare amount with amount from the response from Authorize.net. + * + * @param float $amount + * @return bool + */ + protected function matchAmount($amount) + { + return sprintf('%.2F', $amount) == sprintf('%.2F', $this->getResponse()->getXAmount()); + } + + /** + * Operate with order using information from Authorize.net. + * Authorize order or authorize and capture it. + * + * @param \Magento\Sales\Model\Order $order + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Exception + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + protected function processOrder(\Magento\Sales\Model\Order $order) + { + try { + $this->checkResponseCode(); + $this->checkTransId(); + } catch (\Exception $e) { + //decline the order (in case of wrong response code) but don't return money to customer. + $message = $e->getMessage(); + $this->declineOrder($order, $message, false); + throw $e; + } + + $response = $this->getResponse(); + + //create transaction. need for void if amount will not match. + $payment = $order->getPayment(); + $this->fillPaymentByResponse($payment); + $payment->getMethodInstance()->setIsInitializeNeeded(false); + $payment->getMethodInstance()->setResponseData($response->getData()); + $this->processPaymentFraudStatus($payment); + $payment->place(); + $this->addStatusComment($payment); + $order->save(); + + //match amounts. should be equals for authorization. + //decline the order if amount does not match. + if (!$this->matchAmount($payment->getBaseAmountAuthorized())) { + $message = __( + 'Something went wrong: the paid amount doesn\'t match the order amount.' + . ' Please correct this and try again.' + ); + $this->declineOrder($order, $message, true); + throw new \Magento\Framework\Exception\LocalizedException($message); + } + + try { + if (!$response->hasOrderSendConfirmation() || $response->getOrderSendConfirmation()) { + $this->orderSender->send($order); + } + + $quote = $this->quoteRepository->get($order->getQuoteId())->setIsActive(false); + $this->quoteRepository->save($quote); + } catch (\Exception $e) { + // do not cancel order if we couldn't send email + } + } + + /** + * Process fraud status + * + * @param \Magento\Sales\Model\Order\Payment $payment + * @return $this + */ + protected function processPaymentFraudStatus(\Magento\Sales\Model\Order\Payment $payment) + { + $fraudDetailsResponse = $payment->getMethodInstance() + ->fetchTransactionFraudDetails($this->getResponse()->getXTransId()); + $fraudData = $fraudDetailsResponse->getData(); + + if (empty($fraudData)) { + $payment->setIsFraudDetected(false); + return $this; + } + + $payment->setIsFraudDetected(true); + $payment->setAdditionalInformation('fraud_details', $fraudData); + + return $this; + } + + /** + * Add status comment + * + * @param \Magento\Sales\Model\Order\Payment $payment + * @return $this + */ + protected function addStatusComment(\Magento\Sales\Model\Order\Payment $payment) + { + $transactionId = $this->getResponse()->getXTransId(); + $data = $payment->getMethodInstance()->getTransactionDetails($transactionId); + $transactionStatus = (string)$data->transaction->transactionStatus; + $fdsFilterAction = (string)$data->transaction->FDSFilterAction; + + if ($payment->getIsTransactionPending()) { + $message = 'Amount of %1 is pending approval on the gateway.
' + . 'Transaction "%2" status is "%3".
' + . 'Transaction FDS Filter Action is "%4"'; + $message = __( + $message, + $payment->getOrder()->getBaseCurrency()->formatTxt($this->getResponse()->getXAmount()), + $transactionId, + $this->dataHelper->getTransactionStatusLabel($transactionStatus), + $this->dataHelper->getFdsFilterActionLabel($fdsFilterAction) + ); + $payment->getOrder()->addStatusHistoryComment($message); + } + return $this; + } + + /** + * Register order cancellation. Return money to customer if needed. + * + * @param \Magento\Sales\Model\Order $order + * @param string $message + * @param bool $voidPayment + * @return void + */ + protected function declineOrder(\Magento\Sales\Model\Order $order, $message = '', $voidPayment = true) + { + try { + $response = $this->getResponse(); + if ( + $voidPayment && $response->getXTransId() && strtoupper($response->getXType()) + == self::REQUEST_TYPE_AUTH_ONLY + ) { + $order->getPayment()->setTransactionId(null)->setParentTransactionId($response->getXTransId())->void(); + } + $order->registerCancellation($message)->save(); + } catch (\Exception $e) { + //quiet decline + $this->logger->critical($e); + } + } + + /** + * Return additional information`s transaction_id value of parent transaction model + * + * @param \Magento\Sales\Model\Order\Payment $payment + * @return string + */ + protected function getRealParentTransactionId($payment) + { + $transaction = $payment->getTransaction($payment->getParentTransactionId()); + return $transaction->getAdditionalInformation(self::REAL_TRANSACTION_ID_KEY); + } + + /** + * {inheritdoc} + */ + public function getConfigInterface() + { + return $this; + } + + /** + * Getter for specified value according to set payment method code + * + * @param mixed $key + * @param null $storeId + * @return mixed + */ + public function getValue($key, $storeId = null) + { + return $this->getConfigData($key, $storeId); + } + + /** + * Set initialization requirement state + * + * @param bool $isInitializeNeeded + * @return void + */ + public function setIsInitializeNeeded($isInitializeNeeded = true) + { + $this->_isInitializeNeeded = (bool)$isInitializeNeeded; + } + + /** + * Get whether it is possible to capture + * + * @return bool + */ + public function canCapture() + { + return !$this->isGatewayActionsLocked($this->getInfoInstance()); + } + + /** + * Fetch transaction details info + * + * Update transaction info if there is one placing transaction only + * + * @param \Magento\Payment\Model\InfoInterface $payment + * @param string $transactionId + * @return array + */ + public function fetchTransactionInfo(\Magento\Payment\Model\InfoInterface $payment, $transactionId) + { + $transaction = $payment->getTransaction($transactionId); + + $response = $this->getTransactionResponse($transactionId); + if ($response->getXResponseCode() == self::RESPONSE_CODE_APPROVED) { + if ($response->getTransactionStatus() == 'voided') { + $payment->setIsTransactionDenied(true); + } else { + $transaction->setAdditionalInformation(self::TRANSACTION_FRAUD_STATE_KEY, false); + $payment->setIsTransactionApproved(true); + } + } elseif ($response->getXResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW_DECLINED) { + $payment->setIsTransactionDenied(true); + } + $this->addStatusCommentOnUpdate($payment, $response, $transactionId); + return parent::fetchTransactionInfo($payment, $transactionId); + } + + /** + * @param \Magento\Sales\Model\Order\Payment $payment + * @param \Magento\Framework\Object $response + * @param string $transactionId + * @return $this + */ + protected function addStatusCommentOnUpdate( + \Magento\Sales\Model\Order\Payment $payment, + \Magento\Framework\Object $response, + $transactionId + ) { + if ($payment->getIsTransactionApproved()) { + $message = __( + 'Transaction %1 has been approved. Amount %2. Transaction status is "%3"', + $transactionId, + $payment->getOrder()->getBaseCurrency()->formatTxt($payment->getAmountAuthorized()), + $this->dataHelper->getTransactionStatusLabel($response->getTransactionStatus()) + ); + $payment->getOrder()->addStatusHistoryComment($message); + } elseif ($payment->getIsTransactionDenied()) { + $message = __( + 'Transaction %1 has been voided/declined. Transaction status is "%2". Amount %3.', + $transactionId, + $this->dataHelper->getTransactionStatusLabel($response->getTransactionStatus()), + $payment->getOrder()->getBaseCurrency()->formatTxt($payment->getAmountAuthorized()) + ); + $payment->getOrder()->addStatusHistoryComment($message); + } + return $this; + } +} diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Observer.php b/app/code/Magento/Authorizenet/Model/Directpost/Observer.php new file mode 100644 index 0000000000000..ce55e5f287927 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Directpost/Observer.php @@ -0,0 +1,150 @@ + + */ +class Observer +{ + /** + * Core registry + * + * @var \Magento\Framework\Registry + */ + protected $_coreRegistry; + + /** + * Authorizenet helper + * + * @var \Magento\Authorizenet\Helper\Data + */ + protected $_authorizenetData; + + /** + * @var Directpost + */ + protected $_payment; + + /** + * @var \Magento\Authorizenet\Model\Directpost\Session + */ + protected $_session; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $_storeManager; + + /** + * Constructor + * + * @param \Magento\Authorizenet\Helper\Data $authorizenetData + * @param \Magento\Framework\Registry $coreRegistry + * @param Directpost $payment + * @param \Magento\Authorizenet\Model\Directpost\Session $session + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + */ + public function __construct( + \Magento\Authorizenet\Helper\Data $authorizenetData, + \Magento\Framework\Registry $coreRegistry, + Directpost $payment, + \Magento\Authorizenet\Model\Directpost\Session $session, + \Magento\Store\Model\StoreManagerInterface $storeManager + ) { + $this->_coreRegistry = $coreRegistry; + $this->_authorizenetData = $authorizenetData; + $this->_payment = $payment; + $this->_session = $session; + $this->_storeManager = $storeManager; + } + + /** + * Save order into registry to use it in the overloaded controller. + * + * @param \Magento\Framework\Event\Observer $observer + * @return $this + */ + public function saveOrderAfterSubmit(\Magento\Framework\Event\Observer $observer) + { + /* @var $order Order */ + $order = $observer->getEvent()->getData('order'); + $this->_coreRegistry->register('directpost_order', $order, true); + + return $this; + } + + /** + * Set data for response of frontend saveOrder action + * + * @param \Magento\Framework\Event\Observer $observer + * @return $this + */ + public function addFieldsToResponse(\Magento\Framework\Event\Observer $observer) + { + /* @var $order Order */ + $order = $this->_coreRegistry->registry('directpost_order'); + + if (!$order || !$order->getId()) { + return $this; + } + + $payment = $order->getPayment(); + + if (!$payment || $payment->getMethod() != $this->_payment->getCode()) { + return $this; + } + + $result = $observer->getData('result')->getData(); + + if (!empty($result['error'])) { + return $this; + } + + // if success, then set order to session and add new fields + $this->_session->addCheckoutOrderIncrementId($order->getIncrementId()); + $this->_session->setLastOrderIncrementId($order->getIncrementId()); + + $requestToAuthorizenet = $payment->getMethodInstance() + ->generateRequestFromOrder($order); + $requestToAuthorizenet->setControllerActionName( + $observer->getData('action') + ->getRequest() + ->getControllerName() + ); + $requestToAuthorizenet->setIsSecure( + (string)$this->_storeManager->getStore() + ->isCurrentlySecure() + ); + + $result[$this->_payment->getCode()] = ['fields' => $requestToAuthorizenet->getData()]; + + $observer->getData('result')->setData($result); + + return $this; + } + + /** + * Update all edit increments for all orders if module is enabled. + * Needed for correct work of edit orders in Admin area. + * + * @param \Magento\Framework\Event\Observer $observer + * @return $this + */ + public function updateAllEditIncrements(\Magento\Framework\Event\Observer $observer) + { + /* @var $order Order */ + $order = $observer->getEvent()->getData('order'); + $this->_authorizenetData->updateOrderEditIncrements($order); + + return $this; + } +} diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Request.php b/app/code/Magento/Authorizenet/Model/Directpost/Request.php new file mode 100644 index 0000000000000..430db3cc9e76e --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Directpost/Request.php @@ -0,0 +1,184 @@ +_transKey; + } + + /** + * Set merchant transaction key. + * Needed to generate sign. + * + * @param string $transKey + * @return $this + */ + protected function _setTransactionKey($transKey) + { + $this->_transKey = $transKey; + return $this; + } + + /** + * Generates the fingerprint for request. + * + * @param string $merchantApiLoginId + * @param string $merchantTransactionKey + * @param string $amount + * @param string $currencyCode + * @param string $fpSequence An invoice number or random number. + * @param string $fpTimestamp + * @return string The fingerprint. + */ + public function generateRequestSign( + $merchantApiLoginId, + $merchantTransactionKey, + $amount, + $currencyCode, + $fpSequence, + $fpTimestamp + ) { + return hash_hmac( + "md5", + $merchantApiLoginId . "^" . $fpSequence . "^" . $fpTimestamp . "^" . $amount . "^" . $currencyCode, + $merchantTransactionKey + ); + } + + /** + * Set Authorizenet data to request. + * + * @param \Magento\Authorizenet\Model\Directpost $paymentMethod + * @return $this + */ + public function setConstantData(\Magento\Authorizenet\Model\Directpost $paymentMethod) + { + $this->setXVersion('3.1')->setXDelimData('FALSE')->setXRelayResponse('TRUE'); + + $this->setXTestRequest($paymentMethod->getConfigData('test') ? 'TRUE' : 'FALSE'); + + $this->setXLogin($paymentMethod->getConfigData('login')) + ->setXMethod(\Magento\Authorizenet\Model\Authorizenet::REQUEST_METHOD_CC) + ->setXRelayUrl($paymentMethod->getRelayUrl()); + + $this->_setTransactionKey($paymentMethod->getConfigData('trans_key')); + return $this; + } + + /** + * Set entity data to request + * + * @param \Magento\Sales\Model\Order $order + * @param \Magento\Authorizenet\Model\Directpost $paymentMethod + * @return $this + */ + public function setDataFromOrder( + \Magento\Sales\Model\Order $order, + \Magento\Authorizenet\Model\Directpost $paymentMethod + ) { + $payment = $order->getPayment(); + + $this->setXType($payment->getAnetTransType()); + $this->setXFpSequence($order->getQuoteId()); + $this->setXInvoiceNum($order->getIncrementId()); + $this->setXAmount($payment->getBaseAmountAuthorized()); + $this->setXCurrencyCode($order->getBaseCurrencyCode()); + $this->setXTax( + sprintf('%.2F', $order->getBaseTaxAmount()) + )->setXFreight( + sprintf('%.2F', $order->getBaseShippingAmount()) + ); + + //need to use strval() because NULL values IE6-8 decodes as "null" in JSON in JavaScript, + //but we need "" for null values. + $billing = $order->getBillingAddress(); + if (!empty($billing)) { + $this->setXFirstName(strval($billing->getFirstname())) + ->setXLastName(strval($billing->getLastname())) + ->setXCompany(strval($billing->getCompany())) + ->setXAddress(strval($billing->getStreetLine(1))) + ->setXCity(strval($billing->getCity())) + ->setXState(strval($billing->getRegion())) + ->setXZip(strval($billing->getPostcode())) + ->setXCountry(strval($billing->getCountry())) + ->setXPhone(strval($billing->getTelephone())) + ->setXFax(strval($billing->getFax())) + ->setXCustId(strval($billing->getCustomerId())) + ->setXCustomerIp(strval($order->getRemoteIp())) + ->setXCustomerTaxId(strval($billing->getTaxId())) + ->setXEmail(strval($order->getCustomerEmail())) + ->setXEmailCustomer(strval($paymentMethod->getConfigData('email_customer'))) + ->setXMerchantEmail(strval($paymentMethod->getConfigData('merchant_email'))); + } + + $shipping = $order->getShippingAddress(); + if (!empty($shipping)) { + $this->setXShipToFirstName( + strval($shipping->getFirstname()) + )->setXShipToLastName( + strval($shipping->getLastname()) + )->setXShipToCompany( + strval($shipping->getCompany()) + )->setXShipToAddress( + strval($shipping->getStreetLine(1)) + )->setXShipToCity( + strval($shipping->getCity()) + )->setXShipToState( + strval($shipping->getRegion()) + )->setXShipToZip( + strval($shipping->getPostcode()) + )->setXShipToCountry( + strval($shipping->getCountry()) + ); + } + + $this->setXPoNum(strval($payment->getPoNumber())); + + return $this; + } + + /** + * Set sign hash into the request object. + * All needed fields should be placed in the object fist. + * + * @return $this + */ + public function signRequestData() + { + $fpTimestamp = time(); + $hash = $this->generateRequestSign( + $this->getXLogin(), + $this->_getTransactionKey(), + $this->getXAmount(), + $this->getXCurrencyCode(), + $this->getXFpSequence(), + $fpTimestamp + ); + $this->setXFpTimestamp($fpTimestamp); + $this->setXFpHash($hash); + return $this; + } +} diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Request/Factory.php b/app/code/Magento/Authorizenet/Model/Directpost/Request/Factory.php new file mode 100644 index 0000000000000..49ead3ecc94c8 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Directpost/Request/Factory.php @@ -0,0 +1,27 @@ +generateHash($merchantMd5, $merchantApiLogin, $this->getXAmount(), $this->getXTransId()); + return $hash == $this->getData('x_MD5_Hash'); + } + + /** + * Return if this is approved response from Authorize.net auth request. + * + * @return bool + */ + public function isApproved() + { + return $this->getXResponseCode() == \Magento\Authorizenet\Model\Directpost::RESPONSE_CODE_APPROVED; + } +} diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Response/Factory.php b/app/code/Magento/Authorizenet/Model/Directpost/Response/Factory.php new file mode 100644 index 0000000000000..91905eaf9792c --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Directpost/Response/Factory.php @@ -0,0 +1,27 @@ +getDirectPostOrderIncrementIds(); + if (!$orderIncIds) { + $orderIncIds = []; + } + $orderIncIds[$orderIncrementId] = 1; + $this->setDirectPostOrderIncrementIds($orderIncIds); + } + + /** + * Remove order IncrementId from session + * + * @param string $orderIncrementId + * @return void + */ + public function removeCheckoutOrderIncrementId($orderIncrementId) + { + $orderIncIds = $this->getDirectPostOrderIncrementIds(); + + if (!is_array($orderIncIds)) { + return; + } + + if (isset($orderIncIds[$orderIncrementId])) { + unset($orderIncIds[$orderIncrementId]); + } + $this->setDirectPostOrderIncrementIds($orderIncIds); + } + + /** + * Return if order incrementId is in session. + * + * @param string $orderIncrementId + * @return bool + */ + public function isCheckoutOrderIncrementIdExist($orderIncrementId) + { + $orderIncIds = $this->getDirectPostOrderIncrementIds(); + if (is_array($orderIncIds) && isset($orderIncIds[$orderIncrementId])) { + return true; + } + return false; + } +} diff --git a/app/code/Magento/Authorizenet/Model/Request.php b/app/code/Magento/Authorizenet/Model/Request.php new file mode 100644 index 0000000000000..df2be82cbe111 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Request.php @@ -0,0 +1,15 @@ +objectManager = $objectManager; + $this->instanceName = $instanceName; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\Authorizenet\Model\Request + */ + public function create(array $data = []) + { + return $this->objectManager->create($this->instanceName, $data); + } +} diff --git a/app/code/Magento/Authorizenet/Model/Resource/Debug.php b/app/code/Magento/Authorizenet/Model/Resource/Debug.php new file mode 100644 index 0000000000000..db5ab62c9b874 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Resource/Debug.php @@ -0,0 +1,22 @@ +_init('authorizenet_debug', 'debug_id'); + } +} diff --git a/app/code/Magento/Authorizenet/Model/Resource/Debug/Collection.php b/app/code/Magento/Authorizenet/Model/Resource/Debug/Collection.php new file mode 100644 index 0000000000000..39ea6789279f8 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Resource/Debug/Collection.php @@ -0,0 +1,25 @@ +_init( + 'Magento\Authorizenet\Model\Debug', + 'Magento\Authorizenet\Model\Resource\Debug' + ); + } +} diff --git a/app/code/Magento/Authorizenet/Model/Response.php b/app/code/Magento/Authorizenet/Model/Response.php new file mode 100644 index 0000000000000..d22475163610e --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Response.php @@ -0,0 +1,15 @@ +objectManager = $objectManager; + $this->instanceName = $instanceName; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\Authorizenet\Model\Response + */ + public function create(array $data = []) + { + return $this->objectManager->create($this->instanceName, $data); + } +} diff --git a/app/code/Magento/Authorizenet/Model/Source/Cctype.php b/app/code/Magento/Authorizenet/Model/Source/Cctype.php new file mode 100644 index 0000000000000..ce39818e04e06 --- /dev/null +++ b/app/code/Magento/Authorizenet/Model/Source/Cctype.php @@ -0,0 +1,22 @@ + \Magento\Authorizenet\Model\Authorizenet::ACTION_AUTHORIZE, + 'label' => __('Authorize Only'), + ], + [ + 'value' => \Magento\Authorizenet\Model\Authorizenet::ACTION_AUTHORIZE_CAPTURE, + 'label' => __('Authorize and Capture') + ] + ]; + } +} diff --git a/app/code/Magento/Authorizenet/README.md b/app/code/Magento/Authorizenet/README.md new file mode 100644 index 0000000000000..380161d8b264e --- /dev/null +++ b/app/code/Magento/Authorizenet/README.md @@ -0,0 +1 @@ +The Magento_Authorizenet module implements the integration with the Authorize.Net payment gateway and makes the latter available as a payment method in Magento. diff --git a/app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php b/app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php new file mode 100644 index 0000000000000..ad7bb7b5c0245 --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php @@ -0,0 +1,312 @@ +directpostSessionMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Session') + ->setMethods([ + 'getLastOrderIncrementId', + 'removeCheckoutOrderIncrementId', + 'isCheckoutOrderIncrementIdExist', + 'unsetData' + ]) + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->setMethods(['getId', 'getState', 'getIncrementId', 'registerCancellation', 'loadByIncrementId', 'save']) + ->disableOriginalConstructor() + ->getMock(); + $this->adminOrderCreateMock = $this->getMockBuilder('Magento\Sales\Model\AdminOrder\Create') + ->setMethods(['getSession']) + ->disableOriginalConstructor() + ->getMock(); + $sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->getMock(); + $this->sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + ->setMethods(['getOrder', 'clearStorage']) + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerMock->expects($this->atLeastOnce()) + ->method('get') + ->willReturnMap([ + ['Magento\Authorizenet\Model\Directpost\Session', $this->directpostSessionMock], + ['Magento\Sales\Model\AdminOrder\Create', $this->adminOrderCreateMock], + ['Magento\Backend\Model\Session\Quote', $this->sessionQuoteMock], + ['Magento\Backend\Model\Session', $sessionMock], + ]); + $this->objectManagerMock->expects($this->any()) + ->method('create') + ->with('Magento\Sales\Model\Order') + ->willReturn($this->orderMock); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + ->setMethods(['getParams']) + ->getMockForAbstractClass(); + $responseMock = $this->getMockForAbstractClass('Magento\Framework\App\ResponseInterface'); + $redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); + $this->messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); + + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->setMethods(['getObjectManager', 'getRequest', 'getResponse', 'getRedirect', 'getMessageManager']) + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); + $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->any())->method('getResponse')->willReturn($responseMock); + $this->contextMock->expects($this->any())->method('getRedirect')->willReturn($redirectMock); + $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock); + + $this->productHelperMock = $this->getMockBuilder('Magento\Catalog\Helper\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->escaperMock = $this->getMockBuilder('Magento\Framework\Escaper') + ->disableOriginalConstructor() + ->getMock(); + $this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->forwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->coreRegistryMock = $this->getMockBuilder('Magento\Framework\Registry') + ->setMethods(['register']) + ->disableOriginalConstructor() + ->getMock(); + $resultLayoutMock = $this->getMockBuilder('Magento\Framework\View\Result\Layout') + ->disableOriginalConstructor() + ->getMock(); + $this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\LayoutFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->resultLayoutFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($resultLayoutMock); + $this->helperMock = $this->getMockBuilder('Magento\Authorizenet\Helper\Backend\Data') + ->setMethods(['getSuccessOrderUrl']) + ->disableOriginalConstructor() + ->getMock(); + + $this->controller = new Redirect( + $this->contextMock, + $this->productHelperMock, + $this->escaperMock, + $this->resultPageFactoryMock, + $this->forwardFactoryMock, + $this->coreRegistryMock, + $this->resultLayoutFactoryMock, + $this->helperMock + ); + } + + public function testExecuteErrorMsgWithoutCancelOrder() + { + $params = ['success' => 0, 'error_msg' => 'Error message']; + $incrementId = 1; + $this->requestMock->expects($this->once()) + ->method('getParams') + ->willReturn($params); + $this->directpostSessionMock->expects($this->once()) + ->method('getLastOrderIncrementId') + ->willReturn($incrementId); + $this->directpostSessionMock->expects($this->once()) + ->method('isCheckoutOrderIncrementIdExist') + ->with($incrementId) + ->willReturn(true); + + $this->orderMock->expects($this->once()) + ->method('loadByIncrementId') + ->with($incrementId) + ->willReturnSelf(); + $this->orderMock->expects($this->once()) + ->method('getId') + ->willReturn(true); + $this->orderMock->expects($this->once()) + ->method('getIncrementId') + ->willReturn($incrementId); + $this->orderMock->expects($this->once()) + ->method('getState') + ->willReturn(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT); + $this->orderMock->expects($this->once()) + ->method('registerCancellation') + ->with($params['error_msg']) + ->willReturnSelf(); + $this->orderMock->expects($this->once()) + ->method('save'); + + $this->directpostSessionMock->expects($this->once()) + ->method('removeCheckoutOrderIncrementId') + ->with($incrementId); + $this->coreRegistryMock->expects($this->once()) + ->method('register') + ->with(Iframe::REGISTRY_KEY); + + $this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->execute()); + } + + public function testExecuteErrorMsgWithCancelOrder() + { + $params = ['success' => 0, 'error_msg' => 'Error message', 'x_invoice_num' => 1]; + $incrementId = 1; + $this->requestMock->expects($this->once()) + ->method('getParams') + ->willReturn($params); + $this->directpostSessionMock->expects($this->once()) + ->method('getLastOrderIncrementId') + ->willReturn($incrementId); + $this->directpostSessionMock->expects($this->once()) + ->method('isCheckoutOrderIncrementIdExist') + ->with($incrementId) + ->willReturn(true); + $this->orderMock->expects($this->once()) + ->method('loadByIncrementId') + ->with($incrementId) + ->willReturnSelf(); + $this->orderMock->expects($this->once()) + ->method('getId') + ->willReturn(true); + $this->orderMock->expects($this->once()) + ->method('getIncrementId') + ->willReturn($incrementId); + $this->directpostSessionMock->expects($this->once()) + ->method('removeCheckoutOrderIncrementId') + ->with($incrementId); + + $this->coreRegistryMock->expects($this->once()) + ->method('register') + ->with(Iframe::REGISTRY_KEY); + + $this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->execute()); + } + + public function testExecuteSuccess() + { + $params = ['success' => 1, 'controller_action_name' => 'action', 'x_invoice_num' => 1]; + $this->requestMock->expects($this->once()) + ->method('getParams') + ->willReturn($params); + + $this->helperMock->expects($this->once()) + ->method('getSuccessOrderUrl') + ->willReturn('redirect_parent_url'); + + $this->directpostSessionMock->expects($this->once()) + ->method('unsetData') + ->with('quote_id'); + + $this->orderMock->expects($this->once()) + ->method('getId') + ->willReturn(null); + + $this->sessionQuoteMock->expects($this->atLeastOnce()) + ->method('getOrder') + ->willReturn($this->orderMock); + + $this->adminOrderCreateMock->expects($this->atLeastOnce()) + ->method('getSession') + ->willReturn($this->sessionQuoteMock); + + $this->coreRegistryMock->expects($this->once()) + ->method('register') + ->with(Iframe::REGISTRY_KEY); + + $this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->execute()); + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php b/app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php new file mode 100644 index 0000000000000..59be93bd3db52 --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php @@ -0,0 +1,138 @@ +urlBuilderMock = $this->getMock('Magento\Backend\Model\Url', ['getUrl'], [], '', false); + + $contextMock = $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false); + $contextMock->expects($this->any()) + ->method('getUrlBuilder') + ->willReturn($this->urlBuilderMock); + + $this->orderFactoryMock = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); + $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + + $this->dataHelper = $helper->getObject( + 'Magento\Authorizenet\Helper\Backend\Data', + [ + 'context' => $contextMock, + 'storeManager' =>$this->storeManagerMock, + 'orderFactory' =>$this->orderFactoryMock, + 'backendUrl' =>$this->urlBuilderMock + ] + ); + } + + public function testGetPlaceOrderAdminUrl() + { + $this->urlBuilderMock->expects($this->once()) + ->method('getUrl') + ->with('adminhtml/authorizenet_directpost_payment/place') + ->willReturn('some value'); + + $this->assertEquals('some value', $this->dataHelper->getPlaceOrderAdminUrl()); + } + + public function testGetSuccessOrderUrl() + { + $orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + ['loadByIncrementId', 'getId', '__wakeup'], + [], + '', + false + ); + $orderMock->expects($this->once()) + ->method('loadByIncrementId') + ->with('invoice number') + ->willReturnSelf(); + + $orderMock->expects($this->once()) + ->method('getId') + ->willReturn('order id'); + + $this->orderFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($orderMock); + + $this->urlBuilderMock->expects($this->once()) + ->method('getUrl') + ->with('sales/order/view', ['order_id' => 'order id']) + ->willReturn('some value'); + + $this->assertEquals( + 'some value', + $this->dataHelper->getSuccessOrderUrl(['x_invoice_num' => 'invoice number', 'some param']) + ); + } + + public function testGetRedirectIframeUrl() + { + $params = ['some params', '_secure' => true]; + $this->urlBuilderMock->expects($this->once()) + ->method('getUrl') + ->with('adminhtml/authorizenet_directpost_payment/redirect', $params) + ->willReturn('some value'); + + $this->assertEquals('some value', $this->dataHelper->getRedirectIframeUrl($params)); + } + + public function testGetRelayUrl() + { + $baseUrl = 'http://base.url/'; + + $defaultStoreMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + + $defaultStoreMock->expects($this->once()) + ->method('getBaseUrl') + ->with(\Magento\Framework\UrlInterface::URL_TYPE_LINK) + ->willReturn($baseUrl); + + $this->storeManagerMock->expects($this->once()) + ->method('getDefaultStoreView') + ->willReturn(null); + + $this->storeManagerMock->expects($this->once()) + ->method('getStores') + ->willReturn([$defaultStoreMock]); + + $this->assertSame( + 'http://base.url/authorizenet/directpost_payment/backendResponse', + $this->dataHelper->getRelayUrl() + ); + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php b/app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php new file mode 100644 index 0000000000000..b444dfb68c0a9 --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php @@ -0,0 +1,193 @@ +storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + ->getMockForAbstractClass(); + + $this->dataHelper = $helper->getObject( + 'Magento\Authorizenet\Helper\Data', + ['storeManager' => $this->storeManagerMock] + ); + } + + /** + * @param $type + * @param $amount + * @param $exception + * @param $additionalMessage + * @param $expected + * @dataProvider getMessagesParamDataProvider + */ + public function testGetTransactionMessage($type, $amount, $exception, $additionalMessage, $expected) + { + $currency = $this->getMock('Magento\Directory\Model\Currency', ['formatTxt', '__wakeup'], [], '', false); + $currency->expects($this->any()) + ->method('formatTxt') + ->will($this->returnValue($amount)); + $order = $this->getMock('Magento\Sales\Model\Order', ['getBaseCurrency', '__wakeup'], [], '', false); + $order->expects($this->any()) + ->method('getBaseCurrency') + ->will($this->returnValue($currency)); + $payment = $this->getMock('Magento\Payment\Model\Info', ['getOrder', '__wakeup'], [], '', false); + $payment->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($order)); + $card = new \Magento\Framework\Object(['cc_last_4' => self::LAST4]); + $message = $this->dataHelper->getTransactionMessage( + $payment, + $type, + self::TRID, + $card, + $amount, + $exception, + $additionalMessage + ); + + $this->assertEquals($expected, $message); + } + + /** + * @return array + */ + public function getMessagesParamDataProvider() + { + $amount = 12.30; + $additionalMessage = 'Addition message.'; + return [ + [ + 'AUTH_ONLY', + $amount, + false, + $additionalMessage, + 'Credit Card: xxxx-' . self::LAST4 . ' amount 12.3 authorize - successful. ' + . 'Authorize.Net Transaction ID ' . self::TRID . '. Addition message.', + ], + [ + 'AUTH_CAPTURE', + $amount, + 'some exception', + false, + 'Credit Card: xxxx-' . self::LAST4 . ' amount 12.3 authorize and capture - failed. ' + . 'Authorize.Net Transaction ID ' . self::TRID . '. some exception' + ], + [ + 'CREDIT', + false, + false, + $additionalMessage, + 'Credit Card: xxxx-' . self::LAST4 . ' refund - successful. ' + . 'Authorize.Net Transaction ID ' . self::TRID . '. Addition message.' + ], + ]; + } + + public function testGetRelayUrl() + { + $storeId = 10; + $baseUrl = 'http://base.url/'; + + $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + + $storeMock->expects($this->once()) + ->method('getBaseUrl') + ->with(\Magento\Framework\UrlInterface::URL_TYPE_LINK) + ->willReturn($baseUrl); + + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->with($storeId) + ->willReturn($storeMock); + + $this->assertSame( + 'http://base.url/authorizenet/directpost_payment/response', + $this->dataHelper->getRelayUrl($storeId) + ); + } + + /** + * @param string $code + * @param string $expected + * + * @dataProvider getFdsFilterActionLabelDataProvider + */ + public function testGetFdsFilterActionLabel($code, $expected) + { + $this->assertSame($expected, (string)$this->dataHelper->getFdsFilterActionLabel($code)); + } + + /** + * @return array + */ + public function getFdsFilterActionLabelDataProvider() + { + return [ + ['decline ', 'Decline'], + ['hold', 'Hold'], + ['authAndHold', 'Authorize and Hold'], + ['report', 'Report Only'], + ['unknown_status', 'unknown_status'] + ]; + } + + /** + * @param string $code + * @param string $expected + * + * @dataProvider getTransactionStatusLabelDataProvider + */ + public function testGetTransactionStatusLabel($code, $expected) + { + $this->assertSame($expected, (string)$this->dataHelper->getTransactionStatusLabel($code)); + } + + /** + * @return array + */ + public function getTransactionStatusLabelDataProvider() + { + return [ + ['authorizedPendingCapture', 'Authorized/Pending Capture'], + ['capturedPendingSettlement', 'Captured/Pending Settlement'], + ['refundSettledSuccessfully', 'Refund/Settled Successfully'], + ['refundPendingSettlement', 'Refund/Pending Settlement'], + ['declined', 'Declined'], + ['expired', 'Expired'], + ['voided', 'Voided'], + ['FDSPendingReview', 'FDS - Pending Review'], + ['FDSAuthorizedPendingReview', 'FDS - Authorized/Pending Review'], + ['unknown_status', 'unknown_status'] + ]; + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ObserverTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ObserverTest.php new file mode 100644 index 0000000000000..3640a46c57755 --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ObserverTest.php @@ -0,0 +1,247 @@ +authorizenetDataMock = $this->getMockBuilder('Magento\Authorizenet\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + $this->coreRegistryMock = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + $this->paymentMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + ->disableOriginalConstructor() + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Session') + ->disableOriginalConstructor() + ->setMethods(['setLastOrderIncrementId', 'addCheckoutOrderIncrementId']) + ->getMock(); + $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->actionMock = $this->getMockBuilder('Magento\Checkout\Controller\Onepage\SaveOrder') + ->disableOriginalConstructor() + ->getMock(); + $this->resultMock = $this->getMockBuilder('Magento\Framework\Object') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = $helper->getObject( + 'Magento\Authorizenet\Model\Directpost\Observer', + [ + 'authorizenetData' => $this->authorizenetDataMock, + 'coreRegistry' => $this->coreRegistryMock, + 'payment' => $this->paymentMock, + 'session' => $this->sessionMock, + 'storeManager' => $this->storeManagerMock, + ] + ); + } + + /** + * Test for addFieldsToResponse method + * + * @return void + */ + public function testAddFieldsToResponseSuccess() + { + $testData = $this->getAddFieldsToResponseSuccessTestData(); + + $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->getMock(); + $orderPaymentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment') + ->disableOriginalConstructor() + ->getMock(); + $instanceMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + ->disableOriginalConstructor() + ->getMock(); + $requestToAuthorizenetMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Request') + ->disableOriginalConstructor() + ->setMethods(['setControllerActionName', 'setIsSecure', 'getData']) + ->getMock(); + $requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + ->disableOriginalConstructor() + ->setMethods(['getControllerName']) + ->getMockForAbstractClass(); + $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + + $this->coreRegistryMock->expects($this->once()) + ->method('registry') + ->with('directpost_order') + ->willReturn($orderMock); + $orderMock->expects($this->once()) + ->method('getId') + ->willReturn($testData['order.getId']); + $orderMock->expects($this->once()) + ->method('getPayment') + ->willReturn($orderPaymentMock); + $orderPaymentMock->expects($this->once()) + ->method('getMethod') + ->willReturn($testData['orderPayment.getMethod']); + $this->paymentMock->expects($this->exactly(2)) + ->method('getCode') + ->willReturn($testData['payment.getCode']); + $observerMock->expects($this->atLeastOnce()) + ->method('getData') + ->willReturnMap($testData['observer.getData']); + $this->resultMock->expects($this->once()) + ->method('getData') + ->willReturn($testData['result.getData']); + $orderMock->expects($this->atLeastOnce()) + ->method('getIncrementId') + ->willReturn($testData['order.getIncrementId']); + $this->sessionMock->expects($this->once()) + ->method('addCheckoutOrderIncrementId') + ->with($testData['session.addCheckoutOrderIncrementId']); + $this->sessionMock->expects($this->once()) + ->method('setLastOrderIncrementId') + ->with($testData['session.setLastOrderIncrementId']); + $orderPaymentMock->expects($this->once()) + ->method('getMethodInstance') + ->willReturn($instanceMock); + $instanceMock->expects($this->once()) + ->method('generateRequestFromOrder') + ->with($orderMock) + ->willReturn($requestToAuthorizenetMock); + $this->actionMock->expects($this->once()) + ->method('getRequest') + ->willReturn($requestMock); + $requestMock->expects($this->once()) + ->method('getControllerName') + ->willReturn($testData['request.getControllerName']); + $requestToAuthorizenetMock->expects($this->once()) + ->method('setControllerActionName') + ->with($testData['requestToAuthorizenet.setControllerActionName']); + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->willReturn($storeMock); + $storeMock->expects($this->once()) + ->method('isCurrentlySecure') + ->willReturn($testData['store.isCurrentlySecure']); + $requestToAuthorizenetMock->expects($this->once()) + ->method('setIsSecure') + ->with($testData['requestToAuthorizenet.setIsSecure']); + $requestToAuthorizenetMock->expects($this->once()) + ->method('getData') + ->willReturn($testData['requestToAuthorizenet.getData']); + $this->resultMock->expects($this->once()) + ->method('setData') + ->with($testData['result.setData']); + + $this->observer->addFieldsToResponse($observerMock); + } + + /** + * Get data for test testAddFieldsToResponseSuccess + * + * @return array + */ + protected function getAddFieldsToResponseSuccessTestData() + { + $requestFields = [ + 'field-1' => 'field-value-1', + 'field-2' => 'field-value-2', + 'field-3' => 'field-value-3', + ]; + $secure = 'test-currently-secure'; + $controllerName = 'test-controller-name'; + $incrementId = '0000000001'; + $paymentCode = 'test-payment-code'; + + return [ + 'order.getId' => 77, + 'orderPayment.getMethod' => $paymentCode, + 'payment.getCode' => $paymentCode, + 'observer.getData' => [ + ['action', null, $this->actionMock], + ['result', null, $this->resultMock], + ], + 'result.getData' => [ + 'error' => false + ], + 'order.getIncrementId' => $incrementId, + 'session.addCheckoutOrderIncrementId' => $incrementId, + 'session.setLastOrderIncrementId' => $incrementId, + 'request.getControllerName' => $controllerName, + 'requestToAuthorizenet.setControllerActionName' => $controllerName, + 'store.isCurrentlySecure' => $secure, + 'requestToAuthorizenet.setIsSecure' => $secure, + 'requestToAuthorizenet.getData' => $requestFields, + 'result.setData' => [ + 'error' => false, + 'test-payment-code' => [ + 'fields' => $requestFields + ] + ] + ]; + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php new file mode 100644 index 0000000000000..0ea5132fbe47d --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php @@ -0,0 +1,49 @@ +requestMock = $this->getMock('Magento\Authorizenet\Model\Directpost\Request', [], [], '', false); + + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Authorizenet\Model\Directpost\Request', []) + ->willReturn($this->requestMock); + + $this->requestFactory = $objectManager->getObject( + 'Magento\Authorizenet\Model\Directpost\Request\Factory', + ['objectManager' => $this->objectManagerMock] + ); + } + + public function testCreate() + { + $this->assertSame($this->requestMock, $this->requestFactory->create()); + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php new file mode 100644 index 0000000000000..82f05c5cd12f1 --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php @@ -0,0 +1,49 @@ +responseMock = $this->getMock('Magento\Authorizenet\Model\Directpost\Response', [], [], '', false); + + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Authorizenet\Model\Directpost\Response', []) + ->willReturn($this->responseMock); + + $this->responseFactory = $objectManager->getObject( + 'Magento\Authorizenet\Model\Directpost\Response\Factory', + ['objectManager' => $this->objectManagerMock] + ); + } + + public function testCreate() + { + $this->assertSame($this->responseMock, $this->responseFactory->create()); + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php new file mode 100644 index 0000000000000..bca5ff480a61b --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php @@ -0,0 +1,130 @@ +responseModel = $objectManager->getObject('Magento\Authorizenet\Model\Directpost\Response'); + } + + /** + * @param string $merchantMd5 + * @param string $merchantApiLogin + * @param float|null $amount + * @param float|string $amountTestFunc + * @param string $transactionId + * @dataProvider generateHashDataProvider + */ + public function testGenerateHash($merchantMd5, $merchantApiLogin, $amount, $amountTestFunc, $transactionId) + { + $this->assertEquals( + $this->generateHash($merchantMd5, $merchantApiLogin, $amountTestFunc, $transactionId), + $this->responseModel->generateHash($merchantMd5, $merchantApiLogin, $amount, $transactionId) + ); + } + + public function generateHashDataProvider() + { + return [ + [ + 'merchantMd5' => 'FCD7F001E9274FDEFB14BFF91C799306', + 'merchantApiLogin' => 'Magento', + 'amount' => null, + 'amountTestFunc' => '0.00', + 'transactionId' => '1' + ], + [ + 'merchantMd5' => '8AEF4E508261A287C3E2F544720FCA3A', + 'merchantApiLogin' => 'Magento2', + 'amount' => 100.50, + 'amountTestFunc' => 100.50, + 'transactionId' => '2' + ] + ]; + } + + protected function generateHash($merchantMd5, $merchantApiLogin, $amount, $transactionId) + { + return strtoupper(md5($merchantMd5 . $merchantApiLogin . $transactionId . $amount)); + } + + /** + * @param string $merchantMd5 + * @param string $merchantApiLogin + * @param float|null $amount + * @param string $transactionId + * @param string $hash + * @param bool $expectedValue + * @dataProvider isValidHashDataProvider + */ + public function testIsValidHash($merchantMd5, $merchantApiLogin, $amount, $transactionId, $hash, $expectedValue) + { + $this->responseModel->setXAmount($amount); + $this->responseModel->setXTransId($transactionId); + $this->responseModel->setData('x_MD5_Hash', $hash); + $this->assertEquals($expectedValue, $this->responseModel->isValidHash($merchantMd5, $merchantApiLogin)); + } + + /** + * @return array + */ + public function isValidHashDataProvider() + { + return [ + [ + 'merchantMd5' => 'FCD7F001E9274FDEFB14BFF91C799306', + 'merchantApiLogin' => 'Magento', + 'amount' => null, + 'transactionId' => '1', + 'hash' => '1F24A4EC9A169B2B2A072A5F168E16DC', + 'expectedValue' => true + ], + [ + 'merchantMd5' => '8AEF4E508261A287C3E2F544720FCA3A', + 'merchantApiLogin' => 'Magento2', + 'amount' => 100.50, + 'transactionId' => '2', + 'hash' => '1F24A4EC9A169B2B2A072A5F168E16DC', + 'expectedValue' => false + ] + ]; + } + + /** + * @param int $xResponseCode + * @param bool $expectedValue + * @dataProvider isApprovedDataProvider + */ + public function testIsApproved($xResponseCode, $expectedValue) + { + $this->responseModel->setXResponseCode($xResponseCode); + $this->assertSame($expectedValue, $this->responseModel->isApproved()); + } + + /** + * @return array + */ + public function isApprovedDataProvider() + { + return [ + [Directpost::RESPONSE_CODE_APPROVED, true], + [Directpost::RESPONSE_CODE_DECLINED, false], + [Directpost::RESPONSE_CODE_ERROR, false], + [Directpost::RESPONSE_CODE_HELD, false], + ]; + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php new file mode 100644 index 0000000000000..edfade031c792 --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php @@ -0,0 +1,360 @@ +scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->getMock(); + $this->paymentMock = $this->getMockBuilder('Magento\Payment\Model\InfoInterface') + ->getMock(); + $this->dataHelperMock = $this->getMockBuilder('Magento\Authorizenet\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + $this->responseFactoryMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Response\Factory') + ->disableOriginalConstructor() + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Response') + ->setMethods( + [ + 'setData', 'isValidHash', 'getXTransId', + 'getXResponseCode', 'getXResponseReasonText', + 'getXAmount' + ] + ) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->responseMock); + + $helper = new ObjectManagerHelper($this); + $this->directpost = $helper->getObject( + 'Magento\Authorizenet\Model\Directpost', + [ + 'scopeConfig' => $this->scopeConfigMock, + 'dataHelper' => $this->dataHelperMock, + 'responseFactory' => $this->responseFactoryMock + ] + ); + } + + public function testGetConfigInterface() + { + $this->assertInstanceOf( + 'Magento\Payment\Model\Method\ConfigInterface', + $this->directpost->getConfigInterface() + ); + } + + public function testGetConfigValue() + { + $field = 'some_field'; + $returnValue = 'expected'; + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with('payment/authorizenet_directpost/' . $field) + ->willReturn($returnValue); + $this->assertEquals($returnValue, $this->directpost->getValue($field)); + } + + public function testSetDataHelper() + { + $storeId = 'store-id'; + $expectedResult = 'relay-url'; + + $helperDataMock = $this->getMockBuilder('Magento\Authorizenet\Helper\Backend\Data') + ->disableOriginalConstructor() + ->getMock(); + + $helperDataMock->expects($this->once()) + ->method('getRelayUrl') + ->with($storeId) + ->willReturn($expectedResult); + + $this->directpost->setDataHelper($helperDataMock); + $this->assertEquals($expectedResult, $this->directpost->getRelayUrl($storeId)); + } + + public function testAuthorize() + { + $paymentAction = 'some_action'; + + $this->scopeConfigMock->expects($this->any()) + ->method('getValue') + ->with('payment/authorizenet_directpost/payment_action', 'store', null) + ->willReturn($paymentAction); + $this->paymentMock->expects($this->once()) + ->method('setAdditionalInformation') + ->with('payment_type', $paymentAction); + + $this->directpost->authorize($this->paymentMock, 10); + } + + public function testGetCgiUrl() + { + $url = 'cgi/url'; + + $this->scopeConfigMock->expects($this->any()) + ->method('getValue') + ->with('payment/authorizenet_directpost/cgi_url', 'store', null) + ->willReturn($url); + + $this->assertEquals($url, $this->directpost->getCgiUrl()); + } + + public function testGetCgiUrlWithEmptyConfigValue() + { + $this->scopeConfigMock->expects($this->any()) + ->method('getValue') + ->with('payment/authorizenet_directpost/cgi_url', 'store', null) + ->willReturn(null); + + $this->assertEquals(Directpost::CGI_URL, $this->directpost->getCgiUrl()); + } + + public function testGetRelayUrl() + { + $storeId = 100; + $url = 'relay/url'; + $this->directpost->setData('store', $storeId); + + $this->dataHelperMock->expects($this->any()) + ->method('getRelayUrl') + ->with($storeId) + ->willReturn($url); + + $this->assertEquals($url, $this->directpost->getRelayUrl()); + $this->assertEquals($url, $this->directpost->getRelayUrl($storeId)); + } + + public function testGetResponse() + { + $this->assertSame($this->responseMock, $this->directpost->getResponse()); + } + + public function testSetResponseData() + { + $data = [ + 'key' => 'value' + ]; + + $this->responseMock->expects($this->once()) + ->method('setData') + ->with($data) + ->willReturnSelf(); + + $this->assertSame($this->directpost, $this->directpost->setResponseData($data)); + } + + public function testValidateResponseSuccess() + { + $this->prepareTestValidateResponse('some_md5', 'login', true); + $this->assertEquals(true, $this->directpost->validateResponse()); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testValidateResponseFailure() + { + $this->prepareTestValidateResponse('some_md5', 'login', false); + $this->directpost->validateResponse(); + } + + /** + * @param string $transMd5 + * @param string $login + * @param bool $isValidHash + */ + protected function prepareTestValidateResponse($transMd5, $login, $isValidHash) + { + $this->scopeConfigMock->expects($this->any()) + ->method('getValue') + ->willReturnMap( + [ + ['payment/authorizenet_directpost/trans_md5', 'store', null, $transMd5], + ['payment/authorizenet_directpost/login', 'store', null, $login] + ] + ); + $this->responseMock->expects($this->any()) + ->method('isValidHash') + ->with($transMd5, $login) + ->willReturn($isValidHash); + } + + public function testCheckTransIdSuccess() + { + $this->responseMock->expects($this->once()) + ->method('getXTransId') + ->willReturn('111'); + + $this->assertEquals(true, $this->directpost->checkTransId()); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testCheckTransIdFailure() + { + $this->responseMock->expects($this->once()) + ->method('getXTransId') + ->willReturn(null); + + $this->directpost->checkTransId(); + } + + /** + * @param bool $responseCode + * + * @dataProvider checkResponseCodeSuccessDataProvider + */ + public function testCheckResponseCodeSuccess($responseCode) + { + $this->responseMock->expects($this->once()) + ->method('getXResponseCode') + ->willReturn($responseCode); + + $this->assertEquals(true, $this->directpost->checkResponseCode()); + } + + /** + * @return array + */ + public function checkResponseCodeSuccessDataProvider() + { + return [ + ['responseCode' => Directpost::RESPONSE_CODE_APPROVED], + ['responseCode' => Directpost::RESPONSE_CODE_HELD] + ]; + } + + /** + * @param bool $responseCode + * + * @expectedException \Magento\Framework\Exception\LocalizedException + * @dataProvider checkResponseCodeFailureDataProvider + */ + public function testCheckResponseCodeFailure($responseCode) + { + $reasonText = 'reason text'; + + $this->responseMock->expects($this->once()) + ->method('getXResponseCode') + ->willReturn($responseCode); + $this->responseMock->expects($this->any()) + ->method('getXResponseReasonText') + ->willReturn($reasonText); + $this->dataHelperMock->expects($this->any()) + ->method('wrapGatewayError') + ->with($reasonText) + ->willReturn(__('Gateway error: ' . $reasonText)); + + $this->directpost->checkResponseCode(); + } + + /** + * @return array + */ + public function checkResponseCodeFailureDataProvider() + { + return [ + ['responseCode' => Directpost::RESPONSE_CODE_DECLINED], + ['responseCode' => Directpost::RESPONSE_CODE_ERROR], + ['responseCode' => 999999] + ]; + } + + /** + * @param bool $isInitializeNeeded + * + * @dataProvider setIsInitializeNeededDataProvider + */ + public function testSetIsInitializeNeeded($isInitializeNeeded) + { + $this->directpost->setIsInitializeNeeded($isInitializeNeeded); + $this->assertEquals($isInitializeNeeded, $this->directpost->isInitializeNeeded()); + } + + /** + * @return array + */ + public function setIsInitializeNeededDataProvider() + { + return [ + ['isInitializationNeeded' => true], + ['isInitializationNeeded' => false] + ]; + } + + /** + * @param bool $isGatewayActionsLocked + * @param bool $canCapture + * + * @dataProvider canCaptureDataProvider + */ + public function testCanCapture($isGatewayActionsLocked, $canCapture) + { + $this->directpost->setData('info_instance', $this->paymentMock); + + $this->paymentMock->expects($this->any()) + ->method('getAdditionalInformation') + ->with(Directpost::GATEWAY_ACTIONS_LOCKED_STATE_KEY) + ->willReturn($isGatewayActionsLocked); + + $this->assertEquals($canCapture, $this->directpost->canCapture()); + } + + /** + * @return array + */ + public function canCaptureDataProvider() + { + return [ + ['isGatewayActionsLocked' => false, 'canCapture' => true], + ['isGatewayActionsLocked' => true, 'canCapture' => false] + ]; + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php new file mode 100644 index 0000000000000..42bd4922cd6cc --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php @@ -0,0 +1,49 @@ +requestMock = $this->getMock('Magento\Authorizenet\Model\Request', [], [], '', false); + + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Authorizenet\Model\Request', []) + ->willReturn($this->requestMock); + + $this->requestFactory = $objectManager->getObject( + 'Magento\Authorizenet\Model\Request\Factory', + ['objectManager' => $this->objectManagerMock] + ); + } + + public function testCreate() + { + $this->assertSame($this->requestMock, $this->requestFactory->create()); + } +} diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php new file mode 100644 index 0000000000000..a8d9a628a8e5d --- /dev/null +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php @@ -0,0 +1,49 @@ +responseMock = $this->getMock('Magento\Authorizenet\Model\Response', [], [], '', false); + + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Authorizenet\Model\Response', []) + ->willReturn($this->responseMock); + + $this->responseFactory = $objectManager->getObject( + 'Magento\Authorizenet\Model\Response\Factory', + ['objectManager' => $this->objectManagerMock] + ); + } + + public function testCreate() + { + $this->assertSame($this->responseMock, $this->responseFactory->create()); + } +} diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json new file mode 100644 index 0000000000000..436abe3fc7bfe --- /dev/null +++ b/app/code/Magento/Authorizenet/composer.json @@ -0,0 +1,29 @@ +{ + "name": "magento/module-authorizenet", + "description": "N/A", + "require": { + "php": "~5.5.0|~5.6.0", + "magento/module-sales": "0.74.0-beta16", + "magento/module-store": "0.74.0-beta16", + "magento/module-quote": "0.74.0-beta16", + "magento/module-checkout": "0.74.0-beta16", + "magento/module-backend": "0.74.0-beta16", + "magento/module-payment": "0.74.0-beta16", + "magento/module-catalog": "0.74.0-beta16", + "magento/framework": "0.74.0-beta16", + "magento/magento-composer-installer": "*" + }, + "type": "magento2-module", + "version": "0.74.0-beta16", + "license": [ + "proprietary" + ], + "extra": { + "map": [ + [ + "*", + "Magento/Authorizenet" + ] + ] + } +} diff --git a/app/code/Magento/Authorizenet/etc/adminhtml/di.xml b/app/code/Magento/Authorizenet/etc/adminhtml/di.xml new file mode 100644 index 0000000000000..cad68b99f6da8 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/adminhtml/di.xml @@ -0,0 +1,22 @@ + + + + + + Magento\Backend\Model\Session\Quote + + Magento\Payment\Block\Adminhtml\Transparent\Form + + + + + + Magento\Backend\Model\Session\Quote + + + diff --git a/app/code/Magento/Authorizenet/etc/adminhtml/events.xml b/app/code/Magento/Authorizenet/etc/adminhtml/events.xml new file mode 100644 index 0000000000000..aefa02b36e377 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/adminhtml/events.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/app/code/Magento/Authorizenet/etc/adminhtml/routes.xml b/app/code/Magento/Authorizenet/etc/adminhtml/routes.xml new file mode 100644 index 0000000000000..a1d23a80590ac --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/adminhtml/routes.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/app/code/Magento/Authorizenet/etc/adminhtml/system.xml b/app/code/Magento/Authorizenet/etc/adminhtml/system.xml new file mode 100644 index 0000000000000..591d0951e2d45 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/adminhtml/system.xml @@ -0,0 +1,92 @@ + + + + +
+ + + + + Magento\Config\Model\Config\Source\Yesno + + + + Magento\Authorizenet\Model\Source\PaymentAction + + + + + + + Magento\Config\Model\Config\Backend\Encrypted + + + + Magento\Config\Model\Config\Backend\Encrypted + + + + Magento\Config\Model\Config\Backend\Encrypted + + + + Magento\Sales\Model\Config\Source\Order\Status\Processing + + + + Magento\Config\Model\Config\Source\Yesno + + + + + + + Magento\Config\Model\Config\Source\Locale\Currency + + + + Magento\Config\Model\Config\Source\Yesno + + + + Magento\Config\Model\Config\Source\Yesno + + + + validate-email + + + + Magento\Authorizenet\Model\Source\Cctype + + + + Magento\Config\Model\Config\Source\Yesno + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + + + + Magento\Directory\Model\Config\Source\Country + + + + + + + + + + validate-number + + +
+
+
diff --git a/app/code/Magento/Authorizenet/etc/config.xml b/app/code/Magento/Authorizenet/etc/config.xml new file mode 100644 index 0000000000000..a620f157b10e4 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/config.xml @@ -0,0 +1,36 @@ + + + + + + + 0 + AE,VI,MC,DI + 0 + 0 + + + Magento\Authorizenet\Model\Directpost + processing + authorize + 1 + Credit Card Direct Post (Authorize.net) + + + 0 + USD + 1 + / + x_card_code,x_exp_date,x_card_num + authorizenet/directpost_payment/place + https://test.authorize.net/gateway/transact.dll + https://secure.authorize.net/gateway/transact.dll + + + + diff --git a/app/code/Magento/Authorizenet/etc/di.xml b/app/code/Magento/Authorizenet/etc/di.xml new file mode 100644 index 0000000000000..837239dd6eb91 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/di.xml @@ -0,0 +1,25 @@ + + + + + + Magento\Authorizenet\Helper\Data\Proxy + Magento\Framework\Json\Helper\Data\Proxy + + + + + authorizenet_directpost + + + + + Magento\Authorizenet\Model\Directpost\Session\Storage + + + diff --git a/app/code/Magento/Authorizenet/etc/frontend/di.xml b/app/code/Magento/Authorizenet/etc/frontend/di.xml new file mode 100644 index 0000000000000..516ecb1d6b8c0 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/frontend/di.xml @@ -0,0 +1,46 @@ + + + + + + Magento\Checkout\Model\Session + + + + + + /authorizenet/ + + + + + + Magento\Checkout\Model\Session + + + + + + Magento\Authorizenet\Model\Directpost::METHOD_CODE + + + + + + Magento\Authorizenet\Model\Directpost::METHOD_CODE + + + + + + AuthorizenetCcConfigProvider + DirectpostIframeCcConfigProvider + + + + diff --git a/app/code/Magento/Authorizenet/etc/frontend/events.xml b/app/code/Magento/Authorizenet/etc/frontend/events.xml new file mode 100644 index 0000000000000..948668c6584e2 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/frontend/events.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/app/code/Magento/Authorizenet/etc/frontend/page_types.xml b/app/code/Magento/Authorizenet/etc/frontend/page_types.xml new file mode 100644 index 0000000000000..dafa9fe416ee0 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/frontend/page_types.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/code/Magento/Authorizenet/etc/frontend/routes.xml b/app/code/Magento/Authorizenet/etc/frontend/routes.xml new file mode 100644 index 0000000000000..d9ebbfadff201 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/frontend/routes.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Authorizenet/etc/module.xml b/app/code/Magento/Authorizenet/etc/module.xml new file mode 100644 index 0000000000000..229118564b3f8 --- /dev/null +++ b/app/code/Magento/Authorizenet/etc/module.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/app/code/Magento/Authorizenet/i18n/de_DE.csv b/app/code/Magento/Authorizenet/i18n/de_DE.csv new file mode 100644 index 0000000000000..be595a6db0140 --- /dev/null +++ b/app/code/Magento/Authorizenet/i18n/de_DE.csv @@ -0,0 +1,100 @@ +Cancel,Abbrechen +"You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding.","You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding." +"Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way.","Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way." +"We canceled your payment and released any money we were holding.","We canceled your payment and released any money we were holding." +"You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction.","You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction." +"Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents.","Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents." +"Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.","Sind Sie sicher, dass Sie die Zahlung abbrechen möchten? Klicken Sie auf OK, um Ihre Zahlung abzubrechen und den Betrag wieder frei verfügbar zu machen. Klicken Sie auf Abbrechen, um eine andere Kreditkarte anzugeben und mit der Zahlung fortzufahren." +"Processed Amount","Bearbeiteter Betrag" +"Remaining Balance","Verbleibender Betrag" +"Order saving error: %1","Order saving error: %1" +"Please choose a payment method.","Please choose a payment method." +"You created the order.","You created the order." +"Something went wrong canceling the transactions.","Something went wrong canceling the transactions." +"There was an error canceling transactions. Please contact us or try again later.","Es ist ein Fehler beim Abbruch der Transaktion aufgetreten. Bitte kontaktieren Sie uns oder probieren Sie es später noch einmal." +"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later." +"amount %1","amount %1" +failed,fehlgeschlagen +successful,erfolgreich +"Credit Card: xxxx-%1","Credit Card: xxxx-%1" +"Authorize.Net Transaction ID %1","Authorize.Net Transaction ID %1" +authorize,Autorisieren +"authorize and capture","Autorisieren und Erfassen" +capture,Erfassen +refund,Rückerstattung +void,ungültig +"This is an invalid amount for authorization.","This is an invalid amount for authorization." +"This is an invalid amount for capture.","This is an invalid amount for capture." +"This is an invalid amount for refund.","This is an invalid amount for refund." +"This is an invalid split tenderId ID.","This is an invalid split tenderId ID." +"Something went wrong while canceling the payment.","Something went wrong while canceling the payment." +"Something went wrong while authorizing the payment.","Something went wrong while authorizing the payment." +"Something went wrong while capturing the payment.","Something went wrong while capturing the payment." +"The shopping cart contents and/or address has been changed.","The shopping cart contents and/or address has been changed." +"This is an invalid amount for partial authorization.","This is an invalid amount for partial authorization." +"Parent Authorize.Net transaction (ID %1) expired","Parent Authorize.Net transaction (ID %1) expired" +"Something went wrong while voiding the payment.","Something went wrong while voiding the payment." +"Something went wrong while refunding the payment.","Something went wrong while refunding the payment." +"You have reached the maximum number of credit cards ' 'allowed to be used for the payment.","You have reached the maximum number of credit cards ' 'allowed to be used for the payment." +"Something went wrong while authorizing the partial payment.","Something went wrong while authorizing the partial payment." +"Something went wrong in the payment gateway.","Something went wrong in the payment gateway." +"Gateway error: %1","Gateway error: %1" +"Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s).","Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s)." +"Payment updating error.","Fehler beim Zahlungsupdate." +"Authorize Only","Nur genehmigen" +"Authorize and Capture","Genehmigen und erfassen" +"Invalid amount for capture.","Ungültiger Betrag für die Erfassung." +"Payment capturing error.","Fehler bei Zahlungserfassung." +"Invalid transaction ID.","Invalid transaction ID." +"Payment voiding error.","Fehler beim Stornieren der Zahlung." +"Invalid amount for refund.","Ungültiger Betrag für eine Rückerstattung." +"Payment refunding error.","Fehler bei der Rückerstattung." +"The transaction was declined because the response hash validation failed.","The transaction was declined because the response hash validation failed." +"This payment didn't work out because we can't find this order.","This payment didn't work out because we can't find this order." +"There was a payment authorization error.","There was a payment authorization error." +"This payment was not authorized because the transaction ID field is empty.","This payment was not authorized because the transaction ID field is empty." +"Amount of %1 approved by payment gateway. Transaction ID: ""%2"".","Amount of %1 approved by payment gateway. Transaction ID: ""%2""." +"Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again.","Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again." +"Credit Card Type",Kreditkartentyp +"Credit Card Number",Kreditkartennummer +"Expiration Date",Ablaufdatum +"Card Verification Number",Kreditkartenprüfnummer +"Click ""Cancel"" to remove any pending status and release money already processed during this payment.","Click ""Cancel"" to remove any pending status and release money already processed during this payment." +"Please enter a different credit card number to complete your purchase.","Please enter a different credit card number to complete your purchase." +"Credit Card %1","Credit Card %1" +"Credit Card Information",Kreditkarteninformationen +"--Please Select--","--Bitte wählen--" +"Card Verification Number Visual Reference","Kartenprüfnummer Sichtmerkmale" +"What is this?","Was ist das?" +"You'll be asked for your payment details before placing an order.","You'll be asked for your payment details before placing an order." +"To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel.","To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel." +Processing...,Processing... +Enabled,Enabled +"Sort Order","Sort Order" +Title,Title +"3D Secure Card Validation","3D Secure Card Validation" +"New Order Status","New Order Status" +"No confirmation","No confirmation" +Authorize.net,Authorize.net +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Email Customer","Email Customer" +"API Login ID","API Login ID" +"Merchant's Email","Merchant's Email" +"Test Mode","Test Mode" +Debug,Debug +"Transaction Key","Transaction Key" +"Payment Action","Payment Action" +"Accepted Currency","Accepted Currency" +"Payment from Applicable Countries","Payment from Applicable Countries" +"Payment from Specific Countries","Payment from Specific Countries" +"Minimum Order Total","Minimum Order Total" +"Maximum Order Total","Maximum Order Total" +"Allow Partial Authorization","Allow Partial Authorization" +"3D Secure","3D Secure" +"Severe 3D Secure Card Validation","Severe 3D Secure Card Validation" +"Severe Validation Removes Chargeback Liability on Merchant","Severe Validation Removes Chargeback Liability on Merchant" +"If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement.","If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement." +"Authorize.net Direct Post","Authorize.net Direct Post" +"Merchant MD5","Merchant MD5" +"Gateway URL","Gateway URL" diff --git a/app/code/Magento/Authorizenet/i18n/en_US.csv b/app/code/Magento/Authorizenet/i18n/en_US.csv new file mode 100644 index 0000000000000..7bbbbaf286d5a --- /dev/null +++ b/app/code/Magento/Authorizenet/i18n/en_US.csv @@ -0,0 +1,100 @@ +Cancel,Cancel +"You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding.","You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding." +"Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way.","Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way." +"We canceled your payment and released any money we were holding.","We canceled your payment and released any money we were holding." +"You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction.","You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction." +"Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents.","Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents." +"Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.","Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment." +"Processed Amount","Processed Amount" +"Remaining Balance","Remaining Balance" +"Order saving error: %1","Order saving error: %1" +"Please choose a payment method.","Please choose a payment method." +"You created the order.","You created the order." +"Something went wrong canceling the transactions.","Something went wrong canceling the transactions." +"There was an error canceling transactions. Please contact us or try again later.","There was an error canceling transactions. Please contact us or try again later." +"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later." +"amount %1","amount %1" +failed,failed +successful,successful +"Credit Card: xxxx-%1","Credit Card: xxxx-%1" +"Authorize.Net Transaction ID %1","Authorize.Net Transaction ID %1" +authorize,authorize +"authorize and capture","authorize and capture" +capture,capture +refund,refund +void,void +"This is an invalid amount for authorization.","This is an invalid amount for authorization." +"This is an invalid amount for capture.","This is an invalid amount for capture." +"This is an invalid amount for refund.","This is an invalid amount for refund." +"This is an invalid split tenderId ID.","This is an invalid split tenderId ID." +"Something went wrong while canceling the payment.","Something went wrong while canceling the payment." +"Something went wrong while authorizing the payment.","Something went wrong while authorizing the payment." +"Something went wrong while capturing the payment.","Something went wrong while capturing the payment." +"The shopping cart contents and/or address has been changed.","The shopping cart contents and/or address has been changed." +"This is an invalid amount for partial authorization.","This is an invalid amount for partial authorization." +"Parent Authorize.Net transaction (ID %1) expired","Parent Authorize.Net transaction (ID %1) expired" +"Something went wrong while voiding the payment.","Something went wrong while voiding the payment." +"Something went wrong while refunding the payment.","Something went wrong while refunding the payment." +"You have reached the maximum number of credit cards ' 'allowed to be used for the payment.","You have reached the maximum number of credit cards ' 'allowed to be used for the payment." +"Something went wrong while authorizing the partial payment.","Something went wrong while authorizing the partial payment." +"Something went wrong in the payment gateway.","Something went wrong in the payment gateway." +"Gateway error: %1","Gateway error: %1" +"Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s).","Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s)." +"Payment updating error.","Payment updating error." +"Authorize Only","Authorize Only" +"Authorize and Capture","Authorize and Capture" +"Invalid amount for capture.","Invalid amount for capture." +"Payment capturing error.","Payment capturing error." +"Invalid transaction ID.","Invalid transaction ID." +"Payment voiding error.","Payment voiding error." +"Invalid amount for refund.","Invalid amount for refund." +"Payment refunding error.","Payment refunding error." +"The transaction was declined because the response hash validation failed.","The transaction was declined because the response hash validation failed." +"This payment didn't work out because we can't find this order.","This payment didn't work out because we can't find this order." +"There was a payment authorization error.","There was a payment authorization error." +"This payment was not authorized because the transaction ID field is empty.","This payment was not authorized because the transaction ID field is empty." +"Amount of %1 approved by payment gateway. Transaction ID: ""%2"".","Amount of %1 approved by payment gateway. Transaction ID: ""%2""." +"Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again.","Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again." +"Credit Card Type","Credit Card Type" +"Credit Card Number","Credit Card Number" +"Expiration Date","Expiration Date" +"Card Verification Number","Card Verification Number" +"Click ""Cancel"" to remove any pending status and release money already processed during this payment.","Click ""Cancel"" to remove any pending status and release money already processed during this payment." +"Please enter a different credit card number to complete your purchase.","Please enter a different credit card number to complete your purchase." +"Credit Card %1","Credit Card %1" +"Credit Card Information","Credit Card Information" +"--Please Select--","--Please Select--" +"Card Verification Number Visual Reference","Card Verification Number Visual Reference" +"What is this?","What is this?" +"You'll be asked for your payment details before placing an order.","You'll be asked for your payment details before placing an order." +"To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel.","To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel." +Processing...,Processing... +Enabled,Enabled +"Sort Order","Sort Order" +Title,Title +"3D Secure Card Validation","3D Secure Card Validation" +"New Order Status","New Order Status" +"No confirmation","No confirmation" +Authorize.net,Authorize.net +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Email Customer","Email Customer" +"API Login ID","API Login ID" +"Merchant's Email","Merchant's Email" +"Test Mode","Test Mode" +Debug,Debug +"Transaction Key","Transaction Key" +"Payment Action","Payment Action" +"Accepted Currency","Accepted Currency" +"Payment from Applicable Countries","Payment from Applicable Countries" +"Payment from Specific Countries","Payment from Specific Countries" +"Minimum Order Total","Minimum Order Total" +"Maximum Order Total","Maximum Order Total" +"Allow Partial Authorization","Allow Partial Authorization" +"3D Secure","3D Secure" +"Severe 3D Secure Card Validation","Severe 3D Secure Card Validation" +"Severe Validation Removes Chargeback Liability on Merchant","Severe Validation Removes Chargeback Liability on Merchant" +"If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement.","If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement." +"Authorize.net Direct Post","Authorize.net Direct Post" +"Merchant MD5","Merchant MD5" +"Gateway URL","Gateway URL" diff --git a/app/code/Magento/Authorizenet/i18n/es_ES.csv b/app/code/Magento/Authorizenet/i18n/es_ES.csv new file mode 100644 index 0000000000000..e3f894d4c7544 --- /dev/null +++ b/app/code/Magento/Authorizenet/i18n/es_ES.csv @@ -0,0 +1,100 @@ +Cancel,Cancelar +"You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding.","You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding." +"Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way.","Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way." +"We canceled your payment and released any money we were holding.","We canceled your payment and released any money we were holding." +"You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction.","You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction." +"Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents.","Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents." +"Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.","¿Está seguro de que desea cancelar su pago? Pinche en Aceptar para cancelar el pago y liberar la cantidad retenida. Pinche en ""Cancelar"" para introducir otra tarjeta de crédito y continuar con su pago." +"Processed Amount","Cantidad Procesada" +"Remaining Balance","Saldo Restante" +"Order saving error: %1","Order saving error: %1" +"Please choose a payment method.","Please choose a payment method." +"You created the order.","You created the order." +"Something went wrong canceling the transactions.","Something went wrong canceling the transactions." +"There was an error canceling transactions. Please contact us or try again later.","Ha habido un error en la cancelación de las transacciones. Por favor, póngase en contacto con nosotros o inténtelo más tarde de nuevo." +"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later." +"amount %1","amount %1" +failed,error +successful,exitoso +"Credit Card: xxxx-%1","Credit Card: xxxx-%1" +"Authorize.Net Transaction ID %1","Authorize.Net Transaction ID %1" +authorize,autorizar +"authorize and capture","autorizar y capturar" +capture,capturar +refund,reembolso +void,vacío +"This is an invalid amount for authorization.","This is an invalid amount for authorization." +"This is an invalid amount for capture.","This is an invalid amount for capture." +"This is an invalid amount for refund.","This is an invalid amount for refund." +"This is an invalid split tenderId ID.","This is an invalid split tenderId ID." +"Something went wrong while canceling the payment.","Something went wrong while canceling the payment." +"Something went wrong while authorizing the payment.","Something went wrong while authorizing the payment." +"Something went wrong while capturing the payment.","Something went wrong while capturing the payment." +"The shopping cart contents and/or address has been changed.","The shopping cart contents and/or address has been changed." +"This is an invalid amount for partial authorization.","This is an invalid amount for partial authorization." +"Parent Authorize.Net transaction (ID %1) expired","Parent Authorize.Net transaction (ID %1) expired" +"Something went wrong while voiding the payment.","Something went wrong while voiding the payment." +"Something went wrong while refunding the payment.","Something went wrong while refunding the payment." +"You have reached the maximum number of credit cards ' 'allowed to be used for the payment.","You have reached the maximum number of credit cards ' 'allowed to be used for the payment." +"Something went wrong while authorizing the partial payment.","Something went wrong while authorizing the partial payment." +"Something went wrong in the payment gateway.","Something went wrong in the payment gateway." +"Gateway error: %1","Gateway error: %1" +"Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s).","Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s)." +"Payment updating error.","Error de actualización del pago." +"Authorize Only","Sólo autorizar" +"Authorize and Capture","Autorizar y capturar" +"Invalid amount for capture.","Cantidad para retención no válida." +"Payment capturing error.","Error en el pago de retención." +"Invalid transaction ID.","Invalid transaction ID." +"Payment voiding error.","Error en la anulación del pago." +"Invalid amount for refund.","Cantidad de reembolso no válida." +"Payment refunding error.","Error en el pago de reembolso." +"The transaction was declined because the response hash validation failed.","The transaction was declined because the response hash validation failed." +"This payment didn't work out because we can't find this order.","This payment didn't work out because we can't find this order." +"There was a payment authorization error.","There was a payment authorization error." +"This payment was not authorized because the transaction ID field is empty.","This payment was not authorized because the transaction ID field is empty." +"Amount of %1 approved by payment gateway. Transaction ID: ""%2"".","Amount of %1 approved by payment gateway. Transaction ID: ""%2""." +"Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again.","Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again." +"Credit Card Type","Tipo de Tarjeta de Crédito" +"Credit Card Number","Número de Tarjeta de Crédito" +"Expiration Date","Fecha de Caducidad" +"Card Verification Number","Número de Verificación de Tarjeta" +"Click ""Cancel"" to remove any pending status and release money already processed during this payment.","Click ""Cancel"" to remove any pending status and release money already processed during this payment." +"Please enter a different credit card number to complete your purchase.","Please enter a different credit card number to complete your purchase." +"Credit Card %1","Credit Card %1" +"Credit Card Information","Información de la tarjeta de crédito" +"--Please Select--","--Por favor, seleccione-" +"Card Verification Number Visual Reference","Referencia visual del número de verificación de tarjeta" +"What is this?","¿Qué es esto?" +"You'll be asked for your payment details before placing an order.","You'll be asked for your payment details before placing an order." +"To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel.","To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel." +Processing...,Processing... +Enabled,Enabled +"Sort Order","Sort Order" +Title,Title +"3D Secure Card Validation","3D Secure Card Validation" +"New Order Status","New Order Status" +"No confirmation","No confirmation" +Authorize.net,Authorize.net +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Email Customer","Email Customer" +"API Login ID","API Login ID" +"Merchant's Email","Merchant's Email" +"Test Mode","Test Mode" +Debug,Debug +"Transaction Key","Transaction Key" +"Payment Action","Payment Action" +"Accepted Currency","Accepted Currency" +"Payment from Applicable Countries","Payment from Applicable Countries" +"Payment from Specific Countries","Payment from Specific Countries" +"Minimum Order Total","Minimum Order Total" +"Maximum Order Total","Maximum Order Total" +"Allow Partial Authorization","Allow Partial Authorization" +"3D Secure","3D Secure" +"Severe 3D Secure Card Validation","Severe 3D Secure Card Validation" +"Severe Validation Removes Chargeback Liability on Merchant","Severe Validation Removes Chargeback Liability on Merchant" +"If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement.","If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement." +"Authorize.net Direct Post","Authorize.net Direct Post" +"Merchant MD5","Merchant MD5" +"Gateway URL","Gateway URL" diff --git a/app/code/Magento/Authorizenet/i18n/fr_FR.csv b/app/code/Magento/Authorizenet/i18n/fr_FR.csv new file mode 100644 index 0000000000000..8c581352613ef --- /dev/null +++ b/app/code/Magento/Authorizenet/i18n/fr_FR.csv @@ -0,0 +1,100 @@ +Cancel,Annuler +"You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding.","You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding." +"Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way.","Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way." +"We canceled your payment and released any money we were holding.","We canceled your payment and released any money we were holding." +"You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction.","You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction." +"Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents.","Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents." +"Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.","Etes-vous sûr de vouloir annuler votre paiement ? Cliquez sur OK pour annuler le paiement et débloquer le montant en attente. Cliquez sur Quitter pour entrer une autre carte bancaire et continuer le paiemetn." +"Processed Amount","Montant réalisé" +"Remaining Balance","Balance restante" +"Order saving error: %1","Order saving error: %1" +"Please choose a payment method.","Please choose a payment method." +"You created the order.","You created the order." +"Something went wrong canceling the transactions.","Something went wrong canceling the transactions." +"There was an error canceling transactions. Please contact us or try again later.","Une erreur s'est produite lors de l'annulation de transactions. Veuillez nous contacter ou réessayer ultérieurement." +"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later." +"amount %1","amount %1" +failed,échoué +successful,réussi +"Credit Card: xxxx-%1","Credit Card: xxxx-%1" +"Authorize.Net Transaction ID %1","Authorize.Net Transaction ID %1" +authorize,autoriser +"authorize and capture","autoriser et saisir" +capture,saisir +refund,remboursement +void,vide +"This is an invalid amount for authorization.","This is an invalid amount for authorization." +"This is an invalid amount for capture.","This is an invalid amount for capture." +"This is an invalid amount for refund.","This is an invalid amount for refund." +"This is an invalid split tenderId ID.","This is an invalid split tenderId ID." +"Something went wrong while canceling the payment.","Something went wrong while canceling the payment." +"Something went wrong while authorizing the payment.","Something went wrong while authorizing the payment." +"Something went wrong while capturing the payment.","Something went wrong while capturing the payment." +"The shopping cart contents and/or address has been changed.","The shopping cart contents and/or address has been changed." +"This is an invalid amount for partial authorization.","This is an invalid amount for partial authorization." +"Parent Authorize.Net transaction (ID %1) expired","Parent Authorize.Net transaction (ID %1) expired" +"Something went wrong while voiding the payment.","Something went wrong while voiding the payment." +"Something went wrong while refunding the payment.","Something went wrong while refunding the payment." +"You have reached the maximum number of credit cards ' 'allowed to be used for the payment.","You have reached the maximum number of credit cards ' 'allowed to be used for the payment." +"Something went wrong while authorizing the partial payment.","Something went wrong while authorizing the partial payment." +"Something went wrong in the payment gateway.","Something went wrong in the payment gateway." +"Gateway error: %1","Gateway error: %1" +"Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s).","Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s)." +"Payment updating error.","Erreur lors de la mise à jour du paiement." +"Authorize Only","Autoriser uniquement" +"Authorize and Capture","Autoriser et enregistrer" +"Invalid amount for capture.","Montant invalide" +"Payment capturing error.","Erreur lors de la saisie du paiement" +"Invalid transaction ID.","Invalid transaction ID." +"Payment voiding error.","Erreur annulant le paiement" +"Invalid amount for refund.","Montant invalide pour un remboursement" +"Payment refunding error.","Erreur de remboursement du paiement" +"The transaction was declined because the response hash validation failed.","The transaction was declined because the response hash validation failed." +"This payment didn't work out because we can't find this order.","This payment didn't work out because we can't find this order." +"There was a payment authorization error.","There was a payment authorization error." +"This payment was not authorized because the transaction ID field is empty.","This payment was not authorized because the transaction ID field is empty." +"Amount of %1 approved by payment gateway. Transaction ID: ""%2"".","Amount of %1 approved by payment gateway. Transaction ID: ""%2""." +"Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again.","Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again." +"Credit Card Type","Type de carte de crédit" +"Credit Card Number","Numéro de carte de crédit" +"Expiration Date","Date d'expiration" +"Card Verification Number","Numéro de vérification de la carte" +"Click ""Cancel"" to remove any pending status and release money already processed during this payment.","Click ""Cancel"" to remove any pending status and release money already processed during this payment." +"Please enter a different credit card number to complete your purchase.","Please enter a different credit card number to complete your purchase." +"Credit Card %1","Credit Card %1" +"Credit Card Information","Renseignements sur la carte de crédit" +"--Please Select--","--Veuillez choisir--" +"Card Verification Number Visual Reference","Référence visuelle du numéro de vérification de la carte" +"What is this?","Qu'est-ce que c'est ?" +"You'll be asked for your payment details before placing an order.","You'll be asked for your payment details before placing an order." +"To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel.","To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel." +Processing...,Processing... +Enabled,Enabled +"Sort Order","Sort Order" +Title,Title +"3D Secure Card Validation","3D Secure Card Validation" +"New Order Status","New Order Status" +"No confirmation","No confirmation" +Authorize.net,Authorize.net +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Email Customer","Email Customer" +"API Login ID","API Login ID" +"Merchant's Email","Merchant's Email" +"Test Mode","Test Mode" +Debug,Debug +"Transaction Key","Transaction Key" +"Payment Action","Payment Action" +"Accepted Currency","Accepted Currency" +"Payment from Applicable Countries","Payment from Applicable Countries" +"Payment from Specific Countries","Payment from Specific Countries" +"Minimum Order Total","Minimum Order Total" +"Maximum Order Total","Maximum Order Total" +"Allow Partial Authorization","Allow Partial Authorization" +"3D Secure","3D Secure" +"Severe 3D Secure Card Validation","Severe 3D Secure Card Validation" +"Severe Validation Removes Chargeback Liability on Merchant","Severe Validation Removes Chargeback Liability on Merchant" +"If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement.","If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement." +"Authorize.net Direct Post","Authorize.net Direct Post" +"Merchant MD5","Merchant MD5" +"Gateway URL","Gateway URL" diff --git a/app/code/Magento/Authorizenet/i18n/nl_NL.csv b/app/code/Magento/Authorizenet/i18n/nl_NL.csv new file mode 100644 index 0000000000000..24f8616ddc922 --- /dev/null +++ b/app/code/Magento/Authorizenet/i18n/nl_NL.csv @@ -0,0 +1,100 @@ +Cancel,Annuleren +"You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding.","You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding." +"Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way.","Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way." +"We canceled your payment and released any money we were holding.","We canceled your payment and released any money we were holding." +"You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction.","You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction." +"Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents.","Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents." +"Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.","Weet u zeker dat u uw betaling wilt annuleren? Klik op OK om uw betaling te annuleren en het geld vrij te geven. Klik op Cancel om een andere kredietkaart te gebruiken en verder te gaan met uw betaling." +"Processed Amount","Verwerkte hoeveelheid" +"Remaining Balance","Resterend balans" +"Order saving error: %1","Order saving error: %1" +"Please choose a payment method.","Please choose a payment method." +"You created the order.","You created the order." +"Something went wrong canceling the transactions.","Something went wrong canceling the transactions." +"There was an error canceling transactions. Please contact us or try again later.","Er heeft zich een fout voorgedaan tijdens het annuleren van de transacties. Neem contact met ons op of probeer later." +"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later." +"amount %1","amount %1" +failed,mislukt +successful,succesvol +"Credit Card: xxxx-%1","Credit Card: xxxx-%1" +"Authorize.Net Transaction ID %1","Authorize.Net Transaction ID %1" +authorize,autoriseer +"authorize and capture","autoriseer en vang" +capture,vang +refund,teruggave +void,ongeldig +"This is an invalid amount for authorization.","This is an invalid amount for authorization." +"This is an invalid amount for capture.","This is an invalid amount for capture." +"This is an invalid amount for refund.","This is an invalid amount for refund." +"This is an invalid split tenderId ID.","This is an invalid split tenderId ID." +"Something went wrong while canceling the payment.","Something went wrong while canceling the payment." +"Something went wrong while authorizing the payment.","Something went wrong while authorizing the payment." +"Something went wrong while capturing the payment.","Something went wrong while capturing the payment." +"The shopping cart contents and/or address has been changed.","The shopping cart contents and/or address has been changed." +"This is an invalid amount for partial authorization.","This is an invalid amount for partial authorization." +"Parent Authorize.Net transaction (ID %1) expired","Parent Authorize.Net transaction (ID %1) expired" +"Something went wrong while voiding the payment.","Something went wrong while voiding the payment." +"Something went wrong while refunding the payment.","Something went wrong while refunding the payment." +"You have reached the maximum number of credit cards ' 'allowed to be used for the payment.","You have reached the maximum number of credit cards ' 'allowed to be used for the payment." +"Something went wrong while authorizing the partial payment.","Something went wrong while authorizing the partial payment." +"Something went wrong in the payment gateway.","Something went wrong in the payment gateway." +"Gateway error: %1","Gateway error: %1" +"Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s).","Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s)." +"Payment updating error.","Fout bij het bijwerken van de betaling." +"Authorize Only","Alleen authoriseren" +"Authorize and Capture","Authoriseren en opnemen" +"Invalid amount for capture.","Ongeldige aantal voor vangst." +"Payment capturing error.","Fout in het ophalen van de betaling." +"Invalid transaction ID.","Invalid transaction ID." +"Payment voiding error.","Fout in het vernietigen van de betaling." +"Invalid amount for refund.","Ongeldige aantal voor teruggave." +"Payment refunding error.","Fout in het terugbetalen van de betaling." +"The transaction was declined because the response hash validation failed.","The transaction was declined because the response hash validation failed." +"This payment didn't work out because we can't find this order.","This payment didn't work out because we can't find this order." +"There was a payment authorization error.","There was a payment authorization error." +"This payment was not authorized because the transaction ID field is empty.","This payment was not authorized because the transaction ID field is empty." +"Amount of %1 approved by payment gateway. Transaction ID: ""%2"".","Amount of %1 approved by payment gateway. Transaction ID: ""%2""." +"Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again.","Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again." +"Credit Card Type",Creditcardtype +"Credit Card Number",Creditcardnummer +"Expiration Date",vervaldatum +"Card Verification Number","Kaart verificatie nummer" +"Click ""Cancel"" to remove any pending status and release money already processed during this payment.","Click ""Cancel"" to remove any pending status and release money already processed during this payment." +"Please enter a different credit card number to complete your purchase.","Please enter a different credit card number to complete your purchase." +"Credit Card %1","Credit Card %1" +"Credit Card Information","Creditcard informatie" +"--Please Select--","--selecteer a.u.b.--" +"Card Verification Number Visual Reference","Kaart verificatie nummer visuele referentie" +"What is this?","Wat is dit?" +"You'll be asked for your payment details before placing an order.","You'll be asked for your payment details before placing an order." +"To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel.","To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel." +Processing...,Processing... +Enabled,Enabled +"Sort Order","Sort Order" +Title,Title +"3D Secure Card Validation","3D Secure Card Validation" +"New Order Status","New Order Status" +"No confirmation","No confirmation" +Authorize.net,Authorize.net +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Email Customer","Email Customer" +"API Login ID","API Login ID" +"Merchant's Email","Merchant's Email" +"Test Mode","Test Mode" +Debug,Debug +"Transaction Key","Transaction Key" +"Payment Action","Payment Action" +"Accepted Currency","Accepted Currency" +"Payment from Applicable Countries","Payment from Applicable Countries" +"Payment from Specific Countries","Payment from Specific Countries" +"Minimum Order Total","Minimum Order Total" +"Maximum Order Total","Maximum Order Total" +"Allow Partial Authorization","Allow Partial Authorization" +"3D Secure","3D Secure" +"Severe 3D Secure Card Validation","Severe 3D Secure Card Validation" +"Severe Validation Removes Chargeback Liability on Merchant","Severe Validation Removes Chargeback Liability on Merchant" +"If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement.","If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement." +"Authorize.net Direct Post","Authorize.net Direct Post" +"Merchant MD5","Merchant MD5" +"Gateway URL","Gateway URL" diff --git a/app/code/Magento/Authorizenet/i18n/pt_BR.csv b/app/code/Magento/Authorizenet/i18n/pt_BR.csv new file mode 100644 index 0000000000000..5aa07e625d2ad --- /dev/null +++ b/app/code/Magento/Authorizenet/i18n/pt_BR.csv @@ -0,0 +1,100 @@ +Cancel,Cancelar +"You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding.","You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding." +"Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way.","Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way." +"We canceled your payment and released any money we were holding.","We canceled your payment and released any money we were holding." +"You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction.","You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction." +"Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents.","Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents." +"Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.","Tem certeza de que deseja cancelar o seu pagamento? Clique em OK para cancelar o seu pagamento e liberar o montante em espera. Clique em Cancelar para inserir outro cartão de crédito e continuar com o seu pagamento." +"Processed Amount","Valor Processado" +"Remaining Balance","Balanço Restante" +"Order saving error: %1","Order saving error: %1" +"Please choose a payment method.","Please choose a payment method." +"You created the order.","You created the order." +"Something went wrong canceling the transactions.","Something went wrong canceling the transactions." +"There was an error canceling transactions. Please contact us or try again later.","Ocorreu um erro ao cancelar as transações. Por favor entre em contato conosco ou tente novamente mais tarde." +"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later." +"amount %1","amount %1" +failed,fracassado +successful,"bem sucedido" +"Credit Card: xxxx-%1","Credit Card: xxxx-%1" +"Authorize.Net Transaction ID %1","Authorize.Net Transaction ID %1" +authorize,autorizar +"authorize and capture","autorizar e capturar" +capture,capturar +refund,reembolso +void,vazio +"This is an invalid amount for authorization.","This is an invalid amount for authorization." +"This is an invalid amount for capture.","This is an invalid amount for capture." +"This is an invalid amount for refund.","This is an invalid amount for refund." +"This is an invalid split tenderId ID.","This is an invalid split tenderId ID." +"Something went wrong while canceling the payment.","Something went wrong while canceling the payment." +"Something went wrong while authorizing the payment.","Something went wrong while authorizing the payment." +"Something went wrong while capturing the payment.","Something went wrong while capturing the payment." +"The shopping cart contents and/or address has been changed.","The shopping cart contents and/or address has been changed." +"This is an invalid amount for partial authorization.","This is an invalid amount for partial authorization." +"Parent Authorize.Net transaction (ID %1) expired","Parent Authorize.Net transaction (ID %1) expired" +"Something went wrong while voiding the payment.","Something went wrong while voiding the payment." +"Something went wrong while refunding the payment.","Something went wrong while refunding the payment." +"You have reached the maximum number of credit cards ' 'allowed to be used for the payment.","You have reached the maximum number of credit cards ' 'allowed to be used for the payment." +"Something went wrong while authorizing the partial payment.","Something went wrong while authorizing the partial payment." +"Something went wrong in the payment gateway.","Something went wrong in the payment gateway." +"Gateway error: %1","Gateway error: %1" +"Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s).","Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s)." +"Payment updating error.","Erro de atualização de pagamento." +"Authorize Only","Somente Autorizar" +"Authorize and Capture","Autorizar e Controlar" +"Invalid amount for capture.","Valor inválido para captura." +"Payment capturing error.","Erro de captura de pagamento." +"Invalid transaction ID.","Invalid transaction ID." +"Payment voiding error.","Erro de anulamento de pagamento." +"Invalid amount for refund.","Valor inválido para reembolso." +"Payment refunding error.","Erro de reembolso de pagamento." +"The transaction was declined because the response hash validation failed.","The transaction was declined because the response hash validation failed." +"This payment didn't work out because we can't find this order.","This payment didn't work out because we can't find this order." +"There was a payment authorization error.","There was a payment authorization error." +"This payment was not authorized because the transaction ID field is empty.","This payment was not authorized because the transaction ID field is empty." +"Amount of %1 approved by payment gateway. Transaction ID: ""%2"".","Amount of %1 approved by payment gateway. Transaction ID: ""%2""." +"Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again.","Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again." +"Credit Card Type","Tipo de Cartão de Crédito" +"Credit Card Number","Número do Cartão de Crédito" +"Expiration Date","Data de Validade" +"Card Verification Number","Número de Verificação do Cartão" +"Click ""Cancel"" to remove any pending status and release money already processed during this payment.","Click ""Cancel"" to remove any pending status and release money already processed during this payment." +"Please enter a different credit card number to complete your purchase.","Please enter a different credit card number to complete your purchase." +"Credit Card %1","Credit Card %1" +"Credit Card Information","Informações do Cartão de Crédito" +"--Please Select--","--Por Favor, Escolha--" +"Card Verification Number Visual Reference","Referência Visual de Número de Verificação do Cartão" +"What is this?","O que é isso?" +"You'll be asked for your payment details before placing an order.","You'll be asked for your payment details before placing an order." +"To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel.","To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel." +Processing...,Processing... +Enabled,Enabled +"Sort Order","Sort Order" +Title,Title +"3D Secure Card Validation","3D Secure Card Validation" +"New Order Status","New Order Status" +"No confirmation","No confirmation" +Authorize.net,Authorize.net +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Email Customer","Email Customer" +"API Login ID","API Login ID" +"Merchant's Email","Merchant's Email" +"Test Mode","Test Mode" +Debug,Debug +"Transaction Key","Transaction Key" +"Payment Action","Payment Action" +"Accepted Currency","Accepted Currency" +"Payment from Applicable Countries","Payment from Applicable Countries" +"Payment from Specific Countries","Payment from Specific Countries" +"Minimum Order Total","Minimum Order Total" +"Maximum Order Total","Maximum Order Total" +"Allow Partial Authorization","Allow Partial Authorization" +"3D Secure","3D Secure" +"Severe 3D Secure Card Validation","Severe 3D Secure Card Validation" +"Severe Validation Removes Chargeback Liability on Merchant","Severe Validation Removes Chargeback Liability on Merchant" +"If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement.","If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement." +"Authorize.net Direct Post","Authorize.net Direct Post" +"Merchant MD5","Merchant MD5" +"Gateway URL","Gateway URL" diff --git a/app/code/Magento/Authorizenet/i18n/zh_CN.csv b/app/code/Magento/Authorizenet/i18n/zh_CN.csv new file mode 100644 index 0000000000000..0847524628d66 --- /dev/null +++ b/app/code/Magento/Authorizenet/i18n/zh_CN.csv @@ -0,0 +1,100 @@ +Cancel,取消 +"You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding.","You don't have enough on your credit card to pay for this purchase. To complete your purchase, click ""OK"" and add a credit card to use for the balance. Otherwise, you can cancel the purchase and release the partial payment we are holding." +"Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way.","Your credit card has been declined. You can click OK to add another credit card to complete your purchase. Or you can cancel this credit transaction and pay a different way." +"We canceled your payment and released any money we were holding.","We canceled your payment and released any money we were holding." +"You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction.","You can't use any more credit cards for this payment, and you don't have enough to pay for this purchase. Sorry, but we'll have to cancel your transaction." +"Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents.","Your order has not been placed, because the contents of the shopping cart and/or your address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process to purchase your cart contents." +"Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.",您是否确定要取消支付?单击确定可取消您的支付,并释放占用的额度。单击取消可输入其他信用卡,并继续进行支付。 +"Processed Amount",处理的额度 +"Remaining Balance",剩下的余额 +"Order saving error: %1","Order saving error: %1" +"Please choose a payment method.","Please choose a payment method." +"You created the order.","You created the order." +"Something went wrong canceling the transactions.","Something went wrong canceling the transactions." +"There was an error canceling transactions. Please contact us or try again later.",取消交易时遇到了错误。请联系我们或稍候重试。 +"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later." +"amount %1","amount %1" +failed,失败 +successful,成功 +"Credit Card: xxxx-%1","Credit Card: xxxx-%1" +"Authorize.Net Transaction ID %1","Authorize.Net Transaction ID %1" +authorize,授权 +"authorize and capture",授权和获取 +capture,获取 +refund,退款 +void,避免 +"This is an invalid amount for authorization.","This is an invalid amount for authorization." +"This is an invalid amount for capture.","This is an invalid amount for capture." +"This is an invalid amount for refund.","This is an invalid amount for refund." +"This is an invalid split tenderId ID.","This is an invalid split tenderId ID." +"Something went wrong while canceling the payment.","Something went wrong while canceling the payment." +"Something went wrong while authorizing the payment.","Something went wrong while authorizing the payment." +"Something went wrong while capturing the payment.","Something went wrong while capturing the payment." +"The shopping cart contents and/or address has been changed.","The shopping cart contents and/or address has been changed." +"This is an invalid amount for partial authorization.","This is an invalid amount for partial authorization." +"Parent Authorize.Net transaction (ID %1) expired","Parent Authorize.Net transaction (ID %1) expired" +"Something went wrong while voiding the payment.","Something went wrong while voiding the payment." +"Something went wrong while refunding the payment.","Something went wrong while refunding the payment." +"You have reached the maximum number of credit cards ' 'allowed to be used for the payment.","You have reached the maximum number of credit cards ' 'allowed to be used for the payment." +"Something went wrong while authorizing the partial payment.","Something went wrong while authorizing the partial payment." +"Something went wrong in the payment gateway.","Something went wrong in the payment gateway." +"Gateway error: %1","Gateway error: %1" +"Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s).","Gateway actions are locked because the gateway cannot complete ' 'one or more of the transactions. ' 'Please log in to your Authorize.Net account to manually resolve the issue(s)." +"Payment updating error.",支付更新错误。 +"Authorize Only",仅供授权 +"Authorize and Capture",授权和捕获 +"Invalid amount for capture.",获取的额度无效。 +"Payment capturing error.",支付捕获出错。 +"Invalid transaction ID.","Invalid transaction ID." +"Payment voiding error.",支付的作废出错。 +"Invalid amount for refund.",退款额度无效。 +"Payment refunding error.",支付的退款出错。 +"The transaction was declined because the response hash validation failed.","The transaction was declined because the response hash validation failed." +"This payment didn't work out because we can't find this order.","This payment didn't work out because we can't find this order." +"There was a payment authorization error.","There was a payment authorization error." +"This payment was not authorized because the transaction ID field is empty.","This payment was not authorized because the transaction ID field is empty." +"Amount of %1 approved by payment gateway. Transaction ID: ""%2"".","Amount of %1 approved by payment gateway. Transaction ID: ""%2""." +"Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again.","Something went wrong: the paid amount doesn't match the order amount. Please correct this and try again." +"Credit Card Type",信用卡类型 +"Credit Card Number",信用卡号码 +"Expiration Date",过期日期 +"Card Verification Number",卡片验证号码 +"Click ""Cancel"" to remove any pending status and release money already processed during this payment.","Click ""Cancel"" to remove any pending status and release money already processed during this payment." +"Please enter a different credit card number to complete your purchase.","Please enter a different credit card number to complete your purchase." +"Credit Card %1","Credit Card %1" +"Credit Card Information",信用卡信息 +"--Please Select--","-- 请选择 --" +"Card Verification Number Visual Reference","信用卡验证号码 视觉参考" +"What is this?",这是什么? +"You'll be asked for your payment details before placing an order.","You'll be asked for your payment details before placing an order." +"To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel.","To cancel pending authorizations and release amounts that have already been processed during this payment, click Cancel." +Processing...,Processing... +Enabled,Enabled +"Sort Order","Sort Order" +Title,Title +"3D Secure Card Validation","3D Secure Card Validation" +"New Order Status","New Order Status" +"No confirmation","No confirmation" +Authorize.net,Authorize.net +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Email Customer","Email Customer" +"API Login ID","API Login ID" +"Merchant's Email","Merchant's Email" +"Test Mode","Test Mode" +Debug,Debug +"Transaction Key","Transaction Key" +"Payment Action","Payment Action" +"Accepted Currency","Accepted Currency" +"Payment from Applicable Countries","Payment from Applicable Countries" +"Payment from Specific Countries","Payment from Specific Countries" +"Minimum Order Total","Minimum Order Total" +"Maximum Order Total","Maximum Order Total" +"Allow Partial Authorization","Allow Partial Authorization" +"3D Secure","3D Secure" +"Severe 3D Secure Card Validation","Severe 3D Secure Card Validation" +"Severe Validation Removes Chargeback Liability on Merchant","Severe Validation Removes Chargeback Liability on Merchant" +"If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement.","If you leave this empty, we'll use a default value. The custom URL may be provided by CardinalCommerce agreement." +"Authorize.net Direct Post","Authorize.net Direct Post" +"Merchant MD5","Merchant MD5" +"Gateway URL","Gateway URL" diff --git a/app/code/Magento/Authorizenet/view/adminhtml/layout/adminhtml_authorizenet_directpost_payment_redirect.xml b/app/code/Magento/Authorizenet/view/adminhtml/layout/adminhtml_authorizenet_directpost_payment_redirect.xml new file mode 100644 index 0000000000000..d3f5ec4838403 --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/layout/adminhtml_authorizenet_directpost_payment_redirect.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml new file mode 100644 index 0000000000000..e14a5a03af11b --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml @@ -0,0 +1,17 @@ + + + + + + + authorizenet_directpost + Magento_Authorizenet::directpost/info.phtml + + + + \ No newline at end of file diff --git a/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml new file mode 100644 index 0000000000000..b3451c3c683a9 --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml @@ -0,0 +1,17 @@ + + + + + + + authorizenet_directpost + Magento_Authorizenet::directpost/info.phtml + + + + \ No newline at end of file diff --git a/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_view.xml new file mode 100644 index 0000000000000..0c44217a8700e --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_view.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/iframe.phtml b/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/iframe.phtml new file mode 100644 index 0000000000000..23c1438d777bc --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/iframe.phtml @@ -0,0 +1,33 @@ +getParams(); +$helper = $block->getHelper('adminhtml'); +?> + + + + + + diff --git a/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml b/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml new file mode 100644 index 0000000000000..586d6ff403ebc --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml @@ -0,0 +1,119 @@ + +getMethodCode(); +$_method = $_form->getMethod(); +$_controller = $block->getRequest()->getControllerName(); +$_orderUrl = $this->helper('Magento\Authorizenet\Helper\Backend\Data')->getPlaceOrderAdminUrl(); +?> + + + + + + diff --git a/app/code/Magento/Authorizenet/view/adminhtml/templates/order/view/info/fraud_details.phtml b/app/code/Magento/Authorizenet/view/adminhtml/templates/order/view/info/fraud_details.phtml new file mode 100644 index 0000000000000..90a39448fa2ea --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/templates/order/view/info/fraud_details.phtml @@ -0,0 +1,44 @@ + + +getPayment() ?> +getAdditionalInformation('fraud_details') ?> + + +
+ +
+ +
+
+ + :
+ + + + :
+ + + + :
+ + + + :
+ + + + :
+ + :
+ + +
+
+ \ No newline at end of file diff --git a/app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js b/app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js new file mode 100644 index 0000000000000..d6423db943e1e --- /dev/null +++ b/app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js @@ -0,0 +1,426 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +(function (factory) { + if (typeof define === 'function' && define.amd) { + define([ + "jquery", + "mage/backend/validation", + "prototype" + ], factory); + } else { + factory(jQuery); + } +}(function (jQuery) { + +window.directPost = Class.create(); +directPost.prototype = { + initialize : function(methodCode, iframeId, controller, orderSaveUrl, cgiUrl, nativeAction) { + var prepare = function (event, method) { + if (method === 'authorizenet_directpost') { + this.preparePayment(); + } + }; + this.iframeId = iframeId; + this.controller = controller; + this.orderSaveUrl = orderSaveUrl; + this.nativeAction = nativeAction; + this.cgiUrl = cgiUrl; + this.code = methodCode; + this.inputs = ['cc_type', 'cc_number', 'expiration', 'expiration_yr', 'cc_cid']; + this.headers = []; + this.isValid = true; + this.paymentRequestSent = false; + this.isResponse = false; + this.orderIncrementId = false; + this.successUrl = false; + this.hasError = false; + this.tmpForm = false; + + this.onSaveOnepageOrderSuccess = this.saveOnepageOrderSuccess.bindAsEventListener(this); + this.onLoadIframe = this.loadIframe.bindAsEventListener(this); + this.onLoadOrderIframe = this.loadOrderIframe.bindAsEventListener(this); + this.onSubmitAdminOrder = this.submitAdminOrder.bindAsEventListener(this); + + jQuery('#edit_form').on('changePaymentMethod', prepare.bind(this)); + + jQuery('#edit_form').trigger( + 'changePaymentMethod', + [ + jQuery('#edit_form').find(':radio[name="payment[method]"]:checked').val() + ] + ); + }, + + validate : function() { + this.isValid = true; + this.inputs.each(function(elemIndex) { + if ($(this.code + '_' + elemIndex)) { + if (!jQuery.validator.validateElement($(this.code + '_' + elemIndex))) { + this.isValid = false; + } + } + }, this); + + return this.isValid; + }, + + changeInputOptions : function(param, value) { + this.inputs.each(function(elemIndex) { + if ($(this.code + '_' + elemIndex)) { + $(this.code + '_' + elemIndex).writeAttribute(param, value); + } + }, this); + }, + + preparePayment : function() { + this.changeInputOptions('autocomplete', 'off'); + jQuery('#edit_form') + .off('submitOrder') + .on('submitOrder', this.submitAdminOrder.bind(this)); + if ($(this.iframeId)) { + switch (this.controller) { + case 'onepage': + this.headers = $$('#' + checkout.accordion.container.readAttribute('id') + ' .section'); + var button = $('review-buttons-container').down('button'); + button.writeAttribute('onclick', ''); + button.stopObserving('click'); + button.observe('click', function() { + if ($(this.iframeId)) { + if (this.validate()) { + this.saveOnepageOrder(); + } + } else { + review.save(); + } + }.bind(this)); + break; + case 'order_create': + case 'order_edit': + // Temporary solution will be removed after refactoring Authorize.Net (sales) functionality + jQuery('.scalable.save:not(disabled)').removeAttr('onclick'); + jQuery(document).off('click.directPost'); + jQuery(document).on( + 'click.directPost', + '.scalable.save:not(disabled)', + jQuery.proxy(this.onSubmitAdminOrder, this) + ); + + $('order-' + this.iframeId).observe('load', this.onLoadOrderIframe); + break; + } + + $(this.iframeId).observe('load', this.onLoadIframe); + } + }, + + loadIframe : function() { + if (this.paymentRequestSent) { + switch (this.controller) { + case 'onepage': + this.paymentRequestSent = false; + if (!this.hasError) { + this.returnQuote(); + } + break; + case 'order_edit': + case 'order_create': + if (!this.orderRequestSent) { + this.paymentRequestSent = false; + if (!this.hasError) { + this.returnQuote(); + } else { + this.changeInputOptions('disabled', false); + jQuery('body').trigger('processStop'); + enableElements('save'); + } + } + break; + } + if (this.tmpForm) { + document.body.removeChild(this.tmpForm); + } + } + }, + + loadOrderIframe : function() { + if (this.orderRequestSent) { + $(this.iframeId).hide(); + var data = $('order-' + this.iframeId).contentWindow.document.body.getElementsByTagName('pre')[0].innerHTML; + this.saveAdminOrderSuccess(data); + this.orderRequestSent = false; + } + }, + + showError : function(msg) { + this.hasError = true; + if (this.controller == 'onepage') { + $(this.iframeId).hide(); + this.resetLoadWaiting(); + } + alert(msg); + }, + + returnQuote : function() { + var url = this.orderSaveUrl.replace('place', 'returnQuote'); + new Ajax.Request(url, { + onSuccess : function(transport) { + try { + response = eval('(' + transport.responseText + ')'); + } catch (e) { + response = {}; + } + if (response.error_message) { + alert(response.error_message); + } + $(this.iframeId).show(); + switch (this.controller) { + case 'onepage': + this.resetLoadWaiting(); + break; + case 'order_edit': + case 'order_create': + this.changeInputOptions('disabled', false); + jQuery('body').trigger('processStop'); + enableElements('save'); + break; + } + }.bind(this) + }); + }, + + setLoadWaiting : function() { + this.headers.each(function(header) { + header.removeClassName('allow'); + }); + checkout.setLoadWaiting('review'); + }, + + resetLoadWaiting : function() { + this.headers.each(function(header) { + header.addClassName('allow'); + }); + checkout.setLoadWaiting(false); + }, + + saveOnepageOrder : function() { + this.hasError = false; + this.setLoadWaiting(); + var params = Form.serialize(payment.form); + if (review.agreementsForm) { + params += '&' + Form.serialize(review.agreementsForm); + } + params += '&controller=' + this.controller; + new Ajax.Request(this.orderSaveUrl, { + method : 'post', + parameters : params, + onComplete : this.onSaveOnepageOrderSuccess, + onFailure : function(transport) { + this.resetLoadWaiting(); + if (transport.status == 403) { + checkout.ajaxFailure(); + } + } + }); + }, + + saveOnepageOrderSuccess : function(transport) { + if (transport.status == 403) { + checkout.ajaxFailure(); + } + try { + response = eval('(' + transport.responseText + ')'); + } catch (e) { + response = {}; + } + + if (response.success && response.directpost) { + this.orderIncrementId = response.directpost.fields.x_invoice_num; + var paymentData = {}; + for ( var key in response.directpost.fields) { + paymentData[key] = response.directpost.fields[key]; + } + var preparedData = this.preparePaymentRequest(paymentData); + this.sendPaymentRequest(preparedData); + } else { + var msg = response.error_messages; + if (typeof (msg) == 'object') { + msg = msg.join("\n"); + } + if (msg) { + alert(msg); + } + + if (response.update_section) { + $('checkout-' + response.update_section.name + '-load').replace(response.update_section.html); + response.update_section.html.evalScripts(); + } + + if (response.goto_section) { + checkout.gotoSection(response.goto_section); + checkout.reloadProgressBlock(); + } + } + }, + + submitAdminOrder : function() { + // Temporary solution will be removed after refactoring Authorize.Net (sales) functionality + var editForm = jQuery('#edit_form'); + if (editForm.valid()) { + // Temporary solution will be removed after refactoring Authorize.Net (sales) functionality + paymentMethodEl = editForm.find(':radio[name="payment[method]"]:checked'); + this.hasError = false; + if (paymentMethodEl.val() == this.code) { + jQuery('body').trigger('processStart'); + setLoaderPosition(); + this.changeInputOptions('disabled', 'disabled'); + this.paymentRequestSent = true; + this.orderRequestSent = true; + // Temporary solutions will be removed after refactoring Authorize.Net (sales) functionality + editForm.attr('action', this.orderSaveUrl); + editForm.attr('target', + jQuery('#order-' + this.iframeId).attr('name')); + editForm.append(this.createHiddenElement('controller', this.controller)); + disableElements('save'); + // Temporary solutions will be removed after refactoring Authorize.Net (sales) functionality + order._realSubmit(); + } else { + editForm.attr('action', this.nativeAction); + editForm.attr('target', '_top'); + disableElements('save'); + // Temporary solutions will be removed after refactoring Authorize.Net (sales) functionality + order._realSubmit(); + } + } + }, + + recollectQuote : function() { + var area = [ 'sidebar', 'items', 'shipping_method', 'billing_method', 'totals', 'giftmessage' ]; + area = order.prepareArea(area); + var url = order.loadBaseUrl + 'block/' + area; + var info = $('order-items_grid').select('input', 'select', 'textarea'); + var data = {}; + for ( var i = 0; i < info.length; i++) { + if (!info[i].disabled && (info[i].type != 'checkbox' || info[i].checked)) { + data[info[i].name] = info[i].getValue(); + } + } + data.reset_shipping = true; + data.update_items = true; + if ($('coupons:code') && $F('coupons:code')) { + data['order[coupon][code]'] = $F('coupons:code'); + } + data.json = true; + new Ajax.Request(url, { + parameters : data, + loaderArea : 'html-body', + onSuccess : function(transport) { + jQuery('#edit_form').submit(); + }.bind(this) + }); + + }, + + saveAdminOrderSuccess : function(data) { + try { + response = eval('(' + data + ')'); + } catch (e) { + response = {}; + } + + if (response.directpost) { + this.orderIncrementId = response.directpost.fields.x_invoice_num; + var paymentData = {}; + for ( var key in response.directpost.fields) { + paymentData[key] = response.directpost.fields[key]; + } + var preparedData = this.preparePaymentRequest(paymentData); + this.sendPaymentRequest(preparedData); + } else { + if (response.redirect) { + window.location = response.redirect; + } + if (response.error_messages) { + var msg = response.error_messages; + if (typeof (msg) == 'object') { + msg = msg.join("\n"); + } + if (msg) { + alert(msg); + } + } + } + }, + + preparePaymentRequest : function(data) { + if ($(this.code + '_cc_cid')) { + data.x_card_code = $(this.code + '_cc_cid').value; + } + var year = $(this.code + '_expiration_yr').value; + if (year.length > 2) { + year = year.substring(2); + } + var month = parseInt($(this.code + '_expiration').value, 10); + if (month < 10) { + month = '0' + month; + } + + data.x_exp_date = month + '/' + year; + data.x_card_num = $(this.code + '_cc_number').value; + + return data; + }, + + sendPaymentRequest : function(preparedData) { + this.recreateIframe(); + this.tmpForm = document.createElement('form'); + this.tmpForm.style.display = 'none'; + this.tmpForm.enctype = 'application/x-www-form-urlencoded'; + this.tmpForm.method = 'POST'; + document.body.appendChild(this.tmpForm); + this.tmpForm.action = this.cgiUrl; + this.tmpForm.target = $(this.iframeId).readAttribute('name'); + this.tmpForm.setAttribute('target', $(this.iframeId).readAttribute('name')); + + for ( var param in preparedData) { + this.tmpForm.appendChild(this.createHiddenElement(param, preparedData[param])); + } + + this.paymentRequestSent = true; + this.tmpForm.submit(); + }, + + createHiddenElement : function(name, value) { + var field; + if (isIE) { + field = document.createElement('input'); + field.setAttribute('type', 'hidden'); + field.setAttribute('name', name); + field.setAttribute('value', value); + } else { + field = document.createElement('input'); + field.type = 'hidden'; + field.name = name; + field.value = value; + } + + return field; + }, + + recreateIframe : function() { + if ($(this.iframeId)) { + var nextElement = $(this.iframeId).next(); + var src = $(this.iframeId).readAttribute('src'); + var name = $(this.iframeId).readAttribute('name'); + $(this.iframeId).stopObserving(); + $(this.iframeId).remove(); + var iframe = ' +
+ + + +
+ + + +
+ +
+
+ +
+
+
+
+
diff --git a/composer.json b/composer.json index b106e4e564682..3277dd1beee81 100644 --- a/composer.json +++ b/composer.json @@ -65,6 +65,7 @@ "magento/module-admin-notification": "self.version", "magento/module-advanced-pricing-import-export": "self.version", "magento/module-authorization": "self.version", + "magento/module-authorizenet": "self.version", "magento/module-backend": "self.version", "magento/module-backup": "self.version", "magento/module-bundle": "self.version", diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Authorizenet/Form/Cc.php b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Authorizenet/Form/Cc.php new file mode 100644 index 0000000000000..7b109b8947ea4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Authorizenet/Form/Cc.php @@ -0,0 +1,18 @@ + + + + payment + + + select + + + + select + + + select + + + + diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/ConfigData.xml new file mode 100644 index 0000000000000..de7d54e27bb18 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/ConfigData.xml @@ -0,0 +1,63 @@ + + + + + + + payment + 1 + Yes + 1 + + + payment + 1 + + PAYMENT_AUTHORIZENET_LOGIN + + + payment + 1 + + PAYMENT_AUTHORIZENET_TRANS_KEY + + + payment + 1 + No + 0 + + + payment + 1 + + https://test.authorize.net/gateway/transact.dll + + + payment + 1 + Yes + 1 + + + payment + 1 + Yes + 1 + + + + + payment + 1 + Yes + 0 + + + + diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml new file mode 100644 index 0000000000000..8e2b942b48d1f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml @@ -0,0 +1,18 @@ + + + + + + Visa + 4007000000027 + 01 - January + 2016 + 123 + + + diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml new file mode 100644 index 0000000000000..7adf887baa967 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml @@ -0,0 +1,31 @@ + + + + + + MAGETWO-12832 - Check Out as a Guest with Authorize.Net and Offline Shipping method + catalogProductSimple::product_10_dollar, configurableProduct::with_one_option, bundleProduct::bundle_fixed_100_dollar_product + us_ca_ny_rule + default + US_address_1 + guest + Flat Rate + Fixed + + 156.81 + + authorizenet + visa_default + authorizenet + test_type:3rd_party_test + + + + + + diff --git a/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php b/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php new file mode 100644 index 0000000000000..85b6564400494 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTest.php @@ -0,0 +1,139 @@ + 'data']; + + $this->getRequest()->setParam('payment', ['method' => 'authorizenet_directpost']); + $this->getRequest()->setParam('controller', 'order_create'); + $orderCreateMock = $this->getOrderCreateMock($requestToAuthorizenetData); + $directpostMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + ->setMethods(['getCode']) + ->disableOriginalConstructor() + ->getMock(); + $directpostMock->expects($this->once()) + ->method('getCode') + ->willReturn('authorizenet_directpost'); + $jsonHelper = $this->_objectManager->get('Magento\Framework\Json\Helper\Data'); + $objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->setMethods(['create', 'get']) + ->getMockForAbstractClass(); + $objectManagerMock->expects($this->atLeastOnce()) + ->method('create') + ->with('Magento\Authorizenet\Model\Directpost') + ->willReturn($directpostMock); + $authorizenetSessionMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + ->disableOriginalConstructor() + ->getMock(); + $urlMock = $this->getMockBuilder('Magento\Backend\Model\UrlInterface') + ->getMockForAbstractClass(); + $objectManagerMock->expects($this->atLeastOnce()) + ->method('get') + ->willReturnMap([ + ['Magento\Sales\Model\AdminOrder\Create', $orderCreateMock], + ['Magento\Framework\Json\Helper\Data', $jsonHelper], + ['Magento\Authorizenet\Model\Directpost\Session', $authorizenetSessionMock], + ['Magento\Backend\Model\UrlInterface', $urlMock], + ]); + + $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Backend\App\Action\Context', + [ + 'objectManager' => $objectManagerMock + ] + ); + + $controller = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment\PlaceTesting', + ['context' => $context] + ); + $controller->execute(); + $this->assertContains(json_encode($requestToAuthorizenetData), $this->getResponse()->getBody()); + } + + /** + * @param array $requestToAuthorizenetData + * @return \PHPUnit_Framework_MockObject_MockObject + */ + private function getOrderCreateMock($requestToAuthorizenetData) + { + $methodInstanceMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost') + ->disableOriginalConstructor() + ->getMock(); + $directpostRequestMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Request') + ->setMethods(['getData']) + ->disableOriginalConstructor() + ->getMock(); + $directpostRequestMock->expects($this->once()) + ->method('getData') + ->willReturn($requestToAuthorizenetData); + $methodInstanceMock->expects($this->once()) + ->method('generateRequestFromOrder') + ->willReturn($directpostRequestMock); + $paymentMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + ->setMethods(['getMethod', 'getMethodInstance']) + ->disableOriginalConstructor() + ->getMock(); + $paymentMock->expects($this->once()) + ->method('getMethod') + ->willReturn('authorizenet_directpost'); + $paymentMock->expects($this->once()) + ->method('getMethodInstance') + ->willReturn($methodInstanceMock); + $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') + ->setMethods(['getPayment', 'getStoreId']) + ->disableOriginalConstructor() + ->getMock(); + $quoteMock->expects($this->any()) + ->method('getPayment') + ->willReturn($paymentMock); + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->setMethods(['getPayment']) + ->disableOriginalConstructor() + ->getMock(); + $orderMock->expects($this->any()) + ->method('getPayment') + ->willReturn($paymentMock); + $sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + ->setMethods(['getOrder']) + ->disableOriginalConstructor() + ->getMock(); + $sessionQuoteMock->expects($this->once()) + ->method('getOrder') + ->willReturn($orderMock); + $orderCreateMock = $this->getMockBuilder('Magento\Sales\Model\AdminOrder\Create') + ->setMethods(['getQuote', 'getSession', 'setIsValidate', 'importPostData', 'createOrder', 'setPaymentData']) + ->disableOriginalConstructor() + ->getMock(); + $orderCreateMock->expects($this->any()) + ->method('getQuote') + ->willReturn($quoteMock); + $orderCreateMock->expects($this->once()) + ->method('getSession') + ->willReturn($sessionQuoteMock); + $orderCreateMock->expects($this->once()) + ->method('setIsValidate') + ->willReturnSelf(); + $orderCreateMock->expects($this->once()) + ->method('importPostData') + ->willReturnSelf(); + $orderCreateMock->expects($this->once()) + ->method('createOrder') + ->willReturn($orderMock); + + return $orderCreateMock; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTesting.php b/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTesting.php new file mode 100644 index 0000000000000..cb9712d5fa5d5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/PlaceTesting.php @@ -0,0 +1,21 @@ +getRequest()->setPostValue('controller_action_name', 'onepage'); + $this->dispatch('authorizenet/directpost_payment/response'); + // @codingStandardsIgnoreStart + $this->assertContains( + 'authorizenet/directpost_payment/redirect/success/0/error_msg/The transaction was' + . ' declined because the response hash validation failed.', + // @codingStandardsIgnoreEnd + $this->getResponse()->getBody() + ); + } + + public function testRedirectActionErrorMessage() + { + $this->getRequest()->setParam('success', '0'); + $this->getRequest()->setParam('error_msg', 'Error message'); + $this->dispatch('authorizenet/directpost_payment/redirect'); + $this->assertContains('alert("Error message");', $this->getResponse()->getBody()); + } + + public function testBackendResponseActionOrderSuccess() + { + $xNum = 1; + $this->getRequest()->setPostValue('x_invoice_num', $xNum); + $this->dispatch('authorizenet/directpost_payment/backendresponse'); + $this->assertContains( + '/sales/order/view/', + $this->getResponse()->getBody() + ); + } + + public function testBackendResponseActionValidationFailed() + { + $this->getRequest()->setPostValue('controller_action_name', 'action_name'); + $this->dispatch('authorizenet/directpost_payment/backendresponse'); + // @codingStandardsIgnoreStart + $this->assertContains( + 'authorizenet_directpost_payment/redirect/success/0/error_msg/The transaction was declined' + . ' because the response hash validation failed./controller_action_name/action_name/', + // @codingStandardsIgnoreEnd + $this->getResponse()->getBody() + ); + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt index 9210d15d05df6..15ba997298fe0 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt @@ -1,3 +1,4 @@ +app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js app/code/Magento/Captcha/view/frontend/web/onepage.js app/code/Magento/Catalog/view/adminhtml/web/catalog/category/edit.js app/code/Magento/Catalog/view/adminhtml/web/catalog/product.js diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt index 92cc3827467b3..1476776c1ebbc 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt @@ -1,3 +1,4 @@ +app/code/Magento/Authorizenet app/code/Magento/Bundle app/code/Magento/Captcha app/code/Magento/Catalog 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 c052dc3f2b8ac..2fe6d3a8d30ac 100755 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -3671,4 +3671,29 @@ ['Magento\Framework\View\Element\UiComponent\JsConfigInterface'], ['Magento\GiftMessage\Model\Plugin\TotalsDataProcessorPlugin'], ['Magento\Catalog\Model\Product\Attribute\Backend\Startdate', 'Magento\Catalog\Model\Attribute\Backend\Startdate'], + ['Magento\Authorizenet\Block\Authorizenet\Form\Cc'], + ['Magento\Authorizenet\Block\Authorizenet\Info\Cc'], + ['Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Payment\Cancel'], + ['Magento\Authorizenet\Controller\Authorizenet\Payment\Cancel'], + [ + 'Magento\Authorizenet\Model\Authorizenet\Source\Cctype', + 'Magento\Authorizenet\Model\Source\Cctype' + ], + [ + 'Magento\Authorizenet\Model\Authorizenet\Source\PaymentAction', + 'Magento\Authorizenet\Model\Source\PaymentAction' + ], + ['Magento\Authorizenet\Model\Authorizenet\Cards'], + [ + 'Magento\Authorizenet\Model\Authorizenet\Debug', + 'Magento\Authorizenet\Model\Debug' + ], + [ + 'Magento\Authorizenet\Model\Resource\Authorizenet\Debug\Collection', + 'Magento\Authorizenet\Model\Resource\Debug\Collection' + ], + [ + 'Magento\Authorizenet\Model\Resource\Authorizenet\Debug', + 'Magento\Authorizenet\Model\Resource\Debug' + ] ]; 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 88d5ca7deadc9..364257ef54596 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 @@ -2275,5 +2275,28 @@ ['_getCentinelVpasLabel', 'Magento\Paypal\Model\Info'], ['_getCentinelEciLabel', 'Magento\Paypal\Model\Info'], ['_getPayPalPayflowPro3dSecure', 'Magento\Config\Test\Repository\Config'], - ['_getPayPalPaymentsPro3dSecure', 'Magento\Config\Test\Repository\Config'] + ['_getPayPalPaymentsPro3dSecure', 'Magento\Config\Test\Repository\Config'], + ['addAdditionalFieldsToResponseFrontend', 'Magento\Authorizenet\Model\Directpost\Observer'], + ['_getAuthorizeNet3dSecure', 'Magento\Config\Test\Repository\Config'], + [ + 'getRelyUrl', + 'Magento\Authorizenet\Helper\Backend\Data', + 'Magento\Authorizenet\Helper\Backend\Data::getRelayUrl()' + ], + [ + 'getRelyUrl', + 'Magento\Authorizenet\Helper\Data', + 'Magento\Authorizenet\Helper\Data::getRelayUrl()' + ], + ['setPartialAuthorizationLastActionState', 'Magento\Authorizenet\Model\Authorizenet'], + ['getPartialAuthorizationLastActionState', 'Magento\Authorizenet\Model\Authorizenet'], + ['unsetPartialAuthorizationLastActionState', 'Magento\Authorizenet\Model\Authorizenet'], + ['cancelPartialAuthorization', 'Magento\Authorizenet\Model\Authorizenet'], + ['getCardsStorage', 'Magento\Authorizenet\Model\Authorizenet'], + ['isPartialAuthorization', 'Magento\Authorizenet\Model\Authorizenet'], + [ + 'setHelper', + 'Magento\Authorizenet\Model\Directpost', + 'Magento\Authorizenet\Model\Directpost::setDataHelper()' + ] ]; From a0fd809be5c2b4b219e9866e8cdc442263f27aa8 Mon Sep 17 00:00:00 2001 From: yuri kovsher Date: Sun, 5 Jul 2015 02:22:02 +0300 Subject: [PATCH 52/56] MAGETWO-39631: Add Authorize.net payment method --- app/code/Magento/Authorizenet/LICENSE.txt | 48 ++ app/code/Magento/Authorizenet/LICENSE_AFL.txt | 48 ++ app/code/Magento/Authorizenet/LICENSE_EE.txt | 437 ------------------ 3 files changed, 96 insertions(+), 437 deletions(-) create mode 100644 app/code/Magento/Authorizenet/LICENSE.txt create mode 100644 app/code/Magento/Authorizenet/LICENSE_AFL.txt delete mode 100644 app/code/Magento/Authorizenet/LICENSE_EE.txt diff --git a/app/code/Magento/Authorizenet/LICENSE.txt b/app/code/Magento/Authorizenet/LICENSE.txt new file mode 100644 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magento/Authorizenet/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/Authorizenet/LICENSE_AFL.txt b/app/code/Magento/Authorizenet/LICENSE_AFL.txt new file mode 100644 index 0000000000000..87943b95d43a5 --- /dev/null +++ b/app/code/Magento/Authorizenet/LICENSE_AFL.txt @@ -0,0 +1,48 @@ + +Academic Free License ("AFL") v. 3.0 + +This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Academic Free License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/Authorizenet/LICENSE_EE.txt b/app/code/Magento/Authorizenet/LICENSE_EE.txt deleted file mode 100644 index 2bddf5feda6ba..0000000000000 --- a/app/code/Magento/Authorizenet/LICENSE_EE.txt +++ /dev/null @@ -1,437 +0,0 @@ -MAGENTO(tm) ENTERPRISE EDITION -END USER LICENSE AGREEMENT - -This End User License Agreement ("Agreement") is entered into by and between X.commerce, Inc. -through its Magento division ("Magento"), and the Licensee executing the Magento Order Form -(defined below). The parties agree as follows: - -TERMS AND CONDITIONS - -1. License - 1.1. Subject to Licensee's payment of the applicable fees and to Licensee's compliance with - other terms and conditions of this Agreement, Magento grants Licensee a non-transferable, - non-assignable, non-sublicensable, worldwide license to copy the Software for the purpose of - installing and using it on a computer and solely for internal purposes, in accordance with the - Software's technical documentation and solely during the periods and on the maximum number - of Designated Servers specified in one or more applicable Magento or Magento-authorized - reseller ordering schedules (the "Magento Order Form") executed with Licensee. - - 1.2. In the event that Licensee's actual number of Servers of a particular Software license - exceeds the licensed number of Designated Servers on such license, Licensee shall promptly - provide Magento with written notice and pay Magento the fees required to license such - additional Server(s) in accordance with the commercial terms set out in the Magento Order - Form. - - 1.3. Licensee shall implement reasonable controls to ensure that it does not exceed the - maximum number of licensed Servers of the Software. Magento reserves the right to audit - Licensee's use of the Software during normal business hours and with reasonable notice and to - include means within the Software to limit Licensee's use of the Software to the licensed - number of Servers. - - 1.4. Magento shall provide to Licensee an initial copy of the Software, including the associated - technical documentation, for use by Licensee in accordance with this Agreement. Subject to - Sections 1.1-1.3 above, Licensee is authorized to make a reasonable number of non-Server - copies of the Software, e.g., onto a local pc, as it requires for purpose of exercising its rights - under this Agreement. - - 1.5. Licensee is authorized to use the Software on a single substitute or backup Server on a - temporary basis without charge any time a Designated Server is inoperative due to a - malfunction beyond the control of Licensee. Licensee may transfer the Software on a - permanent basis to a single replacement Server without charge. Licensee agrees to provide - Magento with written notice, including the Server type and operating system, of any such - transfer to a backup or replacement Server within five (5) days thereafter. - - 1.6. Licensee acknowledges that portions of the Software are also freely available to the public - under Magento's open source version of the Software, known as Magento Community Edition, - subject to certain conditions, with limited warranties and other limited assurances, and without - service or support. As an express condition for the license granted hereunder, Licensee agrees - that any use during the term of this Agreement of such open source versions of the Software, - whether in a Production Server Instance or a Non-Production Server Instance, shall be deemed - use of the Software for purposes of the calculation of fees payable under the Agreement. - - 1.7. Magento also grants Licensee the right to modify and create derivative works of the - Software. Licensee may contribute the rights in any of those derivative works back to Magento. - Licensee may contact Magento for more information regarding contributions of derivative - works rights to Magento. Regardless of whether Licensee contributes such derivative works - rights to Magento, Licensee hereby grants Magento a perpetual and irrevocable (irrespective of - the expiration or termination of this Agreement), nonexclusive, transferable, worldwide, and - royalty-free license to reproduce, create derivative works of, distribute, perform, and display - any derivative works of the Software developed by or for Licensee, and to use, make, have - made, sell, offer to sell, import, export, and otherwise exploit any product based on any such - derivative works. - -2. License Exclusions - 2.1 Except as expressly authorized herein, Licensee shall not: - a. use or deploy the Software on any Server in excess of the number of Designated Servers - specified in the applicable Magento Order Form; - - b. distribute, sublicense, disclose, market, rent, lease, or offer remote computing services, - networking, batch processing or transfer of, the Software to any third party, or permit any - person or entity to have access to the Software by means of a time sharing, remote - computing services, networking, batch processing, service bureau or time sharing - arrangement; - - c. export the Software in violation of U.S. Department of Commerce export administration - regulations. - - 2.2. No license, right or interest in any Magento trademark, trade name or service mark is - granted hereunder. - -3. Fees and Payment Terms - Licensee agrees to the fees and payment terms that are described in each Magento Order Form - executed by Licensee. - -4. Title and Protection - 4.1. Magento (or its third party providers) retains title to all portions of the Software and other - Proprietary Materials and any copies thereof. The Proprietary Materials contain valuable - proprietary information, and Licensee shall not disclose them to anyone other than those of its - employees or consultants under written nondisclosure obligations at least as restrictive as - those contained in this Agreement, having a need to know for purposes consistent with this - Agreement. Licensee shall be responsible for the compliance of such employees or consultants. - Licensee shall affix, to each full or partial copy of the Software made by Licensee, all copyright - and proprietary information notices as were affixed to the original. The obligations set forth in - this Section shall survive termination of this Agreement. - - 4.2. Licensee acknowledges that the Software includes certain open source software which is - governed by the applicable license terms thereof. A list of such open source software, as - amended from time to time, including the links applicable to such open source software is - specified in the product software bundled within the Software, and the Software is subject to - the provisions of such license agreements, and in the event of any contradiction between the - provisions of this Agreement and the provisions of such applicable license agreement, the - provisions of the applicable open source license agreement shall prevail solely with respect to - such open source software products. - - 4.3. If the Software is acquired by or on behalf of a unit or agency of the U.S. Government (the - "Government"), the Government agrees that such Product is "commercial computer software" - or "commercial computer software documentation" and that, absent a written agreement to - the contrary, the Government's rights with respect thereto are limited by the terms of this - Agreement, pursuant to applicable FAR and/or DFARS and successor regulations. - -5. Patent and Copyright Indemnity - Subject to the limitations in Section 8, for such time as Licensee is entitled to receive Support - Services (as defined below), Magento shall indemnify and defend Licensee against any claims made - by a third party that Licensee's reproduction of the Software (which, for the purposes of this Section - 5, means the Software as delivered by Magento, excluding the open source software programs - described in Section 4.2) as permitted in this Agreement directly infringes such third party's United - States patent or copyright, provided that Licensee complies with the requirements of this Section. - Licensee will (a) provide Magento prompt written notice of any claim that the Software infringes any - intellectual property rights, (b) provide Magento with all information and assistance requested of it - with respect to any such claim, and (c) offer Magento sole and complete authority to defend and/or - settle any and all such claims. - - In the event that a court holds that the Software, or if Magento believes a court may hold that the - Software, infringes the intellectual property rights of any third party, Magento may (but is not - obligated to), in its sole discretion, do any of the following: obtain for Licensee the right to continue - using the Software, replace or modify the Software so that it becomes non-infringing while providing - substantially equivalent performance or, accept return of the Software, terminate this Agreement, - and refund Licensee an amount equal to the license fees paid to Magento multiplied by the - percentage of the term of the license for the Software that Licensee did not enjoy due to the early - termination by Magento. - - Magento shall have no liability or obligation under this Agreement to the extent the alleged - infringement is based on (i) a modification or derivative work of the Software developed by anyone - other than Magento; (ii), a combination of the Software with any product or service not provided by - Magento; (ii) use of the Software with one or more Servers not listed in a Magento Order Form; (iii) - use of the Software other than in accordance with this Agreement or the documentation; (iv) - indirect or willful infringement; or (v) any open source code, as described in Section 4.2. - - This Section 5 states Magento's entire liability and Licensee's exclusive remedy for any infringement - related to the Software. - -6. Default and Termination - 6.1. An event of default shall be deemed to occur if: (i) Licensee fails to perform any of its - obligations under the Sections entitled "License Exclusions" or "Title and Protection"; (ii) - Licensee fails to pay amounts due pursuant to its agreement to the fees and payment terms in - Section 3 of this Agreement within seven (7) days of the relevant due date; or (iii) either party - fails to perform any other material obligation under this Agreement and such failure remains - uncured for more than thirty (30) days after receipt of written notice thereof. - - 6.2. If an event of default occurs, the non-defaulting party, in addition to any other rights - available to it under the law, may terminate this Agreement and all licenses granted hereunder - by written notice to the defaulting party. - - 6.3. Within thirty (30) days after termination of the Software license or this Agreement or - expiration of the license term as specified in the Magento Order Form, Licensee shall certify in - writing to Magento that Licensee has ceased use of any and all Proprietary Materials and that - all copies or embodiments thereof in any form, including partial copies within modified - versions, have been destroyed. - -7. Warranty - 7.1. Warranty for Software. Magento warrants for a single period of ninety (90) days - commencing upon Magento's electronic delivery of the Software to Licensee that the Software, - as delivered, will in all material respects perform the functions described in the specifications - contained in the documentation provided with the Software. In the event that the Software - does not, in all material respects, perform the functions therein described, Magento or its - authorized reseller will undertake to correct any reported error in accordance with the Support - Services Terms and Conditions set forth below in Section 9, which shall be Magento's entire - liability and Licensee's exclusive remedy for breach of this warranty. Magento does not warrant - that the Software will meet Licensee's requirements, that the Software will operate in the - combinations which Licensee may select for use, that the operation of the Software will be - uninterrupted or error-free, or that all error conditions will be corrected. EXCEPT AS PROVIDED - IN THIS SECTION ALL SOFTWARE PROVIDED HEREUNDER IS PROVIDED "AS IS". - - 7.2. DISCLAIMER. THE EXPRESS WARRANTIES SET FORTH IN THIS SECTION 7 ARE THE ONLY - WARRANTIES MADE BY MAGENTO WITH RESPECT TO THE SOFTWARE PROVIDED BY MAGENTO. - MAGENTO MAKES NO OTHER WARRANTIES, EXPRESS, IMPLIED OR ARISING BY CUSTOM OR - TRADE USAGE, AND, SPECIFICALLY, MAKES NO WARRANTY OF TITLE, NON-INFRINGEMENT, - ACCURACY, QUIET ENJOYMENT, MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR - PURPOSE. MAGENTO'S EXPRESS WARRANTIES SHALL NOT BE ENLARGED, DIMINISHED OR - AFFECTED BY, AND NO OBLIGATION OR LIABILITY SHALL ARISE OUT OF, MAGENTO RENDERING - TECHNICAL OR OTHER ADVICE OR SERVICE IN CONNECTION WITH THE SOFTWARE. - -8. Limitation of Liability - 8.1. LIABILITY EXCLUSIONS. UNDER NO CIRCUMSTANCES WILL MAGENTO BE LIABLE FOR: LOSS - OF REVENUE; LOSS OF ACTUAL OR ANTICIPATED PROFITS; LOSS OF CONTRACTS; LOSS OF THE - USE OF MONEY; LOSS OF ANTICIPATED SAVINGS; LOSS OF BUSINESS; LOSS OF OPPORTUNITY; - LOSS OF GOODWILL; LOSS OF REPUTATION; LOSS OF, DAMAGE TO OR CORRUPTION OF DATA; - OR CONSEQUENTIAL OR INDIRECT LOSS OR SPECIAL, PUNITIVE, OR INCIDENTAL DAMAGES - (INCLUDING, FOR THE AVOIDANCE OF DOUBT, WHERE SUCH LOSS OR DAMAGE IS ALSO OF A - CATEGORY OF LOSS OR DAMAGE ALREADY LISTED), WHETHER FORESEEABLE OR - UNFORESEEABLE, BASED ON CLAIMS OF LICENSEE, MAGENTO OR ANY THIRD PARTY ARISING - OUT OF ANY BREACH OR FAILURE OF EXPRESS OR IMPLIED WARRANTY CONDITIONS OR OTHER - TERM, BREACH OF CONTRACT, MISREPRESENTATION, NEGLIGENCE, OTHER LIABILITY IN TORT, - FAILURE OF ANY REMEDY TO ACHIEVE ITS ESSENTIAL PURPOSE, OR OTHERWISE. - - 8.2. LIABILITY CAP. NOTWITHSTANDING THE FORM (E.G., CONTRACT, TORT, OR OTHERWISE) IN - WHICH ANY LEGAL OR EQUITABLE ACTION MAY BE BROUGHT, IN NO EVENT (INCLUDING WITH - RESPECT TO OBLIGATIONS ARISING UNDER SECTION 5) WILL MAGENTO OR ITS SUPPLIERS BE - LIABLE FOR DAMAGES, EXPENSES, COSTS, LIABILITIES, SUITS, CLAIMS, RESTITUTION OR LOSSES, - THAT EXCEED, IN THE AGGREGATE, THE AMOUNT OF FEES PAID BY LICENSEE FOR THE - SOFTWARE LICENSE IN THE FIRST TWELVE (12) MONTH PERIOD AFTER THE EFFECTIVE DATE. - -9. Support Services Terms and Conditions - For the periods specified in the Magento Order Form, Magento or its authorized reseller will provide - support services and Updates for the Software as described in Magento's standard Support Services - Terms and Conditions, which follow. Magento will have no obligation to provide support for any - modifications or derivative works of the Software developed by anyone other than Magento. - -10. Customer References - Licensee hereby grants Magento the right to display Licensee's logos as part of Magento's customer - lists and other related marketing materials. The parties shall cooperate to undertake mutually- - agreed joint marketing activities. - -11. Notices - All notices shall be in writing and sent by first class mail or overnight mail (or courier), transmitted by - facsimile (if confirmed by such mailing), or email, to the addresses indicated on the Magento Order - Form, or such other address as either party may indicate by at least ten (10) days prior written - notice to the other party. Notices to Magento shall be sent to the Contracts Administration - Department. - -12. Assignment - Licensee may not assign this Agreement without the prior written consent of Magento; provided - that such consent shall not be required for assignment to a purchaser of all or substantially all of the - assets or equity securities of Licensee who undertakes in writing to be bound by all the terms and - conditions of this Agreement. Any prohibited assignment shall be null and void. - -13. Entire Agreement - Along with Magento's standard Support Services Terms and Conditions, which follow, and the - Magento Order Form, this Agreement is the complete and exclusive agreement between the parties, - which supersedes all proposals or prior agreements, oral or written, including any online (click- - through) agreement which Licensee may have accepted in conjunction with the downloading of the - Software, and all other communications between the parties relating to the subject matter hereof. - No purchase order, other ordering document or any hand written or typewritten text which purports - to modify or supplement the printed text hereof or Magento Order Form shall add to or vary the - terms thereof and Magento hereby rejects same. Except as contained in a writing signed by both - parties, all such proposed variations or additions are objected to and shall have no force or effect. - -14. General - This Agreement is made in and shall be governed by the laws of the State of California, without - giving effect to any principles that provide for the application of the law of another jurisdiction. All - proceedings shall be conducted in English. Venue for all proceedings shall be Santa Clara County, - California, provided that Magento may seek injunctive relief in any court of competent jurisdiction. - The United Nations Convention for the International Sale of Goods shall not apply. The section - headings herein are provided for convenience only and have no substantive effect on the - construction of this Agreement. Except for Licensee's obligation to pay Magento, neither party shall - be liable for any failure to perform due to causes beyond its reasonable control. If any provision of - this Agreement is held to be unenforceable, this Agreement shall be construed without such - provision. The failure by a party to exercise any right hereunder shall not operate as a waiver of such - party's right to exercise such right or any other right in the future. This Agreement may be amended - only by a written document executed by a duly authorized representative of each of the parties. The - parties agree to receive electronic documents and accept electronic signatures (information - attached or logically associated with such document and clicked or otherwise adopted with an intent - to sign) including in counterparts which shall be valid substitutes for paper-based documents and - signatures, and the legal validity of a transaction will not be denied on the ground that it is not in - writing. - -15. Definitions - "Designated Server" shall mean the Server specified in a Magento Order Form with respect to a - particular Software license. Such Server may be that of a third-party under nondisclosure obligations - that will host the Software for the benefit of Licensee. - - "Modifications" means any code developed by Licensee or any third party, including without - limitation, configuration, integrations, implementations, or localizations to the external layer of the - core, baseline Software product. The term "Modifications" excludes Updates. - - "Proprietary Material" means the Software, related documentation, and all parts, copies and - modifications thereof, and any other information, in whatever form, received by Licensee - hereunder, provided, however, such information shall not be deemed Proprietary Material if it (a) is - or becomes a part of the public domain through no act or omission of Licensee; or (b) was in - Licensee's lawful possession prior to the disclosure and had not been obtained by Licensee from - Magento; or (c) is lawfully disclosed to Licensee by a third party without restriction on disclosure; or - (d) is independently developed by Licensee without reference to or use of Magento's Proprietary - Material. - - "Server" means each physical or virtual server from which a single instance of the Software is - accessed and used either for production purposes ("Production Server Instance") or for non- - production purposes, such as development, testing, training and other non-operational business - transactions ("Non-Production Server Instance"). For example, if one server contains two (2) - instances of the Software, i.e., one Production Server Instance and one Non-Production Server - Instance, then a Server license is required for each of such instances; development in-house and by - third-party consultants requires licenses for two Non-Production Server Instances. - - "Software" means Magento's proprietary e-commerce software solution known as the Magento(tm) - Enterprise Edition, provided solely in source code, including associated technical documentation, - and all Updates thereof furnished to Licensee as part of Support Services. Except as otherwise - specified herein, the term Software includes certain open source software programs described in - Section 4.2. "Software" does not include any Modifications. - - "Updates" means all published revisions and corrections to the printed documentation and - corrections and new releases of the Software which are generally made available to Magento's - supported customers at no additional cost or for media and handling charges only. Updates shall not - include any options or future products which Magento sells separately. - - -SUPPORT SERVICES TERMS AND CONDITIONS - -Unless otherwise defined herein, all capitalized terms will have the meanings set forth in the -Agreement. - -1. "Support Services" consists of: - a. Advice regarding the downloading, installation and configuration of the Software (including - Updates provided by Magento, but excluding for the avoidance of doubt any Modifications to - the Software), when used by Licensee on systems that meet the Software's "System - Requirements" specified on Magento's website at www.magentocommerce.com/system- - requirements. - - b. Facilities for bug tracking, escalation of problems for priority attention, and access to - community-supported FAQs and Forums relating to the Software. - - c. Assistance with troubleshooting to diagnose and fix errors in the Software. - - d. Access to Magento documentation relating to the Software, including authorization to make - copies of that documentation for internal use as specified in the Agreement. - -2. Exclusions from Support Services. - Magento shall have no obligation to support (i) versions of the - Software other than the then-current and immediately previous releases, which are operated on a - supported hardware/operating system platform specified in the release notes for the Software; (ii) - altered or modified Software; (iii) Software accessed on unlicensed Servers; (iv) problems caused by - Licensee's negligence, misuse, or hardware malfunction; or (v) use of the Software inconsistent with - Magento's instructions. Magento is not responsible for hardware changes necessitated by changes - to the Software. Support Services does not include: - a. Assistance in the development or debugging of Licensee's system, including the operating - system and support tools. - - b. Information and assistance on technical issues related to the installation, administration, and - use of enabling technologies such as databases, computer networks, and communications. - - c. Assistance with the installation and configuration of hardware including, but not limited to - computers, hard disks, networks, and printers. - -3. Subcontractors. - Magento or its authorized resellers reserve the right to subcontract any or all of - the work to be performed under these Support Terms, and Magento retains responsibility for any - work so subcontracted. - -4. Licensee Responsibilities. - Licensee shall provide commercially reasonable cooperation and full - information to Magento or its authorized resellers with respect to the furnishing of Support Services - under this Agreement. - -5. Support Contacts. - Licensee shall designate one or more support contacts that are authorized to - submit Software problems. If Licensee has purchased the license from a Magento-authorized - reseller, Licensee shall contact that party for assistance. If Licensee has purchased the license - directly from Magento, Licensee may contact Magento on the www.magentocommere.com website - or at its toll-free Support telephone number. - -6. Problem Priority. - Upon receipt of a properly submitted Software problem, as specified on - Magento's website at www.magentocommerce.com, Magento or its authorized reseller shall - prioritize it in accordance with the guidelines below: - - a. Priority 1 (P1) - A P1 is a catastrophic production problem within the Software that severely - impacts the Licensee's Production Server Instance, or because of which Licensee's Production - Server Instance is down or not functioning, or that results in a loss of production data and no - work around exists. P1 problems must be reported on Magento's toll-free support telephone - number in order to expedite resolution. Magento will use continuous efforts during its normal - hours of operation, with appropriate escalation to senior management, to provide a resolution - for any P1 problem as soon as is commercially reasonable. - - b. Priority 2 (P2) - A P2 is a problem within the Software where the Licensee's system is - functioning but in a reduced capacity, or the Problem is causing significant impact to portions of - the Licensee's business operations and productivity, or the Software is exposed to potential loss - or interruption of service. Problems existing in a non-production environment that would - otherwise qualify as a P1 if they were in a production system qualify as P2. Magento will use - reasonable efforts during its normal hours of operation to provide a resolution for any P2 - problem as soon as is commercially reasonable. - - c. Priority 3 (P3) - A P3 is a medium-to-low impact problem that involves partial and/or non- - critical loss of functionality, or that impairs some operations but allows Licensee's operations to - continue to function. Problems for which there is limited or no loss or functionality or impact to - Licensee's operation and for which there is an easy work-around qualify as P3. Magento will use - reasonable efforts during its normal hours of operation to provide a resolution for any P3 - problem in time for the next minor release of the Software. - - d. Priority 4 (P4) - A P4 is for a general usage question or issue that may be cosmetic in nature - or documentation related, but the Software works without normal hours of operation to - provide a resolution for any P4 problem in time for the next major release of the Software. - - e. Enhancement Request (ER) - An ER is a recommendation for future product enhancement or - modification to add official support and documentation for unsupported or undocumented - feature, or features that do not exist in the Software. Magento will take ERs into consideration - in the product management process, but has no obligation to deliver enhancements based on - any ER. - -7. Response Times. - Magento or its authorized reseller shall exercise commercially reasonable efforts - to meet the response times specified below for Gold Support (unless Licensee has upgraded to - Platinum Support, as provided in the Magento Order Form), following receipt of a Software problem - properly submitted by Licensee: - - Magento GOLD Support Response Times - WEB Ticket Submission 24 x 7 x 365 - WEB Ticket Response Time* 24 business hours - North American Telephone Support Hours M-F 08:00 - 17:00 (PT) - European Telephone Support Hours M-F 08:30 - 17:30 (CET) - Telephone Response Time P1 Issues* 4 business hours - Response Time P2-P4 Issues* 24 business hours - *From initial contact - - - Magento PLATINUM Support Response Times - WEB Ticket Submission 24 x 7 x 365 - WEB Ticket Response Time* 24 business hours - Telephone Support Hours 24 hours - Telephone Response Time P1 Issues* Up to 2 hours - Response Time P2-P4 Issues* 4 business hours - *From initial contact - - -8. Prohibited Use. - As a condition of Licensee's use of the Forums, Licensee will not use (and will - prohibit its customers from using) the Forums (i) to violate any applicable law, statute, ordinance or - regulation; (ii) to disseminate content that is harmful, threatening, abusive, harassing, tortuous, - defamatory, vulgar, obscene, libelous, or otherwise objectionable; (iii) to disseminate any software - viruses or any other computer code, files or programs that may interrupt, destroy or limit the - functionality of any computer software or hardware or telecommunications equipment; (iv) to - infringe the intellectual property rights or proprietary rights, or rights of publicity or privacy, of any - third party; or (v) use the Forums for any purpose other than their intended use. - -9. Term and Termination. - Magento will provide Support Services and any Updates to Licensee - during the periods identified in the Magento Order Form, subject to Licensee's payment of the - applicable fees. In the event Licensee fails to pay such fees to Magento or in the event Licensee - materially breaches the Support Services provisions and does not cure such breach within thirty (30) - days of its receipt of Magento's notice of same, Magento may suspend or cancel Support Services. - -10. General. - Magento shall not be liable for any failure or delay in performance under these Support - Terms due to causes beyond its reasonable control. Any illegal or unenforceable provision shall be - severed from these Support Terms. Licensee agrees that any information received pursuant to these - Support Terms shall be deemed to be subject to the non-disclosure obligations set forth in the - License Agreement. Licensee's obligation of payment of moneys due under these Support Terms - shall survive termination of these Support Terms or the License Agreement. These Support Terms - state the entire agreement regarding provision of Support Services to Licensee and may be amended - only by a written amendment set forth on a separate document executed by authorized - representatives of both parties. From 6f213747b27f1fe4a1890cb0fc689896c4483cf5 Mon Sep 17 00:00:00 2001 From: yuri kovsher Date: Sun, 5 Jul 2015 19:37:07 +0300 Subject: [PATCH 53/56] MAGETWO-39631: Add Authorize.net payment method --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 4f974ab2e194e..09e5c89e60238 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "1260ae319e263c7debd87fb523d59246", + "hash": "3f06baff4c9942141e3922ea9d66fee7", "packages": [ { "name": "composer/composer", From 0b0c1b1f112c7754085209bcdb270d38c095ef08 Mon Sep 17 00:00:00 2001 From: Yuri Kovsher Date: Mon, 6 Jul 2015 19:04:16 +0300 Subject: [PATCH 54/56] MAGETWO-38793: PR prep and processing: Stories --- app/code/Magento/Sales/Model/Order/Payment.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 8fa7e5bd898c0..39d7be3556d6d 100755 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -310,6 +310,9 @@ public function place() $orderState = $order->getState() ? $order->getState() : $orderState; $orderStatus = $order->getStatus() ? $order->getStatus() : $orderStatus; } + } else { + $order->setState($orderState) + ->setStatus($orderStatus); } $isCustomerNotified = $isCustomerNotified ?: $order->getCustomerNoteNotify(); From 584cb228445d98a324d68088fa67282e3c43d8b7 Mon Sep 17 00:00:00 2001 From: yuri kovsher Date: Mon, 6 Jul 2015 20:57:28 +0300 Subject: [PATCH 55/56] MAGETWO-38793: PR prep and processing: Stories --- .../Magento/Sales/Test/Unit/Model/Order/PaymentTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php index 3448d9dc53d73..2612afa5dd8dd 100755 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -255,8 +255,12 @@ public function testPlace() ->method('getMethodInstance') ->will($this->returnValue($this->paymentMethodMock)); - $this->mockGetDefaultStatus(Order::STATE_NEW, $newOrderStatus, ['first', 'second']); + $this->paymentMethodMock->expects($this->any()) + ->method('getConfigData') + ->with('order_status', null) + ->willReturn($newOrderStatus); + $this->mockGetDefaultStatus(Order::STATE_NEW, $newOrderStatus, ['first', 'second']); $this->assertOrderUpdated(Order::STATE_NEW, $newOrderStatus); $this->paymentMethodMock->expects($this->once()) From 20e1959dd784bd6f7b20e8732a139a8041b6de92 Mon Sep 17 00:00:00 2001 From: Ian Daszkowski Date: Mon, 6 Jul 2015 15:33:28 -0500 Subject: [PATCH 56/56] MAGETWO-39478: Contribution Task -Fixed unit test --- .../Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index 54d8046c80dff..fc6914f44ad5a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -132,7 +132,7 @@ public function testNoFixtureConfigValue() public function testGetActionTitle() { - $this->assertSame('Generating shopping cart price rules', $this->model->getActionTitle()); + $this->assertSame('Generating Cart Price Rules', $this->model->getActionTitle()); } public function testIntroduceParamLabels()