diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index b93cb6688f56d826a8d981518612897aae6f1ac8..f4acc4504604d0625543812ecec21b1d90286e59 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -12,6 +12,9 @@ "magento/module-catalog": "101.1.*", "magento/framework": "100.2.*" }, + "suggest": { + "magento/module-config": "100.2.*" + }, "type": "magento2-module", "version": "100.2.0-dev", "license": [ diff --git a/app/code/Magento/Authorizenet/etc/di.xml b/app/code/Magento/Authorizenet/etc/di.xml index f5e595fb450e83a60a4ce9b45196018cad335f3d..287cdec6fa0f7f62d68e20bfb49254209ef16ca9 100644 --- a/app/code/Magento/Authorizenet/etc/di.xml +++ b/app/code/Magento/Authorizenet/etc/di.xml @@ -16,4 +16,14 @@ <argument name="storage" xsi:type="object">Magento\Authorizenet\Model\Directpost\Session\Storage</argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="payment/authorizenet_directpost/login" xsi:type="string">1</item> + <item name="payment/authorizenet_directpost/trans_key" xsi:type="string">1</item> + <item name="payment/authorizenet_directpost/trans_md5" xsi:type="string">1</item> + <item name="payment/authorizenet_directpost/merchant_email" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Backend/Block/Cache/Grid/Massaction/ProductionModeVisibilityChecker.php b/app/code/Magento/Backend/Block/Cache/Grid/Massaction/ProductionModeVisibilityChecker.php new file mode 100644 index 0000000000000000000000000000000000000000..70a125e399ab3034669c011ee24c3877154469e9 --- /dev/null +++ b/app/code/Magento/Backend/Block/Cache/Grid/Massaction/ProductionModeVisibilityChecker.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Backend\Block\Cache\Grid\Massaction; + +use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface; +use Magento\Framework\App\State; + +/** + * Class checks that action can be displayed on massaction list + */ +class ProductionModeVisibilityChecker implements VisibilityCheckerInterface +{ + /** + * @var State + */ + private $state; + + /** + * @param State $state + */ + public function __construct(State $state) + { + $this->state = $state; + } + + /** + * {@inheritdoc} + */ + public function isVisible() + { + return $this->state->getMode() !== State::MODE_PRODUCTION; + } +} diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php index ffe12c6cff46ee17442f7a69293172c02e206d30..c86907cc98042b30f6bac68ea0b0d2977ae87591 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php @@ -3,14 +3,11 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ +namespace Magento\Backend\Block\Widget\Grid; /** * Grid widget massaction default block - * - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Backend\Block\Widget\Grid; - class Massaction extends \Magento\Backend\Block\Widget\Grid\Massaction\AbstractMassaction { } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index 2f3df1377b395de426cc573f4d48016de82d7229..7f697599c7003583d08bc6c2f40ff138971bd4c0 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -5,14 +5,14 @@ */ namespace Magento\Backend\Block\Widget\Grid\Massaction; -use Magento\Framework\View\Element\Template; +use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; +use Magento\Framework\DataObject; /** * Grid widget massaction block * * @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors * @method boolean getHideFormElement() - * @author Magento Core Team <core@magentocommerce.com> */ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget { @@ -73,20 +73,21 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget * 'complete' => string, // Only for ajax enabled grid (optional) * 'url' => string, * 'confirm' => string, // text of confirmation of this action (optional) - * 'additional' => string // (optional) + * 'additional' => string, // (optional) + * 'visible' => object // instance of VisibilityCheckerInterface (optional) * ); * * @param string $itemId - * @param array|\Magento\Framework\DataObject $item + * @param array|DataObject $item * @return $this */ public function addItem($itemId, $item) { if (is_array($item)) { - $item = new \Magento\Framework\DataObject($item); + $item = new DataObject($item); } - if ($item instanceof \Magento\Framework\DataObject) { + if ($item instanceof DataObject && $this->isVisible($item)) { $item->setId($itemId); $item->setUrl($this->getUrl($item->getUrl())); $this->_items[$itemId] = $item; @@ -95,6 +96,19 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget return $this; } + /** + * Check that item can be added to list + * + * @param DataObject $item + * @return bool + */ + private function isVisible(DataObject $item) + { + /** @var VisibilityChecker $checker */ + $checker = $item->getData('visible'); + return (!$checker instanceof VisibilityChecker) || $checker->isVisible(); + } + /** * Retrieve massaction item with id $itemId * diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/VisibilityCheckerInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/VisibilityCheckerInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..934c4a84d145f349e028fc5497b9db62b2cdac54 --- /dev/null +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/VisibilityCheckerInterface.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Backend\Block\Widget\Grid\Massaction; + +use Magento\Framework\View\Element\Block\ArgumentInterface; + +interface VisibilityCheckerInterface extends ArgumentInterface +{ + /** + * Check that action can be displayed on massaction list + * + * @return bool + */ + public function isVisible(); +} diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php index 7266775959fc348796fabbb150f9e49b2ae9f7ad..42cbe229815aef16e13005ebdc802ec9b9bbd5c5 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php @@ -8,15 +8,41 @@ namespace Magento\Backend\Controller\Adminhtml\Cache; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\App\State; +use Magento\Framework\App\ObjectManager; +/** + * Controller disables some types of cache + */ class MassDisable extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * @var State + */ + private $state; + /** * Mass action for cache disabling * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() + { + if ($this->getState()->getMode() === State::MODE_PRODUCTION) { + $this->messageManager->addErrorMessage(__('You can\'t change status of cache type(s) in production mode')); + } else { + $this->disableCache(); + } + + return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('adminhtml/*'); + } + + /** + * Disable cache + * + * @return void + */ + private function disableCache() { try { $types = $this->getRequest()->getParam('types'); @@ -41,9 +67,20 @@ class MassDisable extends \Magento\Backend\Controller\Adminhtml\Cache } catch (\Exception $e) { $this->messageManager->addException($e, __('An error occurred while disabling cache.')); } + } + + /** + * Get State Instance + * + * @return State + * @deprecated + */ + private function getState() + { + if ($this->state === null) { + $this->state = ObjectManager::getInstance()->get(State::class); + } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - return $resultRedirect->setPath('adminhtml/*'); + return $this->state; } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php index 6c8bccfee166a5f746fd138c1b4e043ac1834542..8c4117831e8c8d7463b3112ac495cdede04f13d5 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php @@ -8,15 +8,41 @@ namespace Magento\Backend\Controller\Adminhtml\Cache; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\App\State; +use Magento\Framework\App\ObjectManager; +/** + * Controller enables some types of cache + */ class MassEnable extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * @var State + */ + private $state; + /** * Mass action for cache enabling * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() + { + if ($this->getState()->getMode() === State::MODE_PRODUCTION) { + $this->messageManager->addErrorMessage(__('You can\'t change status of cache type(s) in production mode')); + } else { + $this->enableCache(); + } + + return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('adminhtml/*'); + } + + /** + * Enable cache + * + * @return void + */ + private function enableCache() { try { $types = $this->getRequest()->getParam('types'); @@ -40,9 +66,20 @@ class MassEnable extends \Magento\Backend\Controller\Adminhtml\Cache } catch (\Exception $e) { $this->messageManager->addException($e, __('An error occurred while enabling cache.')); } + } + + /** + * Get State Instance + * + * @return State + * @deprecated + */ + private function getState() + { + if ($this->state === null) { + $this->state = ObjectManager::getInstance()->get(State::class); + } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - return $resultRedirect->setPath('adminhtml/*'); + return $this->state; } } diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php index 234e9d857549e073cb2fdba1bc39b3e4c7248349..79ecb388873eba21ed9fbfd166a651987194aa52 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php @@ -9,6 +9,8 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid; +use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; + class MassactionTest extends \PHPUnit_Framework_TestCase { /** @@ -17,12 +19,12 @@ class MassactionTest extends \PHPUnit_Framework_TestCase protected $_block; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject */ protected $_layoutMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Backend\Block\Widget\Grid|\PHPUnit_Framework_MockObject_MockObject */ protected $_gridMock; @@ -32,63 +34,63 @@ class MassactionTest extends \PHPUnit_Framework_TestCase protected $_eventManagerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Backend\Model\Url|\PHPUnit_Framework_MockObject_MockObject */ protected $_urlModelMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $_requestMock; + /** + * @var VisibilityChecker|\PHPUnit_Framework_MockObject_MockObject + */ + private $visibilityCheckerMock; + protected function setUp() { - $this->_gridMock = $this->getMock( - \Magento\Backend\Block\Widget\Grid::class, - ['getId', 'getCollection'], - [], - '', - false - ); - $this->_gridMock->expects($this->any())->method('getId')->will($this->returnValue('test_grid')); - - $this->_layoutMock = $this->getMock( - \Magento\Framework\View\Layout::class, - ['getParentName', 'getBlock', 'helper'], - [], - '', - false, - false - ); + $this->_gridMock = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->setMethods(['getId', 'getCollection']) + ->getMock(); + $this->_gridMock->expects($this->any()) + ->method('getId') + ->willReturn('test_grid'); - $this->_layoutMock->expects( - $this->any() - )->method( - 'getParentName' - )->with( - 'test_grid_massaction' - )->will( - $this->returnValue('test_grid') - ); - $this->_layoutMock->expects( - $this->any() - )->method( - 'getBlock' - )->with( - 'test_grid' - )->will( - $this->returnValue($this->_gridMock) - ); + $this->_layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->setMethods(['getParentName', 'getBlock', 'helper']) + ->getMock(); + $this->_layoutMock->expects($this->any()) + ->method('getParentName') + ->with('test_grid_massaction') + ->willReturn('test_grid'); + $this->_layoutMock->expects($this->any()) + ->method('getBlock') + ->with('test_grid') + ->willReturn($this->_gridMock); + + $this->_requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); - $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->_urlModelMock = $this->getMockBuilder(\Magento\Backend\Model\Url::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); - $this->_urlModelMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); + $this->visibilityCheckerMock = $this->getMockBuilder(VisibilityChecker::class) + ->getMockForAbstractClass(); $arguments = [ 'layout' => $this->_layoutMock, 'request' => $this->_requestMock, 'urlBuilder' => $this->_urlModelMock, - 'data' => ['massaction_id_field' => 'test_id', 'massaction_id_filter' => 'test_id'], + 'data' => ['massaction_id_field' => 'test_id', 'massaction_id_filter' => 'test_id'] ]; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -124,26 +126,24 @@ class MassactionTest extends \PHPUnit_Framework_TestCase } /** - * @param $itemId - * @param $item + * @param string $itemId + * @param \Magento\Framework\DataObject $item * @param $expectedItem \Magento\Framework\DataObject - * @dataProvider itemsDataProvider + * @dataProvider itemsProcessingDataProvider */ public function testItemsProcessing($itemId, $item, $expectedItem) { - $this->_urlModelMock->expects( - $this->any() - )->method( - 'getBaseUrl' - )->will( - $this->returnValue('http://localhost/index.php') - ); + $this->_urlModelMock->expects($this->any()) + ->method('getBaseUrl') + ->willReturn('http://localhost/index.php'); $urlReturnValueMap = [ ['*/*/test1', [], 'http://localhost/index.php/backend/admin/test/test1'], ['*/*/test2', [], 'http://localhost/index.php/backend/admin/test/test2'], ]; - $this->_urlModelMock->expects($this->any())->method('getUrl')->will($this->returnValueMap($urlReturnValueMap)); + $this->_urlModelMock->expects($this->any()) + ->method('getUrl') + ->willReturnMap($urlReturnValueMap); $this->_block->addItem($itemId, $item); $this->assertEquals(1, $this->_block->getCount()); @@ -157,7 +157,10 @@ class MassactionTest extends \PHPUnit_Framework_TestCase $this->assertNull($this->_block->getItem($itemId)); } - public function itemsDataProvider() + /** + * @return array + */ + public function itemsProcessingDataProvider() { return [ [ @@ -186,22 +189,17 @@ class MassactionTest extends \PHPUnit_Framework_TestCase } /** - * @param $param - * @param $expectedJson - * @param $expected + * @param string $param + * @param string $expectedJson + * @param array $expected * @dataProvider selectedDataProvider */ public function testSelected($param, $expectedJson, $expected) { - $this->_requestMock->expects( - $this->any() - )->method( - 'getParam' - )->with( - $this->_block->getFormFieldNameInternal() - )->will( - $this->returnValue($param) - ); + $this->_requestMock->expects($this->any()) + ->method('getParam') + ->with($this->_block->getFormFieldNameInternal()) + ->willReturn($param); $this->assertEquals($expectedJson, $this->_block->getSelectedJson()); $this->assertEquals($expected, $this->_block->getSelected()); @@ -262,6 +260,9 @@ class MassactionTest extends \PHPUnit_Framework_TestCase $this->assertEquals($result, $this->_block->getGridIdsJson()); } + /** + * @return array + */ public function dataProviderGetGridIdsJsonWithUseSelectAll() { return [ @@ -279,4 +280,71 @@ class MassactionTest extends \PHPUnit_Framework_TestCase ], ]; } + + /** + * @param string $itemId + * @param array|\Magento\Framework\DataObject $item + * @param int $count + * @param bool $withVisibilityChecker + * @param bool $isVisible + * @dataProvider addItemDataProvider + */ + public function testAddItem($itemId, $item, $count, $withVisibilityChecker, $isVisible) + { + $this->visibilityCheckerMock->expects($this->any()) + ->method('isVisible') + ->willReturn($isVisible); + + if ($withVisibilityChecker) { + $item['visible'] = $this->visibilityCheckerMock; + } + + $urlReturnValueMap = [ + ['*/*/test1', [], 'http://localhost/index.php/backend/admin/test/test1'], + ['*/*/test2', [], 'http://localhost/index.php/backend/admin/test/test2'], + ]; + $this->_urlModelMock->expects($this->any()) + ->method('getUrl') + ->willReturnMap($urlReturnValueMap); + + $this->_block->addItem($itemId, $item); + $this->assertEquals($count, $this->_block->getCount()); + } + + /** + * @return array + */ + public function addItemDataProvider() + { + return [ + [ + 'itemId' => 'test1', + 'item' => ['label' => 'Test 1', 'url' => '*/*/test1'], + 'count' => 1, + 'withVisibilityChecker' => false, + '$isVisible' => false, + ], + [ + 'itemId' => 'test2', + 'item' => ['label' => 'Test 2', 'url' => '*/*/test2'], + 'count' => 1, + 'withVisibilityChecker' => false, + 'isVisible' => true, + ], + [ + 'itemId' => 'test1', + 'item' => ['label' => 'Test 1. Hide', 'url' => '*/*/test1'], + 'count' => 0, + 'withVisibilityChecker' => true, + 'isVisible' => false, + ], + [ + 'itemId' => 'test2', + 'item' => ['label' => 'Test 2. Does not hide', 'url' => '*/*/test2'], + 'count' => 1, + 'withVisibilityChecker' => true, + 'isVisible' => true, + ] + ]; + } } diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b2fc808b0e237b8bbeb5b323fb173ecff67d8071 --- /dev/null +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php @@ -0,0 +1,224 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Backend\Test\Unit\Controller\Adminhtml\Cache; + +use PHPUnit_Framework_MockObject_MockObject as MockObject; +use Magento\Backend\Controller\Adminhtml\Cache\MassDisable; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\App\State; +use Magento\Backend\App\Action\Context; +use Magento\Framework\Message\ManagerInterface as MessageManager; +use Magento\Framework\Controller\ResultFactory; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Framework\App\RequestInterface as Request; +use Magento\Framework\App\Cache\TypeListInterface as CacheTypeList; +use Magento\Framework\App\Cache\StateInterface as CacheState; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class MassDisableTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MassDisable + */ + private $controller; + + /** + * @var State|MockObject + */ + private $stateMock; + + /** + * @var MessageManager|MockObject + */ + private $messageManagerMock; + + /** + * @var Redirect|MockObject + */ + private $redirectMock; + + /** + * @var Request|MockObject + */ + private $requestMock; + + /** + * @var CacheTypeList|MockObject + */ + private $cacheTypeListMock; + + /** + * @var CacheState|MockObject + */ + private $cacheStateMock; + + protected function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + + $this->stateMock = $this->getMockBuilder(State::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + + $this->messageManagerMock = $this->getMockBuilder(MessageManager::class) + ->getMockForAbstractClass(); + + $this->requestMock = $this->getMockBuilder(Request::class) + ->getMockForAbstractClass(); + + $this->cacheTypeListMock = $this->getMockBuilder(CacheTypeList::class) + ->getMockForAbstractClass(); + + $this->cacheStateMock = $this->getMockBuilder(CacheState::class) + ->getMockForAbstractClass(); + + $this->redirectMock = $this->getMockBuilder(Redirect::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + $this->redirectMock->expects($this->once()) + ->method('setPath') + ->with('adminhtml/*') + ->willReturnSelf(); + $resultFactoryMock = $this->getMockBuilder(ResultFactory::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + $resultFactoryMock->expects($this->once()) + ->method('create') + ->with(ResultFactory::TYPE_REDIRECT) + ->willReturn($this->redirectMock); + + $contextMock = $this->getMockBuilder(Context::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + $contextMock->expects($this->once()) + ->method('getMessageManager') + ->willReturn($this->messageManagerMock); + $contextMock->expects($this->once()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + $contextMock->expects($this->once()) + ->method('getRequest') + ->willReturn($this->requestMock); + + $this->controller = $objectManagerHelper->getObject( + MassDisable::class, + [ + 'context' => $contextMock, + 'cacheTypeList' => $this->cacheTypeListMock, + 'cacheState' => $this->cacheStateMock + ] + ); + $objectManagerHelper->setBackwardCompatibleProperty($this->controller, 'state', $this->stateMock); + } + + public function testExecuteInProductionMode() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_PRODUCTION); + + $this->messageManagerMock->expects($this->once()) + ->method('addErrorMessage') + ->with('You can\'t change status of cache type(s) in production mode', null) + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } + + public function testExecuteInvalidTypeCache() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->cacheTypeListMock->expects($this->once()) + ->method('getTypes') + ->willReturn([ + 'pageCache' => [ + 'id' => 'pageCache', + 'label' => 'Cache of Page' + ] + ]); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('types') + ->willReturn(['someCache']); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Specified cache type(s) don\'t exist: someCache') + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } + + public function testExecuteWithException() + { + $exception = new \Exception(); + + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->willThrowException($exception); + + $this->messageManagerMock->expects($this->once()) + ->method('addException') + ->with($exception, 'An error occurred while disabling cache.') + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } + + public function testExecuteSuccess() + { + $cacheType = 'pageCache'; + + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->cacheTypeListMock->expects($this->once()) + ->method('getTypes') + ->willReturn([ + 'pageCache' => [ + 'id' => 'pageCache', + 'label' => 'Cache of Page' + ] + ]); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('types') + ->willReturn([$cacheType]); + + $this->cacheStateMock->expects($this->once()) + ->method('isEnabled') + ->with($cacheType) + ->willReturn(true); + $this->cacheStateMock->expects($this->once()) + ->method('setEnabled') + ->with($cacheType, false); + $this->cacheStateMock->expects($this->once()) + ->method('persist'); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('1 cache type(s) disabled.') + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } +} diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8c1b9f1718ab924379cf3e5440a942c0be5502d7 --- /dev/null +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php @@ -0,0 +1,224 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Backend\Test\Unit\Controller\Adminhtml\Cache; + +use PHPUnit_Framework_MockObject_MockObject as MockObject; +use Magento\Backend\Controller\Adminhtml\Cache\MassEnable; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\App\State; +use Magento\Backend\App\Action\Context; +use Magento\Framework\Message\ManagerInterface as MessageManager; +use Magento\Framework\Controller\ResultFactory; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Framework\App\RequestInterface as Request; +use Magento\Framework\App\Cache\TypeListInterface as CacheTypeList; +use Magento\Framework\App\Cache\StateInterface as CacheState; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class MassEnableTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MassEnable + */ + private $controller; + + /** + * @var State|MockObject + */ + private $stateMock; + + /** + * @var MessageManager|MockObject + */ + private $messageManagerMock; + + /** + * @var Redirect|MockObject + */ + private $redirectMock; + + /** + * @var Request|MockObject + */ + private $requestMock; + + /** + * @var CacheTypeList|MockObject + */ + private $cacheTypeListMock; + + /** + * @var CacheState|MockObject + */ + private $cacheStateMock; + + protected function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + + $this->stateMock = $this->getMockBuilder(State::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + + $this->messageManagerMock = $this->getMockBuilder(MessageManager::class) + ->getMockForAbstractClass(); + + $this->requestMock = $this->getMockBuilder(Request::class) + ->getMockForAbstractClass(); + + $this->cacheTypeListMock = $this->getMockBuilder(CacheTypeList::class) + ->getMockForAbstractClass(); + + $this->cacheStateMock = $this->getMockBuilder(CacheState::class) + ->getMockForAbstractClass(); + + $this->redirectMock = $this->getMockBuilder(Redirect::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + $this->redirectMock->expects($this->once()) + ->method('setPath') + ->with('adminhtml/*') + ->willReturnSelf(); + $resultFactoryMock = $this->getMockBuilder(ResultFactory::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + $resultFactoryMock->expects($this->once()) + ->method('create') + ->with(ResultFactory::TYPE_REDIRECT) + ->willReturn($this->redirectMock); + + $contextMock = $this->getMockBuilder(Context::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->getMock(); + $contextMock->expects($this->once()) + ->method('getMessageManager') + ->willReturn($this->messageManagerMock); + $contextMock->expects($this->once()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + $contextMock->expects($this->once()) + ->method('getRequest') + ->willReturn($this->requestMock); + + $this->controller = $objectManagerHelper->getObject( + MassEnable::class, + [ + 'context' => $contextMock, + 'cacheTypeList' => $this->cacheTypeListMock, + 'cacheState' => $this->cacheStateMock + ] + ); + $objectManagerHelper->setBackwardCompatibleProperty($this->controller, 'state', $this->stateMock); + } + + public function testExecuteInProductionMode() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_PRODUCTION); + + $this->messageManagerMock->expects($this->once()) + ->method('addErrorMessage') + ->with('You can\'t change status of cache type(s) in production mode', null) + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } + + public function testExecuteInvalidTypeCache() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->cacheTypeListMock->expects($this->once()) + ->method('getTypes') + ->willReturn([ + 'pageCache' => [ + 'id' => 'pageCache', + 'label' => 'Cache of Page' + ] + ]); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('types') + ->willReturn(['someCache']); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Specified cache type(s) don\'t exist: someCache') + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } + + public function testExecuteWithException() + { + $exception = new \Exception(); + + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->willThrowException($exception); + + $this->messageManagerMock->expects($this->once()) + ->method('addException') + ->with($exception, 'An error occurred while enabling cache.') + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } + + public function testExecuteSuccess() + { + $cacheType = 'pageCache'; + + $this->stateMock->expects($this->once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->cacheTypeListMock->expects($this->once()) + ->method('getTypes') + ->willReturn([ + 'pageCache' => [ + 'id' => 'pageCache', + 'label' => 'Cache of Page' + ] + ]); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('types') + ->willReturn([$cacheType]); + + $this->cacheStateMock->expects($this->once()) + ->method('isEnabled') + ->with($cacheType) + ->willReturn(false); + $this->cacheStateMock->expects($this->once()) + ->method('setEnabled') + ->with($cacheType, true); + $this->cacheStateMock->expects($this->once()) + ->method('persist'); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('1 cache type(s) enabled.') + ->willReturnSelf(); + + $this->assertSame($this->redirectMock, $this->controller->execute()); + } +} diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 8b52d08da48fbbd8fd1cf450bb8a2db66ca75b62..c0c5a0ec5b8a7ff217fcf0bb1772cb932f14bc55 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -213,4 +213,22 @@ </argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="trans_email/ident_general/name" xsi:type="string">1</item> + <item name="trans_email/ident_general/email" xsi:type="string">1</item> + <item name="trans_email/ident_sales/name" xsi:type="string">1</item> + <item name="trans_email/ident_sales/email" xsi:type="string">1</item> + <item name="trans_email/ident_support/name" xsi:type="string">1</item> + <item name="trans_email/ident_support/email" xsi:type="string">1</item> + <item name="trans_email/ident_custom1/name" xsi:type="string">1</item> + <item name="trans_email/ident_custom1/email" xsi:type="string">1</item> + <item name="trans_email/ident_custom2/name" xsi:type="string">1</item> + <item name="trans_email/ident_custom2/email" xsi:type="string">1</item> + <item name="admin/url/custom" xsi:type="string">1</item> + <item name="admin/url/custom_path" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_block.xml b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_block.xml index decc26f331c8298d16b4a76d4a74d82c5808c651..98f9ca89ba18accc9013c7b0851e39abafa517b2 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_block.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_block.xml @@ -23,10 +23,12 @@ <item name="enable" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Enable</item> <item name="url" xsi:type="string">adminhtml/*/massEnable</item> + <item name="visible" xsi:type="object">Magento\Backend\Block\Cache\Grid\Massaction\ProductionModeVisibilityChecker</item> </item> <item name="disable" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Disable</item> <item name="url" xsi:type="string">adminhtml/*/massDisable</item> + <item name="visible" xsi:type="object">Magento\Backend\Block\Cache\Grid\Massaction\ProductionModeVisibilityChecker</item> </item> <item name="refresh" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Refresh</item> diff --git a/app/code/Magento/Braintree/etc/di.xml b/app/code/Magento/Braintree/etc/di.xml index d051ef78cfcd22424fa359e47be3efc0ee8dcc2b..5417c96ba677204a0c3c3ffc69cefdc27f148ee3 100644 --- a/app/code/Magento/Braintree/etc/di.xml +++ b/app/code/Magento/Braintree/etc/di.xml @@ -365,7 +365,7 @@ </arguments> </virtualType> <!-- END PayPal commands --> - + <!-- Value handlers infrastructure --> <type name="Magento\Braintree\Gateway\Response\VaultDetailsHandler"> <arguments> @@ -452,7 +452,7 @@ </arguments> </virtualType> <!-- END PayPal value handlers infrastructure --> - + <!-- Void Command --> <virtualType name="BraintreeVoidCommand" type="Magento\Payment\Gateway\Command\GatewayCommand"> <arguments> @@ -544,4 +544,16 @@ </arguments> </type> <!-- END Settlement Report Section --> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="payment/braintree/merchant_id" xsi:type="string">1</item> + <item name="payment/braintree/public_key" xsi:type="string">1</item> + <item name="payment/braintree/private_key" xsi:type="string">1</item> + <item name="payment/braintree/merchant_account_id" xsi:type="string">1</item> + <item name="payment/braintree/kount_id" xsi:type="string">1</item> + <item name="payment/braintree_paypal/merchant_name_override" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/StatusBaseSelectProcessor.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/StatusBaseSelectProcessor.php index 656998113fdb92e50e5177db4876651cfcd2023a..b4293a39895850fb349a6232e0c5b95fc1dfa50f 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/StatusBaseSelectProcessor.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/StatusBaseSelectProcessor.php @@ -11,6 +11,8 @@ use Magento\Catalog\Model\Product\Attribute\Source\Status; use Magento\Eav\Model\Config; use Magento\Framework\DB\Select; use Magento\Framework\EntityManager\MetadataPool; +use Magento\Store\Api\StoreResolverInterface; +use Magento\Store\Model\Store; /** * Class StatusBaseSelectProcessor @@ -27,16 +29,24 @@ class StatusBaseSelectProcessor implements BaseSelectProcessorInterface */ private $metadataPool; + /** + * @var StoreResolverInterface + */ + private $storeResolver; + /** * @param Config $eavConfig * @param MetadataPool $metadataPool + * @param StoreResolverInterface $storeResolver */ public function __construct( Config $eavConfig, - MetadataPool $metadataPool + MetadataPool $metadataPool, + StoreResolverInterface $storeResolver ) { $this->eavConfig = $eavConfig; $this->metadataPool = $metadataPool; + $this->storeResolver = $storeResolver; } /** @@ -48,13 +58,23 @@ class StatusBaseSelectProcessor implements BaseSelectProcessorInterface $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); $statusAttribute = $this->eavConfig->getAttribute(Product::ENTITY, ProductInterface::STATUS); - $select->join( + $select->joinLeft( + ['status_global_attr' => $statusAttribute->getBackendTable()], + "status_global_attr.{$linkField} = " . self::PRODUCT_TABLE_ALIAS . ".{$linkField}" + . ' AND status_global_attr.attribute_id = ' . (int)$statusAttribute->getAttributeId() + . ' AND status_global_attr.store_id = ' . Store::DEFAULT_STORE_ID, + [] + ); + + $select->joinLeft( ['status_attr' => $statusAttribute->getBackendTable()], - sprintf('status_attr.%s = %s.%1$s', $linkField, self::PRODUCT_TABLE_ALIAS), + "status_attr.{$linkField} = " . self::PRODUCT_TABLE_ALIAS . ".{$linkField}" + . ' AND status_attr.attribute_id = ' . (int)$statusAttribute->getAttributeId() + . ' AND status_attr.store_id = ' . $this->storeResolver->getCurrentStoreId(), [] - ) - ->where('status_attr.attribute_id = ?', $statusAttribute->getAttributeId()) - ->where('status_attr.value = ?', Status::STATUS_ENABLED); + ); + + $select->where('IFNULL(status_attr.value, status_global_attr.value) = ?', Status::STATUS_ENABLED); return $select; } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php index 0909f754a01c2c937e8c3692c52b1a256a27b0c3..1fada997913b620de06ddedcbffb3fdcdea92620 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php @@ -16,7 +16,12 @@ use Magento\Framework\DB\Select; use Magento\Framework\EntityManager\EntityMetadataInterface; use Magento\Framework\EntityManager\MetadataPool; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Store\Api\StoreResolverInterface; +use Magento\Store\Model\Store; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class StatusBaseSelectProcessorTest extends \PHPUnit_Framework_TestCase { /** @@ -29,6 +34,11 @@ class StatusBaseSelectProcessorTest extends \PHPUnit_Framework_TestCase */ private $metadataPool; + /** + * @var StoreResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $storeResolver; + /** * @var Select|\PHPUnit_Framework_MockObject_MockObject */ @@ -43,11 +53,13 @@ class StatusBaseSelectProcessorTest extends \PHPUnit_Framework_TestCase { $this->eavConfig = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); $this->metadataPool = $this->getMockBuilder(MetadataPool::class)->disableOriginalConstructor()->getMock(); + $this->storeResolver = $this->getMockBuilder(StoreResolverInterface::class)->getMock(); $this->select = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock(); $this->statusBaseSelectProcessor = (new ObjectManager($this))->getObject(StatusBaseSelectProcessor::class, [ 'eavConfig' => $this->eavConfig, 'metadataPool' => $this->metadataPool, + 'storeResolver' => $this->storeResolver, ]); } @@ -55,7 +67,8 @@ class StatusBaseSelectProcessorTest extends \PHPUnit_Framework_TestCase { $linkField = 'link_field'; $backendTable = 'backend_table'; - $attributeId = 'attribute_id'; + $attributeId = 2; + $currentStoreId = 1; $metadata = $this->getMock(EntityMetadataInterface::class); $metadata->expects($this->once()) @@ -66,13 +79,14 @@ class StatusBaseSelectProcessorTest extends \PHPUnit_Framework_TestCase ->with(ProductInterface::class) ->willReturn($metadata); + /** @var AttributeInterface|\PHPUnit_Framework_MockObject_MockObject $statusAttribute */ $statusAttribute = $this->getMockBuilder(AttributeInterface::class) ->setMethods(['getBackendTable', 'getAttributeId']) ->getMock(); - $statusAttribute->expects($this->once()) + $statusAttribute->expects($this->atLeastOnce()) ->method('getBackendTable') ->willReturn($backendTable); - $statusAttribute->expects($this->once()) + $statusAttribute->expects($this->atLeastOnce()) ->method('getAttributeId') ->willReturn($attributeId); $this->eavConfig->expects($this->once()) @@ -80,21 +94,34 @@ class StatusBaseSelectProcessorTest extends \PHPUnit_Framework_TestCase ->with(Product::ENTITY, ProductInterface::STATUS) ->willReturn($statusAttribute); - $this->select->expects($this->once()) - ->method('join') + $this->storeResolver->expects($this->once()) + ->method('getCurrentStoreId') + ->willReturn($currentStoreId); + + $this->select->expects($this->at(0)) + ->method('joinLeft') ->with( - ['status_attr' => $backendTable], - sprintf('status_attr.%s = %s.%1$s', $linkField, BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS), + ['status_global_attr' => $backendTable], + "status_global_attr.{$linkField} = " + . BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS . ".{$linkField}" + . " AND status_global_attr.attribute_id = {$attributeId}" + . ' AND status_global_attr.store_id = ' . Store::DEFAULT_STORE_ID, [] ) ->willReturnSelf(); $this->select->expects($this->at(1)) - ->method('where') - ->with('status_attr.attribute_id = ?', $attributeId) + ->method('joinLeft') + ->with( + ['status_attr' => $backendTable], + "status_attr.{$linkField} = " . BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS . ".{$linkField}" + . " AND status_attr.attribute_id = {$attributeId}" + . " AND status_attr.store_id = {$currentStoreId}", + [] + ) ->willReturnSelf(); $this->select->expects($this->at(2)) ->method('where') - ->with('status_attr.value = ?', Status::STATUS_ENABLED) + ->with('IFNULL(status_attr.value, status_global_attr.value) = ?', Status::STATUS_ENABLED) ->willReturnSelf(); $this->assertEquals($this->select, $this->statusBaseSelectProcessor->process($this->select)); diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index 4e8b95607de4b26a0bde1cbde918a93119ebdc4d..8a820fd5846e38bb3ed907fbf9020ccaf9dbd448 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -567,14 +567,8 @@ class Rule extends \Magento\Rule\Model\AbstractModel implements RuleInterface, I $result = []; foreach ($array1 as $key => $value) { if (array_key_exists($key, $array2)) { - if (is_array($value)) { - if ($value != $array2[$key]) { - $result[$key] = true; - } - } else { - if ($value != $array2[$key]) { - $result[$key] = true; - } + if ($value != $array2[$key]) { + $result[$key] = true; } } else { $result[$key] = true; diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php index a0f988276fd792696d65dedd1ad7f5d55838b9e1..25b8900db8f48e257cdf0ad99267ec862d9fc494 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php @@ -115,7 +115,7 @@ class Decimal extends AbstractFilter } $label = $this->renderRangeLabel( empty($from) ? 0 : $from, - empty($to) ? $to : $to + empty($to) ? 0 : $to ); $value = $from . '-' . $to; diff --git a/app/code/Magento/Checkout/etc/di.xml b/app/code/Magento/Checkout/etc/di.xml index a2243b33a04edc0af4dc71ed79b802eac68f4cc2..81a430d52c49933cf70013f8856a96f5b6c26377 100644 --- a/app/code/Magento/Checkout/etc/di.xml +++ b/app/code/Magento/Checkout/etc/di.xml @@ -42,4 +42,11 @@ </argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="checkout/payment_failed/copy_to" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Checkout/view/frontend/web/template/summary/cart-items.html b/app/code/Magento/Checkout/view/frontend/web/template/summary/cart-items.html index ed7ad193a12fde35dd2226afdf11f1233887afd8..498a9f852d06be2cc5787091aca7b641b7a45e8a 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/summary/cart-items.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/summary/cart-items.html @@ -4,8 +4,7 @@ * See COPYING.txt for license details. */ --> -<!-- ko ifnot: isItemsBlockExpanded() --> -<div class="block items-in-cart" data-bind="mageInit: {'collapsible':{'openedState': 'active'}}"> +<div class="block items-in-cart" data-bind="mageInit: {'collapsible':{'openedState': 'active', 'active': isItemsBlockExpanded()}}"> <div class="title" data-role="title"> <strong role="heading"><span data-bind="text: getItemsQty()"></span> <!-- ko if: getItemsQty() == 1 --> @@ -32,33 +31,3 @@ </div> </div> </div> -<!-- /ko --> -<!-- ko if: isItemsBlockExpanded() --> -<div class="block items-in-cart" data-bind="mageInit: {'collapsible':{'openedState': 'active', 'active': true}}"> - <div class="title" data-role="title"> - <strong role="heading"><span data-bind="text: getItemsQty()"></span> - <!-- ko if: getItemsQty() == 1 --> - <!-- ko i18n: 'Item in Cart' --><!-- /ko --> - <!-- /ko --> - <!-- ko if: getItemsQty() > 1 --> - <!-- ko i18n: 'Items in Cart' --><!-- /ko --> - <!-- /ko --> - </strong> - </div> - <div class="content minicart-items" data-role="content"> - <div class="minicart-items-wrapper overflowed"> - <ol class="minicart-items"> - <!-- ko foreach: getItems() --> - <li class="product-item"> - <div class="product"> - <!-- ko foreach: $parent.elems() --> - <!-- ko template: getTemplate() --><!-- /ko --> - <!-- /ko --> - </div> - </li> - <!-- /ko --> - </ol> - </div> - </div> -</div> -<!-- /ko --> diff --git a/app/code/Magento/Config/App/Config/Source/DumpConfigSourceAggregated.php b/app/code/Magento/Config/App/Config/Source/DumpConfigSourceAggregated.php new file mode 100644 index 0000000000000000000000000000000000000000..80567d0504ee9c31d8cadef957c1d12dad9f1508 --- /dev/null +++ b/app/code/Magento/Config/App/Config/Source/DumpConfigSourceAggregated.php @@ -0,0 +1,152 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\App\Config\Source; + +use Magento\Config\Model\Config\Export\ExcludeList; +use Magento\Framework\App\Config\ConfigSourceInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; + +/** + * Class DumpConfigSourceAggregated aggregates configurations from all available sources + */ +class DumpConfigSourceAggregated implements DumpConfigSourceInterface +{ + /** + * @var ExcludeList + */ + private $excludeList; + + /** + * @var ConfigSourceInterface[] + */ + private $sources; + + /** + * @var array + */ + private $excludedFields; + + /** + * @var array + */ + private $data; + + /** + * @param ExcludeList $excludeList + * @param array $sources + */ + public function __construct(ExcludeList $excludeList, array $sources = []) + { + $this->excludeList = $excludeList; + $this->sources = $sources; + } + + /** + * Retrieve aggregated configuration from all available sources. + * + * @param string $path + * @return array + */ + public function get($path = '') + { + $path = (string)$path; + $data = []; + + if (isset($this->data[$path])) { + return $this->data[$path]; + } + + $this->sortSources(); + + foreach ($this->sources as $sourceConfig) { + /** @var ConfigSourceInterface $source */ + $source = $sourceConfig['source']; + $data = array_replace_recursive($data, $source->get($path)); + } + + $this->excludedFields = []; + $this->filterChain($path, $data); + + return $this->data[$path] = $data; + } + + /** + * Recursive filtering of sensitive data + * + * @param string $path + * @param array $data + * @return void + */ + private function filterChain($path, &$data) + { + foreach ($data as $subKey => &$subData) { + $newPath = $path ? $path . '/' . $subKey : $subKey; + $filteredPath = $this->filterPath($newPath); + + if ( + $filteredPath + && !is_array($data[$subKey]) + && $this->excludeList->isPresent($filteredPath) + ) { + $this->excludedFields[$newPath] = $filteredPath; + + unset($data[$subKey]); + } elseif (is_array($subData)) { + $this->filterChain($newPath, $subData); + } + } + } + + /** + * Eliminating scope info from path + * + * @param string $path + * @return null|string + */ + private function filterPath($path) + { + $parts = explode('/', $path); + + // Check if there are enough parts to recognize scope + if (count($parts) < 3) { + return null; + } + + if ($parts[0] === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { + unset($parts[0]); + } else { + unset($parts[0], $parts[1]); + } + + return implode('/', $parts); + } + + /** + * Sort sources ASC from higher priority to lower + * + * @return void + */ + private function sortSources() + { + uasort($this->sources, function ($firstItem, $secondItem) { + return $firstItem['sortOrder'] > $secondItem['sortOrder']; + }); + } + + /** + * Retrieves list of field paths were excluded from config dump + * @return array + */ + public function getExcludedFields() + { + $this->get(); + + $fields = array_values($this->excludedFields); + $fields = array_unique($fields); + + return $fields; + } +} diff --git a/app/code/Magento/Config/App/Config/Source/DumpConfigSourceInterface.php b/app/code/Magento/Config/App/Config/Source/DumpConfigSourceInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..cf0ce492b7d5265a5445a3fbe3f4e6d68ec384a4 --- /dev/null +++ b/app/code/Magento/Config/App/Config/Source/DumpConfigSourceInterface.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\App\Config\Source; + +use Magento\Framework\App\Config\ConfigSourceInterface; + +/** + * Interface DumpConfigSourceInterface + */ +interface DumpConfigSourceInterface extends ConfigSourceInterface +{ + /** + * Retrieves list of field paths were excluded from config dump + * + * @return array + */ + public function getExcludedFields(); +} diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index 4a3c6da8379153a240e4869592fcef31788df608..a0fc0f1f10ebdfbbcd78695ee223e48efdd21b7a 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -6,18 +6,10 @@ namespace Magento\Config\App\Config\Type; use Magento\Framework\App\Config\ConfigTypeInterface; -use Magento\Framework\App\Config\ConfigSourceInterface; -use Magento\Framework\App\Config\Spi\PostProcessorInterface; -use Magento\Framework\Cache\FrontendInterface; use Magento\Framework\DataObject; -use Magento\Framework\Serialize\Serializer\Serialize; -use Magento\Framework\Serialize\SerializerInterface; -use Magento\Store\Model\Config\Processor\Fallback; /** * Class process source, cache them and retrieve value by path - * - * @package Magento\Config\App\Config\Type */ class System implements ConfigTypeInterface { @@ -26,7 +18,7 @@ class System implements ConfigTypeInterface const CONFIG_TYPE = 'system'; /** - * @var ConfigSourceInterface + * @var \Magento\Framework\App\Config\ConfigSourceInterface */ private $source; @@ -36,12 +28,17 @@ class System implements ConfigTypeInterface private $data; /** - * @var PostProcessorInterface + * @var \Magento\Framework\App\Config\Spi\PostProcessorInterface */ private $postProcessor; /** - * @var FrontendInterface + * @var \Magento\Framework\App\Config\Spi\PreProcessorInterface + */ + private $preProcessor; + + /** + * @var \Magento\Framework\Cache\FrontendInterface */ private $cache; @@ -51,34 +48,36 @@ class System implements ConfigTypeInterface private $cachingNestedLevel; /** - * @var Fallback + * @var \Magento\Store\Model\Config\Processor\Fallback */ private $fallback; /** - * @var Serialize + * @var \Magento\Framework\Serialize\SerializerInterface */ private $serializer; /** - * System constructor. - * @param ConfigSourceInterface $source - * @param PostProcessorInterface $postProcessor - * @param Fallback $fallback - * @param FrontendInterface $cache + * @param \Magento\Framework\App\Config\ConfigSourceInterface $source + * @param \Magento\Framework\App\Config\Spi\PostProcessorInterface $postProcessor + * @param \Magento\Store\Model\Config\Processor\Fallback $fallback + * @param \Magento\Framework\Cache\FrontendInterface $cache + * @param \Magento\Framework\Serialize\SerializerInterface $serializer + * @param \Magento\Framework\App\Config\Spi\PreProcessorInterface $preProcessor * @param int $cachingNestedLevel - * @param Serialize $serializer */ public function __construct( - ConfigSourceInterface $source, - PostProcessorInterface $postProcessor, - Fallback $fallback, - FrontendInterface $cache, - Serialize $serializer, + \Magento\Framework\App\Config\ConfigSourceInterface $source, + \Magento\Framework\App\Config\Spi\PostProcessorInterface $postProcessor, + \Magento\Store\Model\Config\Processor\Fallback $fallback, + \Magento\Framework\Cache\FrontendInterface $cache, + \Magento\Framework\Serialize\SerializerInterface $serializer, + \Magento\Framework\App\Config\Spi\PreProcessorInterface $preProcessor, $cachingNestedLevel = 1 ) { $this->source = $source; $this->postProcessor = $postProcessor; + $this->preProcessor = $preProcessor; $this->cache = $cache; $this->cachingNestedLevel = $cachingNestedLevel; $this->fallback = $fallback; @@ -96,7 +95,9 @@ class System implements ConfigTypeInterface if (!$this->data) { $data = $this->cache->load(self::CONFIG_TYPE); if (!$data) { - $data = $this->fallback->process($this->source->get()); + $data = $this->preProcessor->process($this->source->get()); + $this->data = new DataObject($data); + $data = $this->fallback->process($data); $this->data = new DataObject($data); //Placeholder processing need system config - so we need to save intermediate result $data = $this->postProcessor->process($data); diff --git a/app/code/Magento/Config/Block/System/Config/Form.php b/app/code/Magento/Config/Block/System/Config/Form.php index d1a0da2a700a3f628c83ac2d61029bc915cd3ba6..f0ad7e4a28b1a365b6596f7175ae34434e09e59c 100644 --- a/app/code/Magento/Config/Block/System/Config/Form.php +++ b/app/code/Magento/Config/Block/System/Config/Form.php @@ -7,8 +7,10 @@ namespace Magento\Config\Block\System\Config; use Magento\Config\App\Config\Type\System; use Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\ObjectManager; +use Magento\Framework\DataObject; /** * System config form block @@ -331,29 +333,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic $fieldPrefix = '', $labelPrefix = '' ) { - $inherit = true; - $data = $this->getAppConfigDataValue($path); - if ($data === null) { - if (array_key_exists($path, $this->_configData)) { - $data = $this->_configData[$path]; - $inherit = false; + $inherit = !array_key_exists($path, $this->_configData); + $data = $this->getFieldData($field, $path); - if ($field->hasBackendModel()) { - $backendModel = $field->getBackendModel(); - $backendModel->setPath($path) - ->setValue($data) - ->setWebsite($this->getWebsiteCode()) - ->setStore($this->getStoreCode()) - ->afterLoad(); - $data = $backendModel->getValue(); - } - - } elseif ($field->getConfigPath() !== null) { - $data = $this->getConfigValue($field->getConfigPath()); - } else { - $data = $this->getConfigValue($path); - } - } $fieldRendererClass = $field->getFrontendModel(); if ($fieldRendererClass) { $fieldRenderer = $this->_layout->getBlockSingleton($fieldRendererClass); @@ -373,9 +355,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic $sharedClass = $this->_getSharedCssClass($field); $requiresClass = $this->_getRequiresCssClass($field, $fieldPrefix); - $isReadOnly = $this->getSettingChecker()->isReadOnly($path, $this->getScope(), $this->getScopeCode()); - $canUseDefault = $this->canUseDefaultValue($field->showInDefault()); - $canUseWebsite = $this->canUseWebsiteValue($field->showInWebsite()); + $isReadOnly = $this->getSettingChecker()->isReadOnly($path, $this->getScope(), $this->getStringScopeCode()); $formField = $fieldset->addField( $elementId, $field->getType(), @@ -392,8 +372,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'scope_label' => $this->getScopeLabel($field), - 'can_use_default_value' => $canUseDefault, - 'can_use_website_value' => $canUseWebsite, + 'can_use_default_value' => $this->canUseDefaultValue($field->showInDefault()), + 'can_use_website_value' => $this->canUseWebsiteValue($field->showInWebsite()), 'can_restore_to_default' => $this->isCanRestoreToDefault($field->canRestore()), 'disabled' => $isReadOnly, 'is_disable_inheritance' => $isReadOnly @@ -413,6 +393,74 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic $formField->setRenderer($fieldRenderer); } + /** + * Get data of field by path + * + * @param \Magento\Config\Model\Config\Structure\Element\Field $field + * @param string $path + * @return mixed|null|string + */ + private function getFieldData(\Magento\Config\Model\Config\Structure\Element\Field $field, $path) + { + $data = $this->getAppConfigDataValue($path); + + $placeholderValue = $this->getSettingChecker()->getPlaceholderValue( + $path, + $this->getScope(), + $this->getStringScopeCode() + ); + + if ($placeholderValue) { + $data = $placeholderValue; + } + if ($data === null) { + if (array_key_exists($path, $this->_configData)) { + $data = $this->_configData[$path]; + + if ($field->hasBackendModel()) { + $backendModel = $field->getBackendModel(); + $backendModel->setPath($path) + ->setValue($data) + ->setWebsite($this->getWebsiteCode()) + ->setStore($this->getStoreCode()) + ->afterLoad(); + $data = $backendModel->getValue(); + } + + } elseif ($field->getConfigPath() !== null) { + $data = $this->getConfigValue($field->getConfigPath()); + } else { + $data = $this->getConfigValue($path); + } + } + + return $data; + } + + /** + * Retrieve Scope string code + * + * @return string + */ + private function getStringScopeCode() + { + $scopeCode = $this->getData('scope_string_code'); + + if (null === $scopeCode) { + if ($this->getStoreCode()) { + $scopeCode = $this->_storeManager->getStore($this->getStoreCode())->getCode(); + } elseif ($this->getWebsiteCode()) { + $scopeCode = $this->_storeManager->getWebsite($this->getWebsiteCode())->getCode(); + } else { + $scopeCode = ''; + } + + $this->setData('scope_string_code', $scopeCode); + } + + return $scopeCode; + } + /** * Populate dependencies block * @@ -748,14 +796,13 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic { $appConfig = $this->getAppConfig()->get(System::CONFIG_TYPE); $scope = $this->getScope(); - $scopeId = $this->getScopeId(); - if ($scope === 'default') { - $data = isset($appConfig[$scope][$path]) ? $appConfig[$scope][$path] : null; + $scopeCode = $this->getStringScopeCode(); + + if ($scope === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { + $data = new DataObject(isset($appConfig[$scope]) ? $appConfig[$scope] : []); } else { - $data = isset($appConfig[$scope][$scopeId][$path]) - ? $appConfig[$scope][$scopeId][$path] - : null; + $data = new DataObject(isset($appConfig[$scope][$scopeCode]) ? $appConfig[$scope][$scopeCode] : []); } - return $data; + return $data->getData($path); } } diff --git a/app/code/Magento/Config/Model/Config/Export/Comment.php b/app/code/Magento/Config/Model/Config/Export/Comment.php new file mode 100644 index 0000000000000000000000000000000000000000..ae0431c82daa031523f464ea1539209ca324996c --- /dev/null +++ b/app/code/Magento/Config/Model/Config/Export/Comment.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Model\Config\Export; + +use Magento\Config\App\Config\Source\DumpConfigSourceInterface; +use Magento\Config\Model\Placeholder\PlaceholderFactory; +use Magento\Config\Model\Placeholder\PlaceholderInterface; +use Magento\Framework\App\Config\CommentInterface; + +/** + * Class Comment. Is used to retrieve comment for config dump file + */ +class Comment implements CommentInterface +{ + /** + * @var PlaceholderInterface + */ + private $placeholder; + + /** + * @var DumpConfigSourceInterface + */ + private $source; + + /** + * @param PlaceholderFactory $placeholderFactory + * @param DumpConfigSourceInterface $source + */ + public function __construct( + PlaceholderFactory $placeholderFactory, + DumpConfigSourceInterface $source + ) { + $this->placeholder = $placeholderFactory->create(PlaceholderFactory::TYPE_ENVIRONMENT); + $this->source = $source; + } + + /** + * Retrieves comments for config export file. + * + * @return string + */ + public function get() + { + $comment = ''; + $fields = $this->source->getExcludedFields(); + foreach ($fields as $path) { + $comment .= "\n" . $this->placeholder->generate($path) . ' for ' . $path ; + } + if ($comment) { + $comment = 'The configuration file doesn\'t contain sensitive data for security reasons. ' + . 'Sensitive data can be stored in the following environment variables:' + . $comment; + } + return $comment; + } +} diff --git a/app/code/Magento/Config/Model/Config/Export/ExcludeList.php b/app/code/Magento/Config/Model/Config/Export/ExcludeList.php new file mode 100644 index 0000000000000000000000000000000000000000..f3c10b4100ed3a068b56873553c96e2e5852073b --- /dev/null +++ b/app/code/Magento/Config/Model/Config/Export/ExcludeList.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Model\Config\Export; + +use Magento\Framework\App\Config\ScopeConfigInterface; + +/** + * Class ExcludeList contains list of config fields which should be excluded from config export file + */ +class ExcludeList +{ + /** + * @var array + */ + private $configs; + + /** + * @param array $configs + */ + public function __construct(array $configs = []) + { + $this->configs = $configs; + } + + /** + * Check whether config item is excluded from export + * + * @param string $path + * @return bool + */ + public function isPresent($path) + { + return !empty($this->configs[$path]) ; + } + + /** + * Retrieves all excluded field paths for export + * + * @return array + */ + public function get() + { + return array_keys( + array_filter( + $this->configs, + function ($value) { + return filter_var($value, FILTER_VALIDATE_BOOLEAN); + } + ) + ); + } +} diff --git a/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php b/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php new file mode 100644 index 0000000000000000000000000000000000000000..efbe888f2ebd62e0376e567e4046080af6ba8658 --- /dev/null +++ b/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php @@ -0,0 +1,70 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Model\Config\Processor; + +use Magento\Config\Model\Placeholder\PlaceholderFactory; +use Magento\Config\Model\Placeholder\PlaceholderInterface; +use Magento\Framework\App\Config\Spi\PreProcessorInterface; +use Magento\Framework\Stdlib\ArrayManager; + +/** + * Allows to extract configurations from environment variables. + */ +class EnvironmentPlaceholder implements PreProcessorInterface +{ + /** + * @var PlaceholderFactory + */ + private $placeholderFactory; + + /** + * @var ArrayManager + */ + private $arrayManager; + + /** + * @var PlaceholderInterface + */ + private $placeholder; + + /** + * @param PlaceholderFactory $placeholderFactory + * @param ArrayManager $arrayManager + */ + public function __construct( + PlaceholderFactory $placeholderFactory, + ArrayManager $arrayManager + ) { + $this->placeholderFactory = $placeholderFactory; + $this->arrayManager = $arrayManager; + $this->placeholder = $placeholderFactory->create(PlaceholderFactory::TYPE_ENVIRONMENT); + } + + /** + * Method extracts environment variables. + * If environment variable is matching the desired rule - it's being used as value. + * + * {@inheritdoc} + */ + public function process(array $config) + { + $environmentVariables = $_ENV; + + foreach ($environmentVariables as $template => $value) { + if (!$this->placeholder->isApplicable($template)) { + continue; + } + + $config = $this->arrayManager->set( + $this->placeholder->restore($template), + $config, + $value + ); + } + + return $config; + } +} diff --git a/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php b/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php index 48b82086ad8b10d3b0241d2502b6199ab2584ab1..7e673401c7348c0721d917b5417c9940ceae16e3 100644 --- a/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php +++ b/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php @@ -6,10 +6,11 @@ namespace Magento\Config\Model\Config\Reader\Source\Deployed; use Magento\Config\Model\Config\Reader; -use Magento\Framework\App\Config\ScopeCodeResolver; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\DeploymentConfig; -use Magento\Framework\App\ObjectManager; +use Magento\Config\Model\Placeholder\PlaceholderInterface; +use Magento\Config\Model\Placeholder\PlaceholderFactory; +use Magento\Framework\App\Config\ScopeCodeResolver; /** * Class for checking settings that defined in config file @@ -21,6 +22,11 @@ class SettingChecker */ private $config; + /** + * @var PlaceholderInterface + */ + private $placeholder; + /** * @var ScopeCodeResolver */ @@ -28,45 +34,86 @@ class SettingChecker /** * @param DeploymentConfig $config + * @param PlaceholderFactory $placeholderFactory * @param ScopeCodeResolver $scopeCodeResolver */ public function __construct( DeploymentConfig $config, + PlaceholderFactory $placeholderFactory, ScopeCodeResolver $scopeCodeResolver ) { $this->config = $config; $this->scopeCodeResolver = $scopeCodeResolver; + $this->placeholder = $placeholderFactory->create(PlaceholderFactory::TYPE_ENVIRONMENT); } /** - * Resolve path by scope and scope code + * Check that setting defined in deployed configuration * + * @param string $path * @param string $scope - * @param string $scopeCode - * @return string + * @param string|null $scopeCode + * @return boolean */ - private function resolvePath($scope, $scopeCode) + public function isReadOnly($path, $scope, $scopeCode = null) { - $scopePath = 'system/' . $scope; + $config = $this->getEnvValue( + $this->placeholder->generate($path, $scope, $scopeCode) + ); - if ($scope != ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { - $scopePath .= '/' . $this->scopeCodeResolver->resolve($scope, $scopeCode); + if (null === $config) { + $config = $this->config->get($this->resolvePath($scope, $scopeCode) . "/" . $path); } - return $scopePath; + return $config !== null; } /** - * Check that setting defined in deployed configuration + * Check that there is value for generated placeholder + * + * Placeholder is generated from values of $path, $scope and $scopeCode * * @param string $path * @param string $scope * @param string $scopeCode - * @return boolean + * @param string|null $scopeCode + * @return string|null */ - public function isReadOnly($path, $scope, $scopeCode) + public function getPlaceholderValue($path, $scope, $scopeCode = null) { - $config = $this->config->get($this->resolvePath($scope, $scopeCode) . "/" . $path); - return $config !== null; + return $this->getEnvValue($this->placeholder->generate($path, $scope, $scopeCode)); + } + + /** + * Retrieve value of environment variable by placeholder + * + * @param string $placeholder + * @return string|null + */ + public function getEnvValue($placeholder) + { + if ($this->placeholder->isApplicable($placeholder) && isset($_ENV[$placeholder])) { + return $_ENV[$placeholder]; + } + + return null; + } + + /** + * Resolve path by scope and scope code + * + * @param string $scope + * @param string $scopeCode + * @return string + */ + private function resolvePath($scope, $scopeCode) + { + $scopePath = 'system/' . $scope; + + if ($scope != ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { + $scopePath .= '/' . $this->scopeCodeResolver->resolve($scope, $scopeCode); + } + + return $scopePath; } } diff --git a/app/code/Magento/Config/Model/Placeholder/Environment.php b/app/code/Magento/Config/Model/Placeholder/Environment.php new file mode 100644 index 0000000000000000000000000000000000000000..96ffadc96c6f9a958ebc61e6626bcc02ac178237 --- /dev/null +++ b/app/code/Magento/Config/Model/Placeholder/Environment.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Model\Placeholder; + +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\DeploymentConfig; + +/** + * Class is used to work with placeholders for environment variables names based on config paths + */ +class Environment implements PlaceholderInterface +{ + /** + * @const string Prefix for placeholder + */ + const PREFIX = 'CONFIG__'; + + /** + * @var DeploymentConfig + */ + private $deploymentConfig; + + /** + * @param DeploymentConfig $deploymentConfig + */ + public function __construct(DeploymentConfig $deploymentConfig) + { + $this->deploymentConfig = $deploymentConfig; + } + + /** + * Generates placeholder like CONFIG__DEFAULT__TEST__TEST_VALUE + * + * @inheritdoc + */ + public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null) + { + $parts = $scopeType ? [$scopeType] : []; + + if ($scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT && $scopeCode) { + $parts[] = $scopeCode; + } + + $parts[] = $path; + + $template = implode('__', $parts); + $template = str_replace('/', '__', $template); + $template = static::PREFIX . $template; + $template = strtoupper($template); + + return $template; + } + + /** + * @inheritdoc + */ + public function restore($template) + { + $template = preg_replace('/^' . static::PREFIX . '/', '', $template); + $template = str_replace('__', '/', $template); + $template = strtolower($template); + + return $template; + } + + /** + * @inheritdoc + */ + public function isApplicable($placeholder) + { + return 1 === preg_match('/^' . static::PREFIX . '([a-zA-Z]+)([a-zA-Z0-9_])*$/', $placeholder); + } +} diff --git a/app/code/Magento/Config/Model/Placeholder/PlaceholderFactory.php b/app/code/Magento/Config/Model/Placeholder/PlaceholderFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..3f88bc2a289c4b32e47f24ef43223a868ea99267 --- /dev/null +++ b/app/code/Magento/Config/Model/Placeholder/PlaceholderFactory.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Model\Placeholder; + +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\ObjectManagerInterface; + +class PlaceholderFactory +{ + /** + * @const string Environment type + */ + const TYPE_ENVIRONMENT = 'environment'; + + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @var array + */ + private $types; + + /** + * @param ObjectManagerInterface $objectManager + * @param array $types + */ + public function __construct(ObjectManagerInterface $objectManager, array $types = []) + { + $this->objectManager = $objectManager; + $this->types = $types; + } + + /** + * Create placeholder + * + * @param string $type + * @return PlaceholderInterface + * @throws LocalizedException + */ + public function create($type) + { + if (!isset($this->types[$type])) { + throw new LocalizedException(__('There is no defined type ' . $type)); + } + + $object = $this->objectManager->create($this->types[$type]); + + if (!$object instanceof PlaceholderInterface) { + throw new LocalizedException(__('Object is not instance of ' . PlaceholderInterface::class)); + } + + return $object; + } +} diff --git a/app/code/Magento/Config/Model/Placeholder/PlaceholderInterface.php b/app/code/Magento/Config/Model/Placeholder/PlaceholderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..286eb0034a55063b8dcbf35cc13474ef144fd656 --- /dev/null +++ b/app/code/Magento/Config/Model/Placeholder/PlaceholderInterface.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Model\Placeholder; + +use Magento\Framework\App\Config\ScopeConfigInterface; + +/** + * Interface PlaceholderInterface + */ +interface PlaceholderInterface +{ + /** + * Generating placeholder from value + * + * @param string $path + * @param string $scopeType + * @param string $scopeCode + * @return string + */ + public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null); + + /** + * Restoring path parts from template. + * + * @param string $template + * @return string + */ + public function restore($template); + + /** + * Check whether provided string is placeholder + * + * @param string $placeholder + * @return bool + */ + public function isApplicable($placeholder); +} diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9c6aef37540e5d69f071b8f4f9ccb465f69233ff --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php @@ -0,0 +1,171 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Test\Unit\App\Config\Source; + +use Magento\Config\App\Config\Source\DumpConfigSourceAggregated; +use Magento\Config\Model\Config\Export\ExcludeList; +use Magento\Framework\App\Config\ConfigSourceInterface; + +class DumpConfigSourceAggregatedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $sourceMock; + + /** + * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $sourceMockTwo; + + /** + * @var DumpConfigSourceAggregated + */ + private $model; + + /** + * @var ExcludeList|\PHPUnit_Framework_MockObject_MockObject + */ + private $excludeListMock; + + public function setUp() + { + $this->sourceMock = $this->getMockBuilder(ConfigSourceInterface::class) + ->getMockForAbstractClass(); + $this->sourceMockTwo = $this->getMockBuilder(ConfigSourceInterface::class) + ->getMockForAbstractClass(); + $this->excludeListMock = $this->getMockBuilder(ExcludeList::class) + ->disableOriginalConstructor() + ->getMock(); + + $sources = [ + [ + 'source' => $this->sourceMockTwo, + 'sortOrder' => 100 + ], + [ + 'source' => $this->sourceMock, + 'sortOrder' => 10 + ], + + ]; + + $this->model = new DumpConfigSourceAggregated($this->excludeListMock, $sources); + } + + public function testGet() + { + $path = ''; + $data = [ + 'default' => [ + 'web' => [ + 'unsecure' => [ + 'base_url' => 'http://test.local', + ], + 'secure' => [ + 'base_url' => 'https://test.local', + ] + ] + ], + 'test' => [ + 'test' => [ + 'test1' => [ + 'test2' => [ + 'test3' => 5, + ] + ] + ] + ] + ]; + + $this->sourceMock->expects($this->once()) + ->method('get') + ->with($path) + ->willReturn($data); + $this->sourceMockTwo->expects($this->once()) + ->method('get') + ->with($path) + ->willReturn(['key' => 'value2']); + $this->excludeListMock->expects($this->any()) + ->method('isPresent') + ->willReturnMap([ + ['web/unsecure/base_url', false], + ['web/secure/base_url', true], + ['test1/test2/test/3', false] + ]); + + $this->assertEquals( + [ + 'test' => [ + 'test' => [ + 'test1' => [ + 'test2' => [ + 'test3' => 5, + ] + ] + ], + ], + 'key' => 'value2', + 'default' => [ + 'web' => [ + 'unsecure' => [ + 'base_url' => 'http://test.local', + ], + 'secure' => [] + ] + ], + ], + $this->model->get($path) + ); + } + + public function testGetExcludedFields() + { + $path = ''; + $data = [ + 'default' => [ + 'web' => [ + 'unsecure' => [ + 'base_url' => 'http://test.local', + ], + 'secure' => [ + 'base_url' => 'https://test.local', + ] + ] + ], + 'test' => [ + 'test' => [ + 'test1' => [ + 'test2' => [ + 'test3' => 5, + ] + ] + ] + ] + ]; + + $this->sourceMock->expects($this->once()) + ->method('get') + ->with($path) + ->willReturn($data); + $this->sourceMockTwo->expects($this->once()) + ->method('get') + ->with($path) + ->willReturn(['key' => 'value2']); + $this->excludeListMock->expects($this->any()) + ->method('isPresent') + ->willReturnMap([ + ['web/unsecure/base_url', false], + ['web/secure/base_url', true], + ['test1/test2/test/3', false] + ]); + + $this->assertEquals( + ['web/secure/base_url'], + $this->model->getExcludedFields() + ); + } +} diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php index be541228bf6d88a5ad7e459ba77a34e896c863a1..8409e96db552e61a8ee3a8a4ec788d457d84ba5c 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php @@ -8,9 +8,9 @@ namespace Magento\Config\Test\Unit\App\Config\Type; use Magento\Config\App\Config\Type\System; use Magento\Framework\App\Config\ConfigSourceInterface; use Magento\Framework\App\Config\Spi\PostProcessorInterface; -use Magento\Framework\App\ObjectManager; +use Magento\Framework\App\Config\Spi\PreProcessorInterface; use Magento\Framework\Cache\FrontendInterface; -use Magento\Framework\Serialize\Serializer\Serialize; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Store\Model\Config\Processor\Fallback; /** @@ -29,6 +29,11 @@ class SystemTest extends \PHPUnit_Framework_TestCase */ private $postProcessor; + /** + * @var PreProcessorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $preProcessor; + /** * @var Fallback|\PHPUnit_Framework_MockObject_MockObject */ @@ -45,7 +50,7 @@ class SystemTest extends \PHPUnit_Framework_TestCase private $configType; /** - * @var Serialize|\PHPUnit_Framework_MockObject_MockObject + * @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $serializer; @@ -60,7 +65,9 @@ class SystemTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->cache = $this->getMockBuilder(FrontendInterface::class) ->getMockForAbstractClass(); - $this->serializer = $this->getMockBuilder(Serialize::class) + $this->preProcessor = $this->getMockBuilder(PreProcessorInterface::class) + ->getMockForAbstractClass(); + $this->serializer = $this->getMockBuilder(SerializerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->configType = new System( @@ -68,7 +75,8 @@ class SystemTest extends \PHPUnit_Framework_TestCase $this->postProcessor, $this->fallback, $this->cache, - $this->serializer + $this->serializer, + $this->preProcessor ); } @@ -112,6 +120,10 @@ class SystemTest extends \PHPUnit_Framework_TestCase ->method('process') ->with($data) ->willReturnArgument(0); + $this->preProcessor->expects($this->once()) + ->method('process') + ->with($data) + ->willReturnArgument(0); $this->postProcessor->expects($this->once()) ->method('process') ->with($data) diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php index 2c671914f264b04ec34508d919a23c67bf64abad..5c7bf92f954285571bc6620a1726d2ccfd9432f4 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php @@ -10,6 +10,7 @@ namespace Magento\Config\Test\Unit\Block\System\Config; use Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker; use Magento\Framework\App\DeploymentConfig; +use Magento\Store\Model\StoreManagerInterface; /** * Test System config form block @@ -72,6 +73,11 @@ class FormTest extends \PHPUnit_Framework_TestCase */ protected $_fieldsetFactoryMock; + /** + * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $storeManagerMock; + /** * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -161,6 +167,9 @@ class FormTest extends \PHPUnit_Framework_TestCase false ); + $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class) + ->getMockForAbstractClass(); + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $context = $helper->getObject( @@ -168,7 +177,8 @@ class FormTest extends \PHPUnit_Framework_TestCase [ 'scopeConfig' => $this->_coreConfigMock, 'request' => $requestMock, - 'urlBuilder' => $this->_urlModelMock + 'urlBuilder' => $this->_urlModelMock, + 'storeManager' => $this->storeManagerMock ] ); @@ -423,6 +433,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * @param string|null $configPath * @param bool $inherit * @param string $expectedValue + * @param string|null $placeholderValue * @param int $hasBackendModel * * @dataProvider initFieldsDataProvider @@ -434,6 +445,7 @@ class FormTest extends \PHPUnit_Framework_TestCase $configPath, $inherit, $expectedValue, + $placeholderValue, $hasBackendModel ) { // Parameters initialization @@ -503,6 +515,18 @@ class FormTest extends \PHPUnit_Framework_TestCase $this->returnValue($configValue) ); + /** @var \Magento\Store\Api\Data\StoreInterface|\PHPUnit_Framework_MockObject_MockObject $storeMock */ + $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) + ->getMockForAbstractClass(); + $storeMock->expects($this->once()) + ->method('getCode') + ->willReturn('store_code'); + + $this->storeManagerMock->expects($this->atLeastOnce()) + ->method('getStore') + ->with('store_code') + ->willReturn($storeMock); + // Field mock configuration $fieldMock = $this->getMock( \Magento\Config\Model\Config\Structure\Element\Field::class, @@ -596,17 +620,20 @@ class FormTest extends \PHPUnit_Framework_TestCase $fieldMock->expects($this->once())->method('populateInput'); - - $settingChecker = $this->getMockBuilder(SettingChecker::class) + $settingCheckerMock = $this->getMockBuilder(SettingChecker::class) ->disableOriginalConstructor() ->getMock(); - $settingChecker->expects($this->once()) + $settingCheckerMock->expects($this->once()) ->method('isReadOnly') ->willReturn(false); - $reflection = new \ReflectionClass(get_class($this->object)); - $reflectionProperty = $reflection->getProperty('settingChecker'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($this->object, $settingChecker); + + $settingCheckerMock->expects($this->once()) + ->method('getPlaceholderValue') + ->willReturn($placeholderValue); + + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $helper->setBackwardCompatibleProperty($this->object, 'settingChecker', $settingCheckerMock); $this->object->initFields($fieldsetMock, $groupMock, $sectionMock, $fieldPrefix, $labelPrefix); } @@ -617,8 +644,9 @@ class FormTest extends \PHPUnit_Framework_TestCase public function initFieldsDataProvider() { return [ - [['section1/group1/field1' => 'some_value'], false, null, false, 'some_value', 1], - [[], 'Config Value', 'some/config/path', true, 'Config Value', 0] + [['section1/group1/field1' => 'some_value'], false, null, false, 'some_value', null, 1], + [[], 'Config Value', 'some/config/path', true, 'Config Value', null, 0], + [[], 'Config Value', 'some/config/path', true, 'Placeholder Value', 'Placeholder Value', 0] ]; } } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Export/CommentTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Export/CommentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c8b10bcf4ddcd5393a62307c873646f87d1419e8 --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Export/CommentTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Test\Unit\Model\Config\Export; + +use Magento\Config\Model\Config\Export\Comment; +use Magento\Config\App\Config\Source\DumpConfigSourceInterface; +use Magento\Config\Model\Placeholder\PlaceholderFactory; +use Magento\Config\Model\Placeholder\PlaceholderInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + +class CommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DumpConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $configSourceMock; + + /** + * @var PlaceholderInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $placeholderMock; + + /** + * @var Comment + */ + private $model; + + protected function setUp() + { + $objectManager = new ObjectManager($this); + + $this->placeholderMock = $this->getMockBuilder(PlaceholderInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $placeholderFactoryMock = $this->getMockBuilder(PlaceholderFactory::class) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $placeholderFactoryMock->expects($this->once()) + ->method('create') + ->with(PlaceholderFactory::TYPE_ENVIRONMENT) + ->willReturn($this->placeholderMock); + + $this->configSourceMock = $this->getMockBuilder(DumpConfigSourceInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->model = $objectManager->getObject( + Comment::class, + [ + 'placeholderFactory' => $placeholderFactoryMock, + 'source' => $this->configSourceMock + ] + ); + } + + public function testGetEmpty() + { + $this->configSourceMock->expects($this->once()) + ->method('getExcludedFields') + ->willReturn([]); + $this->assertEmpty($this->model->get()); + } + + public function testGet() + { + $path = 'one/two'; + $placeholder = 'one__two'; + $expectedResult = 'The configuration file doesn\'t contain sensitive data for security reasons. ' + . 'Sensitive data can be stored in the following environment variables:' + . "\n$placeholder for $path"; + + $this->configSourceMock->expects($this->once()) + ->method('getExcludedFields') + ->willReturn([$path]); + + $this->placeholderMock->expects($this->once()) + ->method('generate') + ->with($path) + ->willReturn($placeholder); + + $this->assertEquals($expectedResult, $this->model->get()); + } +} diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Export/ExcludeListTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Export/ExcludeListTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3156ad1ec549325839bbf9470c6396d101ee557f --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Export/ExcludeListTest.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Test\Unit\Model\Config\Export; + +use Magento\Config\Model\Config\Export\ExcludeList; + +class ExcludeListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ExcludeList + */ + private $model; + + protected function setUp() + { + $this->model = new ExcludeList( + [ + 'web/unsecure/base_url' => '', + 'web/test/test_value' => '0', + 'web/test/test_sensitive' => '1', + ] + ); + } + + public function testGet() + { + $this->assertEquals(['web/test/test_sensitive'], $this->model->get()); + } + + public function testIsPresent() + { + $this->assertFalse($this->model->isPresent('some/new/path')); + $this->assertFalse($this->model->isPresent('web/unsecure/base_url')); + $this->assertFalse($this->model->isPresent('web/test/test_value')); + $this->assertTrue($this->model->isPresent('web/test/test_sensitive')); + } +} diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..25f9f6b3cb83222dd9c196114729e8b10465072b --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php @@ -0,0 +1,131 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Test\Unit\Model\Config\Processor; + +use Magento\Config\Model\Config\Processor\EnvironmentPlaceholder; +use Magento\Config\Model\Placeholder\PlaceholderFactory; +use Magento\Config\Model\Placeholder\PlaceholderInterface; +use Magento\Framework\Stdlib\ArrayManager; +use \PHPUnit_Framework_MockObject_MockObject as Mock; + +class EnvironmentPlaceholderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EnvironmentPlaceholder + */ + private $model; + + /** + * @var PlaceholderFactory|Mock + */ + private $placeholderFactoryMock; + + /** + * @var ArrayManager|Mock + */ + private $arrayManagerMock; + + /** + * @var PlaceholderInterface|Mock + */ + private $placeholderMock; + + /** + * @var array + */ + private $env; + + protected function setUp() + { + $this->placeholderFactoryMock = $this->getMockBuilder(PlaceholderFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class) + ->disableOriginalConstructor() + ->getMock(); + $this->placeholderMock = $this->getMockBuilder(PlaceholderInterface::class) + ->getMockForAbstractClass(); + $this->env = $_ENV; + + $this->placeholderFactoryMock->expects($this->any()) + ->method('create') + ->with(PlaceholderFactory::TYPE_ENVIRONMENT) + ->willReturn($this->placeholderMock); + + $this->model = new EnvironmentPlaceholder( + $this->placeholderFactoryMock, + $this->arrayManagerMock + ); + } + + public function testProcess() + { + $_ENV = array_merge( + $this->env, + [ + 'CONFIG_DEFAULT_TEST' => 1, + 'CONFIG_DEFAULT_TEST2' => 2, + 'BAD_CONFIG' => 3, + ] + ); + + $this->placeholderMock->expects($this->any()) + ->method('isApplicable') + ->willReturnMap( + [ + ['CONFIG_DEFAULT_TEST', true], + ['CONFIG_DEFAULT_TEST2', true], + ['BAD_CONFIG', false], + ] + ); + $this->placeholderMock->expects($this->any()) + ->method('restore') + ->willReturnMap( + [ + ['CONFIG_DEFAULT_TEST', 'default/test'], + ['CONFIG_DEFAULT_TEST2', 'default/test2'], + ] + ); + $this->arrayManagerMock->expects($this->any()) + ->method('set') + ->willReturnMap( + [ + ['default/test', [], 1, '/', ['default' => ['test' => 1]]], + [ + 'default/test2', + [ + 'default' => [ + 'test' => 1 + ] + ], + 2, + '/', + [ + 'default' => [ + 'test' => 1, + 'test2' => 2 + ] + ], + ] + ] + ); + + $this->assertSame( + [ + 'default' => [ + 'test' => 1, + 'test2' => 2 + ] + ], + $this->model->process([]) + ); + } + + protected function tearDown() + { + $_ENV = $this->env; + } +} diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php index 2e746eae410f414788a7b5277e331be7075e6655..75bfab85616b588975175abe8976a8e57ec65e04 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php @@ -7,21 +7,30 @@ namespace Magento\Config\Test\Unit\Model\Config\Reader\Source\Deployed; use Magento\Config\Model\Config\Reader; use Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker; -use Magento\Framework\App\Config\ScopeCodeResolver; use Magento\Framework\App\Config; use Magento\Framework\App\DeploymentConfig; +use Magento\Config\Model\Placeholder\PlaceholderInterface; +use Magento\Config\Model\Placeholder\PlaceholderFactory; /** * Test class for checking settings that defined in config file - * - * @package Magento\Config\Test\Unit\Model\Config\Reader\Source\Deployed */ class SettingCheckerTest extends \PHPUnit_Framework_TestCase { /** * @var Config|\PHPUnit_Framework_MockObject_MockObject */ - private $config; + private $configMock; + + /** + * @var PlaceholderInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $placeholderMock; + + /** + * @var Config\ScopeCodeResolver|\PHPUnit_Framework_MockObject_MockObject + */ + private $scopeCodeResolverMock; /** * @var SettingChecker @@ -29,43 +38,109 @@ class SettingCheckerTest extends \PHPUnit_Framework_TestCase private $checker; /** - * @var ScopeCodeResolver | \PHPUnit_Framework_MockObject_MockObject + * @var array */ - private $scopeCodeResolver; + private $env; public function setUp() { - $this->config = $this->getMockBuilder(DeploymentConfig::class) + $this->configMock = $this->getMockBuilder(DeploymentConfig::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeCodeResolver = $this->getMockBuilder(ScopeCodeResolver::class) + $this->placeholderMock = $this->getMockBuilder(PlaceholderInterface::class) + ->getMockForAbstractClass(); + $this->scopeCodeResolverMock = $this->getMockBuilder(Config\ScopeCodeResolver::class) ->disableOriginalConstructor() ->getMock(); - $this->checker = new SettingChecker($this->config, $this->scopeCodeResolver); + $placeholderFactoryMock = $this->getMockBuilder(PlaceholderFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $this->env = $_ENV; + + $placeholderFactoryMock->expects($this->once()) + ->method('create') + ->with(PlaceholderFactory::TYPE_ENVIRONMENT) + ->willReturn($this->placeholderMock); + + $this->checker = new SettingChecker($this->configMock, $placeholderFactoryMock, $this->scopeCodeResolverMock); } - public function testIsDefined() + /** + * @param string $path + * @param string $scope + * @param string $scopeCode + * @param string|null $confValue + * @param array $variables + * @param bool $expectedResult + * @dataProvider isReadonlyDataProvider + */ + public function testIsReadonly($path, $scope, $scopeCode, $confValue, array $variables, $expectedResult) { - $path = 'general/web/locale'; - $scope = 'website'; - $scopeCode = 'myWebsite'; - $scopeCodeId = '4'; + $this->placeholderMock->expects($this->once()) + ->method('isApplicable') + ->willReturn(true); + $this->placeholderMock->expects($this->once()) + ->method('generate') + ->with($path, $scope, $scopeCode) + ->willReturn('SOME_PLACEHOLDER'); + $this->scopeCodeResolverMock->expects($this->any()) + ->method('resolve') + ->willReturnMap( + [ + ['website', 'myWebsite', ($scopeCode ? $scopeCode : '')] + ] + ); + + $_ENV = array_merge($this->env, $variables); - $this->config->expects($this->once()) + $this->configMock->expects($this->any()) ->method('get') - ->willReturn([ - $scope => [ - $scopeCode => [ - $path => 'value' - ], + ->willReturnMap([ + [ + 'system/' . $scope . "/" . ($scopeCode ? $scopeCode . '/' : '') . $path, + null, + $confValue ], ]); - $this->scopeCodeResolver->expects($this->once()) - ->method('resolve') - ->with($scope, $scopeCodeId) - ->willReturn($scopeCode); + $this->assertSame($expectedResult, $this->checker->isReadOnly($path, $scope, $scopeCode)); + } - $this->assertTrue($this->checker->isReadOnly($path, $scope, $scopeCodeId)); + /** + * @return array + */ + public function isReadonlyDataProvider() + { + return [ + [ + 'path' => 'general/web/locale', + 'scope' => 'website', + 'scopeCode' => 'myWebsite', + 'confValue' => 'value', + 'variables' => [], + 'expectedResult' => true, + ], + [ + 'path' => 'general/web/locale', + 'scope' => 'website', + 'scopeCode' => 'myWebsite', + 'confValue' => null, + 'variables' => ['SOME_PLACEHOLDER' => 'value'], + 'expectedResult' => true, + ], + [ + 'path' => 'general/web/locale', + 'scope' => 'website', + 'scopeCode' => 'myWebsite', + 'confValue' => null, + 'variables' => [], + 'expectedResult' => false, + ] + ]; + } + + protected function tearDown() + { + $_ENV = $this->env; } } diff --git a/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php b/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..64b4e6e37fb94867854da15f8e0f72d9b0ccbf3c --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php @@ -0,0 +1,131 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Test\Unit\Model\Placeholder; + +use Magento\Config\Model\Placeholder\Environment; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Config\ConfigOptionsListConstants; +use \PHPUnit_Framework_MockObject_MockObject as Mock; + +/** + * Class EnvironmentTest + */ +class EnvironmentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Environment + */ + private $model; + + /** + * @var DeploymentConfig|Mock + */ + private $deploymentConfigMock; + + protected function setUp() + { + $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new Environment( + $this->deploymentConfigMock + ); + } + + /** + * @param string $path + * @param string $scope + * @param string $scopeId + * @param string $expected + * @dataProvider getGenerateDataProvider + */ + public function testGenerate($path, $scope, $scopeId, $expected) + { + $this->assertSame( + $expected, + $this->model->generate($path, $scope, $scopeId) + ); + } + + public function getGenerateDataProvider() + { + return [ + [ + 'web/unsecure/base_url', + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + Environment::PREFIX . 'DEFAULT__WEB__UNSECURE__BASE_URL' + ], + [ + 'web/unsecure/base_url', + 'web', + 'test', + Environment::PREFIX . 'WEB__TEST__WEB__UNSECURE__BASE_URL' + ], + [ + 'web/unsecure/base_url', + 'web', + null, + Environment::PREFIX . 'WEB__WEB__UNSECURE__BASE_URL' + ], + ]; + } + + /** + * @param string $placeholder + * @param bool $expected + * @dataProvider getIsPlaceholderDataProvider + */ + public function testIsApplicable($placeholder, $expected) + { + $this->assertSame( + $expected, + $this->model->isApplicable($placeholder) + ); + } + + /** + * @return array + */ + public function getIsPlaceholderDataProvider() + { + return [ + [Environment::PREFIX . 'TEST', true], + ['TEST', false], + [Environment::PREFIX . 'TEST_test', true], + [Environment::PREFIX . '-:A', false], + [Environment::PREFIX . '_A', false], + [Environment::PREFIX . 'A@#$', false] + ]; + } + + /** + * @param string $template + * @param string $expected + * @dataProvider restoreDataProvider + */ + public function testRestore($template, $expected) + { + $this->assertSame( + $expected, + $this->model->restore($template) + ); + } + + /** + * @return array + */ + public function restoreDataProvider() + { + return [ + [Environment::PREFIX . 'TEST__CONFIG', 'test/config'], + [Environment::PREFIX . 'TEST__CONFIG__VALUE', 'test/config/value'], + [Environment::PREFIX . 'TEST__CONFIG_VALUE', 'test/config_value'], + ]; + } +} diff --git a/app/code/Magento/Config/Test/Unit/Model/Placeholder/PlaceholderFactoryTest.php b/app/code/Magento/Config/Test/Unit/Model/Placeholder/PlaceholderFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e8f646e984187ed49ffc7df0798c8efa689ba767 --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/Model/Placeholder/PlaceholderFactoryTest.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Test\Unit\Model\Placeholder; + +use Magento\Config\Model\Placeholder\Environment; +use Magento\Config\Model\Placeholder\PlaceholderFactory; +use Magento\Framework\ObjectManagerInterface; + +class PlaceholderFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PlaceholderFactory + */ + private $model; + + /** + * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $objectManagerMock; + + /** + * @var Environment|\PHPUnit_Framework_MockObject_MockObject + */ + private $environmentMock; + + protected function setUp() + { + $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) + ->getMockForAbstractClass(); + $this->environmentMock = $this->getMockBuilder(Environment::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new PlaceholderFactory( + $this->objectManagerMock, + [ + PlaceholderFactory::TYPE_ENVIRONMENT => Environment::class, + 'wrongClass' => \stdClass::class, + ] + ); + } + + public function testCreate() + { + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with(Environment::class) + ->willReturn($this->environmentMock); + + $this->assertInstanceOf( + Environment::class, + $this->model->create(PlaceholderFactory::TYPE_ENVIRONMENT) + ); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage There is no defined type dummyClass + */ + public function testCreateNonExisted() + { + $this->model->create('dummyClass'); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Object is not instance of Magento\Config\Model\Placeholder\PlaceholderInterface + */ + public function testCreateWrongImplementation() + { + $this->model->create('wrongClass'); + } +} diff --git a/app/code/Magento/Config/etc/di.xml b/app/code/Magento/Config/etc/di.xml index 4f9eae24b55f611db54f3f5423c3944f7d93a7f6..3e2fa4fbecf6da0a712a1df313eb5b63812a5a20 100644 --- a/app/code/Magento/Config/etc/di.xml +++ b/app/code/Magento/Config/etc/di.xml @@ -81,6 +81,8 @@ <argument name="source" xsi:type="object">systemConfigSourceAggregatedProxy</argument> <argument name="postProcessor" xsi:type="object">systemConfigPostProcessorCompositeProxy</argument> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> + <argument name="preProcessor" xsi:type="object">systemConfigPreProcessorComposite</argument> + <argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument> </arguments> </type> <virtualType name="modulesDataProviderProxy" type="Magento\Framework\App\Config\InitialConfigSource\Proxy"> @@ -113,6 +115,13 @@ </argument> </arguments> </virtualType> + <virtualType name="systemConfigPreProcessorComposite" type="Magento\Framework\App\Config\PreProcessorComposite"> + <arguments> + <argument name="processors" xsi:type="array"> + <item name="environmentPlaceholder" xsi:type="object">Magento\Config\Model\Config\Processor\EnvironmentPlaceholder</item> + </argument> + </arguments> + </virtualType> <virtualType name="systemConfigSourceAggregated" type="Magento\Framework\App\Config\ConfigSourceAggregated"> <arguments> <argument name="sources" xsi:type="array"> @@ -138,15 +147,15 @@ <argument name="fileKey" xsi:type="const">Magento\Framework\Config\File\ConfigFilePool::APP_CONFIG</argument> </arguments> </virtualType> - <virtualType name="appDumpSystemSource" type="Magento\Framework\App\Config\ConfigSourceAggregated"> + <virtualType name="appDumpSystemSource" type="Magento\Config\App\Config\Source\DumpConfigSourceAggregated"> <arguments> <argument name="sources" xsi:type="array"> - <item name="initial" xsi:type="array"> - <item name="source" xsi:type="object">systemConfigInitialDataProvider</item> - <item name="sortOrder" xsi:type="string">10</item> - </item> <item name="dynamic" xsi:type="array"> <item name="source" xsi:type="object">Magento\Config\App\Config\Source\RuntimeConfigSource</item> + <item name="sortOrder" xsi:type="string">100</item> + </item> + <item name="initial" xsi:type="array"> + <item name="source" xsi:type="object">systemConfigInitialDataProvider</item> <item name="sortOrder" xsi:type="string">1000</item> </item> </argument> @@ -158,8 +167,21 @@ <item name="system" xsi:type="array"> <item name="source" xsi:type="object">appDumpSystemSource</item> <item name="namespace" xsi:type="const">Magento\Config\App\Config\Type\System::CONFIG_TYPE</item> + <item name="comment" xsi:type="object">Magento\Config\Model\Config\Export\Comment</item> </item> </argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\Comment"> + <arguments> + <argument name="source" xsi:type="object">appDumpSystemSource</argument> + </arguments> + </type> + <type name="Magento\Config\Model\Placeholder\PlaceholderFactory"> + <arguments> + <argument name="types" xsi:type="array"> + <item name="environment" xsi:type="string">Magento\Config\Model\Placeholder\Environment</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php index fbb69798ff94fbdf8caafc7486e564da662cf655..ed4863342a9670699fd544b7c7838697dd06eef7 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php @@ -9,9 +9,45 @@ namespace Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Store\Api\StoreResolverInterface; +use Magento\Store\Model\Store; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Configurable extends \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice { + /** + * @var StoreResolverInterface + */ + private $storeResolver; + + /** + * Class constructor + * + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context + * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy + * @param \Magento\Eav\Model\Config $eavConfig + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Framework\Module\Manager $moduleManager + * @param string $connectionName + * @param StoreResolverInterface $storeResolver + */ + public function __construct( + \Magento\Framework\Model\ResourceModel\Db\Context $context, + \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, + \Magento\Eav\Model\Config $eavConfig, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Framework\Module\Manager $moduleManager, + $connectionName = null, + StoreResolverInterface $storeResolver = null + ) { + parent::__construct($context, $tableStrategy, $eavConfig, $eventManager, $moduleManager, $connectionName); + $this->storeResolver = $storeResolver ?: + \Magento\Framework\App\ObjectManager::getInstance()->get(StoreResolverInterface::class); + } + /** * Reindex temporary (price result data) for all products * @@ -190,16 +226,21 @@ class Configurable extends \Magento\Catalog\Model\ResourceModel\Product\Indexer\ [] )->where( 'le.required_options=0' - )->join( - ['product_status' => $this->getTable($statusAttribute->getBackend()->getTable())], - sprintf( - 'le.%1$s = product_status.%1$s AND product_status.attribute_id = %2$s', - $linkField, - $statusAttribute->getAttributeId() - ), + )->joinLeft( + ['status_global_attr' => $statusAttribute->getBackendTable()], + "status_global_attr.{$linkField} = le.{$linkField}" + . ' AND status_global_attr.attribute_id = ' . (int)$statusAttribute->getAttributeId() + . ' AND status_global_attr.store_id = ' . Store::DEFAULT_STORE_ID, + [] + )->joinLeft( + ['status_attr' => $statusAttribute->getBackendTable()], + "status_attr.{$linkField} = le.{$linkField}" + . ' AND status_attr.attribute_id = ' . (int)$statusAttribute->getAttributeId() + . ' AND status_attr.store_id = ' . $this->storeResolver->getCurrentStoreId(), [] )->where( - 'product_status.value=' . ProductStatus::STATUS_ENABLED + 'IFNULL(status_attr.value, status_global_attr.value) = ?', + Status::STATUS_ENABLED )->group( ['e.entity_id', 'i.customer_group_id', 'i.website_id', 'l.product_id'] ); diff --git a/app/code/Magento/Contact/etc/di.xml b/app/code/Magento/Contact/etc/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..95cd40cb55e3171e025e3482a290168799395212 --- /dev/null +++ b/app/code/Magento/Contact/etc/di.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="contact/email/recipient_email" xsi:type="string">1</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Cron/Console/Command/CronInstallCommand.php b/app/code/Magento/Cron/Console/Command/CronInstallCommand.php new file mode 100644 index 0000000000000000000000000000000000000000..2835244599d38943fea5b2162814bbd6b9edb32e --- /dev/null +++ b/app/code/Magento/Cron/Console/Command/CronInstallCommand.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Cron\Console\Command; + +use Magento\Framework\Crontab\CrontabManagerInterface; +use Magento\Framework\Crontab\TasksProviderInterface; +use Magento\Framework\Exception\LocalizedException; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Magento\Framework\Console\Cli; +use Symfony\Component\Console\Input\InputOption; + +/** + * CronInstallCommand installs Magento cron tasks + */ +class CronInstallCommand extends Command +{ + /** + * @var CrontabManagerInterface + */ + private $crontabManager; + + /** + * @var TasksProviderInterface + */ + private $tasksProvider; + + /** + * @param CrontabManagerInterface $crontabManager + * @param TasksProviderInterface $tasksProvider + */ + public function __construct( + CrontabManagerInterface $crontabManager, + TasksProviderInterface $tasksProvider + ) { + $this->crontabManager = $crontabManager; + $this->tasksProvider = $tasksProvider; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('cron:install') + ->setDescription('Generates and installs crontab for current user') + ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install tasks'); + + parent::configure(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if ($this->crontabManager->getTasks() && !$input->getOption('force')) { + $output->writeln('<error>Crontab has already been generated and saved</error>'); + return Cli::RETURN_FAILURE; + } + + try { + $this->crontabManager->saveTasks($this->tasksProvider->getTasks()); + } catch (LocalizedException $e) { + $output->writeln('<error>' . $e->getMessage() . '</error>'); + return Cli::RETURN_FAILURE; + } + + $output->writeln('<info>Crontab has been generated and saved</info>'); + + return Cli::RETURN_SUCCESS; + } +} diff --git a/app/code/Magento/Cron/Console/Command/CronRemoveCommand.php b/app/code/Magento/Cron/Console/Command/CronRemoveCommand.php new file mode 100644 index 0000000000000000000000000000000000000000..11c666a556f899e9d7c6358c09291ee9df904998 --- /dev/null +++ b/app/code/Magento/Cron/Console/Command/CronRemoveCommand.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Cron\Console\Command; + +use Magento\Framework\Crontab\CrontabManagerInterface; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Magento\Framework\Console\Cli; +use Magento\Framework\Exception\LocalizedException; + +/** + * CronRemoveCommand removes Magento cron tasks + */ +class CronRemoveCommand extends Command +{ + /** + * @var CrontabManagerInterface + */ + private $crontabManager; + + /** + * @param CrontabManagerInterface $crontabManager + */ + public function __construct(CrontabManagerInterface $crontabManager) + { + $this->crontabManager = $crontabManager; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('cron:remove') + ->setDescription('Removes tasks from crontab'); + + parent::configure(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + $this->crontabManager->removeTasks(); + } catch (LocalizedException $e) { + $output->writeln('<error>' . $e->getMessage() . '</error>'); + return Cli::RETURN_FAILURE; + } + + $output->writeln('<info>Magento cron tasks have been removed</info>'); + + return Cli::RETURN_SUCCESS; + } +} diff --git a/app/code/Magento/Cron/Test/Unit/Console/Command/CronInstallCommandTest.php b/app/code/Magento/Cron/Test/Unit/Console/Command/CronInstallCommandTest.php new file mode 100644 index 0000000000000000000000000000000000000000..09949cf78dc8f267fe2bb668d91f2b28032ed8c1 --- /dev/null +++ b/app/code/Magento/Cron/Test/Unit/Console/Command/CronInstallCommandTest.php @@ -0,0 +1,126 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Cron\Test\Unit\Console\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Magento\Cron\Console\Command\CronInstallCommand; +use Magento\Framework\Crontab\CrontabManagerInterface; +use Magento\Framework\Crontab\TasksProviderInterface; +use Magento\Framework\Console\Cli; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Phrase; + +class CronInstallCommandTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CrontabManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $crontabManagerMock; + + /** + * @var TasksProviderInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $tasksProviderMock; + + /** + * @var CommandTester + */ + private $commandTester; + + /** + * @return void + */ + protected function setUp() + { + $this->crontabManagerMock = $this->getMockBuilder(CrontabManagerInterface::class) + ->getMockForAbstractClass(); + $this->tasksProviderMock = $this->getMockBuilder(TasksProviderInterface::class) + ->getMockForAbstractClass(); + + $this->commandTester = new CommandTester( + new CronInstallCommand($this->crontabManagerMock, $this->tasksProviderMock) + ); + } + + /** + * @return void + */ + public function testExecuteAlreadyInstalled() + { + $this->crontabManagerMock->expects($this->once()) + ->method('getTasks') + ->willReturn([['* * * * * /bin/php /var/run.php']]); + $this->tasksProviderMock->expects($this->never()) + ->method('getTasks'); + + $this->commandTester->execute([]); + $this->assertEquals( + 'Crontab has already been generated and saved' . PHP_EOL, + $this->commandTester->getDisplay() + ); + $this->assertEquals(Cli::RETURN_FAILURE, $this->commandTester->getStatusCode()); + } + + /** + * @return void + */ + public function testExecuteWithException() + { + $this->crontabManagerMock->expects($this->once()) + ->method('getTasks') + ->willReturn([]); + $this->tasksProviderMock->expects($this->once()) + ->method('getTasks') + ->willReturn([]); + $this->crontabManagerMock->expects($this->once()) + ->method('saveTasks') + ->willThrowException(new LocalizedException(new Phrase('Some error'))); + + $this->commandTester->execute([]); + $this->assertEquals( + 'Some error' . PHP_EOL, + $this->commandTester->getDisplay() + ); + $this->assertEquals(Cli::RETURN_FAILURE, $this->commandTester->getStatusCode()); + } + + /** + * @param array $existingTasks + * @param array $options + * @return void + * @dataProvider executeDataProvider + */ + public function testExecute($existingTasks, $options) + { + $this->crontabManagerMock->expects($this->once()) + ->method('getTasks') + ->willReturn($existingTasks); + $this->tasksProviderMock->expects($this->once()) + ->method('getTasks') + ->willReturn([]); + $this->crontabManagerMock->expects($this->once()) + ->method('saveTasks') + ->with([]); + + $this->commandTester->execute($options); + $this->assertEquals( + 'Crontab has been generated and saved' . PHP_EOL, + $this->commandTester->getDisplay() + ); + $this->assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode()); + } + + /** + * @return array + */ + public function executeDataProvider() + { + return [ + ['existingTasks' => [], 'options' => []], + ['existingTasks' => ['* * * * * /bin/php /var/www/run.php'], 'options' => ['-f'=> true]] + ]; + } +} diff --git a/app/code/Magento/Cron/Test/Unit/Console/Command/CronRemoveCommandTest.php b/app/code/Magento/Cron/Test/Unit/Console/Command/CronRemoveCommandTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cd017b26d758578482bffa137a3f221650619bae --- /dev/null +++ b/app/code/Magento/Cron/Test/Unit/Console/Command/CronRemoveCommandTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Cron\Test\Unit\Console\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Magento\Cron\Console\Command\CronRemoveCommand; +use Magento\Framework\Crontab\CrontabManagerInterface; +use Magento\Framework\Console\Cli; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Phrase; + +class CronRemoveCommandTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CrontabManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $crontabManagerMock; + + /** + * @var CommandTester + */ + private $commandTester; + + /** + * @return void + */ + protected function setUp() + { + $this->crontabManagerMock = $this->getMockBuilder(CrontabManagerInterface::class) + ->getMockForAbstractClass(); + + $this->commandTester = new CommandTester( + new CronRemoveCommand($this->crontabManagerMock) + ); + } + + /** + * @return void + */ + public function testExecute() + { + $this->crontabManagerMock->expects($this->once()) + ->method('RemoveTasks'); + + $this->commandTester->execute([]); + $this->assertEquals( + 'Magento cron tasks have been removed' . PHP_EOL, + $this->commandTester->getDisplay() + ); + $this->assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode()); + } + + /** + * @return void + */ + public function testExecuteFailed() + { + $this->crontabManagerMock->expects($this->once()) + ->method('RemoveTasks') + ->willThrowException(new LocalizedException(new Phrase('Some error'))); + + $this->commandTester->execute([]); + $this->assertEquals( + 'Some error' . PHP_EOL, + $this->commandTester->getDisplay() + ); + $this->assertEquals(Cli::RETURN_FAILURE, $this->commandTester->getStatusCode()); + } +} diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index d5624e96765c58bd699eebc29c14c7fe76037b7a..6abc9096f24012309a3b56cb0b84912d3a8d1e26 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -8,6 +8,8 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Cron\Model\ConfigInterface" type="Magento\Cron\Model\Config" /> <preference for="Magento\Framework\Shell\CommandRendererInterface" type="Magento\Framework\Shell\CommandRenderer" /> + <preference for="Magento\Framework\Crontab\CrontabManagerInterface" type="Magento\Framework\Crontab\CrontabManager" /> + <preference for="Magento\Framework\Crontab\TasksProviderInterface" type="Magento\Framework\Crontab\TasksProvider" /> <type name="Magento\Config\Model\Config\Structure\Converter"> <plugin name="cron_backend_config_structure_converter_plugin" type="Magento\Cron\Model\Backend\Config\Structure\Converter" /> </type> @@ -28,6 +30,8 @@ <arguments> <argument name="commands" xsi:type="array"> <item name="cronCommand" xsi:type="object">Magento\Cron\Console\Command\CronCommand</item> + <item name="cronInstall" xsi:type="object">Magento\Cron\Console\Command\CronInstallCommand</item> + <item name="cronRemove" xsi:type="object">Magento\Cron\Console\Command\CronRemoveCommand</item> </argument> </arguments> </type> @@ -38,4 +42,24 @@ </argument> </arguments> </type> + <type name="Magento\Framework\Crontab\CrontabManager"> + <arguments> + <argument name="shell" xsi:type="object">Magento\Framework\App\Shell</argument> + </arguments> + </type> + <type name="Magento\Framework\Crontab\TasksProviderInterface"> + <arguments> + <argument name="tasks" xsi:type="array"> + <item name="cronMagento" xsi:type="array"> + <item name="command" xsi:type="string">{magentoRoot}bin/magento cron:run | grep -v "Ran jobs by schedule" >> {magentoLog}magento.cron.log</item> + </item> + <item name="cronUpdate" xsi:type="array"> + <item name="command" xsi:type="string">{magentoRoot}update/cron.php >> {magentoLog}update.cron.log</item> + </item> + <item name="cronSetup" xsi:type="array"> + <item name="command" xsi:type="string">{magentoRoot}bin/magento setup:cron:run >> {magentoLog}setup.cron.log</item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 7b32da94ddedb476eda579521c1a19c002618ec4..786c5f9770a2e56123983c7b82c63ea369bec0a4 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -554,6 +554,8 @@ class AbstractAddress extends AbstractExtensibleModel implements AddressModelInt /** * Validate address attribute values * + * + * * @return bool|array * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -562,23 +564,24 @@ class AbstractAddress extends AbstractExtensibleModel implements AddressModelInt { $errors = []; if (!\Zend_Validate::is($this->getFirstname(), 'NotEmpty')) { - $errors[] = __('Please enter the first name.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'firstname']); } if (!\Zend_Validate::is($this->getLastname(), 'NotEmpty')) { - $errors[] = __('Please enter the last name.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'lastname']); } if (!\Zend_Validate::is($this->getStreetLine(1), 'NotEmpty')) { - $errors[] = __('Please enter the street.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'street']); } if (!\Zend_Validate::is($this->getCity(), 'NotEmpty')) { - $errors[] = __('Please enter the city.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'city']); } if (!\Zend_Validate::is($this->getTelephone(), 'NotEmpty')) { - $errors[] = __('Please enter the phone number.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']); + } $_havingOptionalZip = $this->_directoryData->getCountriesWithOptionalZip(); @@ -590,11 +593,11 @@ class AbstractAddress extends AbstractExtensibleModel implements AddressModelInt 'NotEmpty' ) ) { - $errors[] = __('Please enter the zip/postal code.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'postcode']); } if (!\Zend_Validate::is($this->getCountryId(), 'NotEmpty')) { - $errors[] = __('Please enter the country.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'countryId']); } if ($this->getCountryModel()->getRegionCollection()->getSize() && !\Zend_Validate::is( @@ -604,7 +607,7 @@ class AbstractAddress extends AbstractExtensibleModel implements AddressModelInt $this->getCountryId() ) ) { - $errors[] = __('Please enter the state/province.'); + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'regionId']); } if (empty($errors) || $this->getShouldIgnoreValidation()) { diff --git a/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php b/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php index 67d4ea32369ba8a37fef329d2aec809037fcac75..24df57e07e84826dcd7a19cdd84e5e6ca70ac37c 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php @@ -124,8 +124,12 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf $addressModel->updateData($address); } - $inputException = $this->_validate($addressModel); - if ($inputException->wasErrorAdded()) { + $errors = $addressModel->validate(); + if ($errors !== true) { + $inputException = new InputException(); + foreach ($errors as $error) { + $inputException->addError($error); + } throw $inputException; } $addressModel->save(); @@ -255,70 +259,6 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf return true; } - /** - * Validate Customer Addresses attribute values. - * - * @param CustomerAddressModel $customerAddressModel the model to validate - * @return InputException - * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - private function _validate(CustomerAddressModel $customerAddressModel) - { - $exception = new InputException(); - if ($customerAddressModel->getShouldIgnoreValidation()) { - return $exception; - } - - if (!\Zend_Validate::is($customerAddressModel->getFirstname(), 'NotEmpty')) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'firstname'])); - } - - if (!\Zend_Validate::is($customerAddressModel->getLastname(), 'NotEmpty')) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'lastname'])); - } - - if (!\Zend_Validate::is($customerAddressModel->getStreetLine(1), 'NotEmpty')) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'street'])); - } - - if (!\Zend_Validate::is($customerAddressModel->getCity(), 'NotEmpty')) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'city'])); - } - - if (!\Zend_Validate::is($customerAddressModel->getTelephone(), 'NotEmpty')) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'telephone'])); - } - - $havingOptionalZip = $this->directoryData->getCountriesWithOptionalZip(); - if (!in_array($customerAddressModel->getCountryId(), $havingOptionalZip) - && !\Zend_Validate::is($customerAddressModel->getPostcode(), 'NotEmpty') - ) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'postcode'])); - } - - if (!\Zend_Validate::is($customerAddressModel->getCountryId(), 'NotEmpty')) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'countryId'])); - } - - if ($this->directoryData->isRegionRequired($customerAddressModel->getCountryId())) { - $regionCollection = $customerAddressModel->getCountryModel()->getRegionCollection(); - if (!$regionCollection->count() && empty($customerAddressModel->getRegion())) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'region'])); - } elseif ( - $regionCollection->count() - && !in_array( - $customerAddressModel->getRegionId(), - array_column($regionCollection->getData(), 'region_id') - ) - ) { - $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'regionId'])); - } - } - return $exception; - } - /** * Retrieve collection processor * diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php index 32112ccdeb1aec053955226a49eb1838f8c4276b..ba833221aba18cb2b4f2b1e90a9c8b59d78327f5 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php @@ -336,31 +336,31 @@ class AbstractAddressTest extends \PHPUnit_Framework_TestCase return [ 'firstname' => [ array_merge(array_diff_key($data, ['firstname' => '']), ['country_id' => $countryId++]), - ['Please enter the first name.'], + ['firstname is a required field.'], ], 'lastname' => [ array_merge(array_diff_key($data, ['lastname' => '']), ['country_id' => $countryId++]), - ['Please enter the last name.'], + ['lastname is a required field.'], ], 'street' => [ array_merge(array_diff_key($data, ['street' => '']), ['country_id' => $countryId++]), - ['Please enter the street.'], + ['street is a required field.'], ], 'city' => [ array_merge(array_diff_key($data, ['city' => '']), ['country_id' => $countryId++]), - ['Please enter the city.'], + ['city is a required field.'], ], 'telephone' => [ array_merge(array_diff_key($data, ['telephone' => '']), ['country_id' => $countryId++]), - ['Please enter the phone number.'], + ['telephone is a required field.'], ], 'postcode' => [ array_merge(array_diff_key($data, ['postcode' => '']), ['country_id' => $countryId++]), - ['Please enter the zip/postal code.'], + ['postcode is a required field.'], ], 'country_id' => [ array_diff_key($data, ['country_id' => '']), - ['Please enter the country.'], + ['countryId is a required field.'], ], 'validated' => [array_merge($data, ['country_id' => $countryId++]), true], ]; diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php index b72a5f6a417d4ab77d2c025e1f43b6e58f72ccc2..5f6bc315acd16f6a79d82c5ee2566e240c6572a6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php @@ -128,6 +128,7 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase 'setCustomer', 'getCountryModel', 'getShouldIgnoreValidation', + 'validate', 'save', 'getDataModel', 'getCustomerId', @@ -191,6 +192,9 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase $this->address->expects($this->once()) ->method('setCustomer') ->with($this->customer); + $this->address->expects($this->once()) + ->method('validate') + ->willReturn(true); $this->address->expects($this->once()) ->method('save'); $this->addressRegistry->expects($this->once()) @@ -208,9 +212,6 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase $this->address->expects($this->once()) ->method('getDataModel') ->willReturn($customerAddress); - $this->address->expects($this->once()) - ->method('getShouldIgnoreValidation') - ->willReturn(true); $this->repository->save($customerAddress); } @@ -222,6 +223,7 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase { $customerId = 34; $addressId = 53; + $errors[] = __('Please enter the state/province.'); $customerAddress = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AddressInterface::class, [], @@ -245,7 +247,9 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase $this->address->expects($this->once()) ->method('updateData') ->with($customerAddress); - $this->prepareMocksForInvalidAddressValidation(); + $this->address->expects($this->once()) + ->method('validate') + ->willReturn($errors); $this->repository->save($customerAddress); } @@ -258,6 +262,7 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase { $customerId = 34; $addressId = 53; + $errors[] = __('region is a required field.'); $customerAddress = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AddressInterface::class, [], @@ -281,60 +286,13 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase $this->address->expects($this->once()) ->method('updateData') ->with($customerAddress); - $countryModel = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); - $regionCollection = $this->getMock( - \Magento\Directory\Model\ResourceModel\Region\Collection::class, - [], - [], - '', - false - ); - $this->address->expects($this->once()) - ->method('getShouldIgnoreValidation') - ->willReturn(false); - $this->address->expects($this->atLeastOnce()) - ->method('getCountryId') - ->willReturn(1); - $this->address->expects($this->once()) - ->method('getFirstname') - ->willReturn('firstname'); - $this->address->expects($this->once()) - ->method('getLastname') - ->willReturn('lastname'); - $this->address->expects($this->once()) - ->method('getStreetLine') - ->with(1) - ->willReturn('street line'); - $this->address->expects($this->once()) - ->method('getCity') - ->willReturn('city'); - $this->address->expects($this->once()) - ->method('getTelephone') - ->willReturn('23423423423'); $this->address->expects($this->never()) ->method('getRegionId') ->willReturn(null); - - $this->directoryData->expects($this->once()) - ->method('getCountriesWithOptionalZip') - ->willReturn([1]); - $this->address->expects($this->once()) - ->method('getCountryModel') - ->willReturn($countryModel); - $countryModel->expects($this->once()) - ->method('getRegionCollection') - ->willReturn($regionCollection); - $regionCollection->expects($this->once()) - ->method('count') - ->willReturn(0); - $this->directoryData->expects($this->once()) - ->method('isRegionRequired') - ->with(1) - ->willReturn(true); $this->address->expects($this->once()) - ->method('getRegion') - ->willReturn(''); + ->method('validate') + ->willReturn($errors); $this->repository->save($customerAddress); } @@ -347,6 +305,7 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase { $customerId = 34; $addressId = 53; + $errors[] = __('regionId is a required field.'); $customerAddress = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AddressInterface::class, [], @@ -370,114 +329,14 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase $this->address->expects($this->once()) ->method('updateData') ->with($customerAddress); - $countryModel = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); - $regionCollection = $this->getMock( - \Magento\Directory\Model\ResourceModel\Region\Collection::class, - [], - [], - '', - false - ); - - $this->address->expects($this->once()) - ->method('getShouldIgnoreValidation') - ->willReturn(false); - $this->address->expects($this->atLeastOnce()) - ->method('getCountryId') - ->willReturn(1); - $this->address->expects($this->once()) - ->method('getFirstname') - ->willReturn('firstname'); - $this->address->expects($this->once()) - ->method('getLastname') - ->willReturn('lastname'); - $this->address->expects($this->once()) - ->method('getStreetLine') - ->with(1) - ->willReturn('street line'); - $this->address->expects($this->once()) - ->method('getCity') - ->willReturn('city'); - $this->address->expects($this->once()) - ->method('getTelephone') - ->willReturn('23423423423'); - $this->address->expects($this->once()) - ->method('getRegionId') - ->willReturn(2); - - $this->directoryData->expects($this->once()) - ->method('getCountriesWithOptionalZip') - ->willReturn([1]); - $this->address->expects($this->once()) - ->method('getCountryModel') - ->willReturn($countryModel); - $countryModel->expects($this->once()) - ->method('getRegionCollection') - ->willReturn($regionCollection); - $regionCollection->expects($this->atLeastOnce()) - ->method('count') - ->willReturn(2); - $regionCollection->expects($this->once()) - ->method('getData') - ->willReturn([5, 6, 7, 8, 9]); - $this->directoryData->expects($this->once()) - ->method('isRegionRequired') - ->with(1) - ->willReturn(true); $this->address->expects($this->never()) ->method('getRegion') ->willReturn(''); - - $this->repository->save($customerAddress); - } - - protected function prepareMocksForInvalidAddressValidation() - { - $countryModel = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); - $regionCollection = $this->getMock( - \Magento\Directory\Model\ResourceModel\Region\Collection::class, - [], - [], - '', - false - ); - - $this->address->expects($this->once()) - ->method('getShouldIgnoreValidation') - ->willReturn(false); - $this->address->expects($this->atLeastOnce()) - ->method('getCountryId'); - $this->address->expects($this->once()) - ->method('getFirstname'); - $this->address->expects($this->once()) - ->method('getLastname'); - $this->address->expects($this->once()) - ->method('getStreetLine') - ->with(1); $this->address->expects($this->once()) - ->method('getCity'); - $this->address->expects($this->once()) - ->method('getTelephone'); - $this->address->expects($this->never()) - ->method('getRegionId') - ->willReturn(null); + ->method('validate') + ->willReturn($errors); - $this->directoryData->expects($this->once()) - ->method('getCountriesWithOptionalZip') - ->willReturn([]); - $this->address->expects($this->once()) - ->method('getCountryModel') - ->willReturn($countryModel); - $countryModel->expects($this->once()) - ->method('getRegionCollection') - ->willReturn($regionCollection); - $regionCollection->expects($this->once()) - ->method('count') - ->willReturn(0); - $this->directoryData->expects($this->once()) - ->method('isRegionRequired') - ->with(null) - ->willReturn(true); + $this->repository->save($customerAddress); } public function testGetById() diff --git a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php index b4e4fef8fb2f941eaa56cc33b2df65f783fa0413..40b262e3e4f5176f87d306be8babb5cfb2ba1898 100644 --- a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php +++ b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php @@ -5,7 +5,7 @@ */ namespace Magento\Deploy\Console\Command\App; -use Magento\Framework\App\Config\Reader\Source\SourceInterface; +use Magento\Framework\App\Config\ConfigSourceInterface; use Magento\Framework\App\DeploymentConfig\Writer; use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\Console\Cli; @@ -24,7 +24,7 @@ class ApplicationDumpCommand extends Command private $writer; /** - * @var SourceInterface[] + * @var ConfigSourceInterface[] */ private $sources; @@ -64,20 +64,29 @@ class ApplicationDumpCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { $dump = []; + $comments = []; foreach ($this->sources as $sourceData) { - /** @var SourceInterface $source */ + /** @var ConfigSourceInterface $source */ $source = $sourceData['source']; $namespace = $sourceData['namespace']; $dump[$namespace] = $source->get(); + if (!empty($sourceData['comment'])) { + $comments[$namespace] = is_string($sourceData['comment']) + ? $sourceData['comment'] + : $sourceData['comment']->get(); + } } - $this->writer ->saveConfig( [ConfigFilePool::APP_CONFIG => $dump], true, - ConfigFilePool::LOCAL + ConfigFilePool::LOCAL, + $comments ); + if (!empty($comments)) { + $output->writeln($comments); + } $output->writeln('<info>Done.</info>'); - return Cli::RETURN_SUCCESS; + return Cli::RETURN_SUCCESS; } } diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml index 80433242853b85378a31b50133716e8399084c29..2362aaa0780debfcdc0e55b270ed733dc1237e5b 100644 --- a/app/code/Magento/Developer/etc/di.xml +++ b/app/code/Magento/Developer/etc/di.xml @@ -252,4 +252,11 @@ </argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="dev/restrict/allow_ips" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Dhl/etc/di.xml b/app/code/Magento/Dhl/etc/di.xml index a215c2e82182535e14e659d20cf1f7db2317e915..cbe795791147cc03de7eb060c84108c6cbeb53fa 100644 --- a/app/code/Magento/Dhl/etc/di.xml +++ b/app/code/Magento/Dhl/etc/di.xml @@ -9,4 +9,13 @@ <type name="Magento\Checkout\Block\Cart\LayoutProcessor"> <plugin name="checkout_cart_shipping_dhl" type="Magento\Dhl\Model\Plugin\Checkout\Block\Cart\Shipping"/> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="carriers/dhl/id" xsi:type="string">1</item> + <item name="carriers/dhl/password" xsi:type="string">1</item> + <item name="carriers/dhl/account" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Directory/etc/di.xml b/app/code/Magento/Directory/etc/di.xml index f868197e60593cb59292a060b473f1d87d55820e..b4da40d119fe3e2269d1d33f47c5e2009a3379b1 100644 --- a/app/code/Magento/Directory/etc/di.xml +++ b/app/code/Magento/Directory/etc/di.xml @@ -47,4 +47,12 @@ <preference for="Magento\Directory\Api\CountryInformationAcquirerInterface" type="Magento\Directory\Model\CountryInformationAcquirer" /> <preference for="Magento\Directory\Api\Data\CountryInformationInterface" type="Magento\Directory\Model\Data\CountryInformation" /> <preference for="Magento\Directory\Api\Data\RegionInformationInterface" type="Magento\Directory\Model\Data\RegionInformation" /> + + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="currency/import/error_email" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/NewRelicReporting/etc/di.xml b/app/code/Magento/NewRelicReporting/etc/di.xml index caabf89be1871b05d55040d34f3b4b0e5b7a9120..6e3a24be91982e9f14b54228144157165094b1a5 100644 --- a/app/code/Magento/NewRelicReporting/etc/di.xml +++ b/app/code/Magento/NewRelicReporting/etc/di.xml @@ -12,4 +12,14 @@ <argument name="fullModuleList" xsi:type="object">Magento\Framework\Module\FullModuleList</argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="newrelicreporting/general/account_id" xsi:type="string">1</item> + <item name="newrelicreporting/general/app_id" xsi:type="string">1</item> + <item name="newrelicreporting/general/api" xsi:type="string">1</item> + <item name="newrelicreporting/general/insights_insert_key" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index 0f96b14124d042e86adbad3e944b2bdc97ee2e1a..893eda8cc6020882763056e78f844ab19166c1a6 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -7,7 +7,9 @@ namespace Magento\Paypal\Model\Express; use Magento\Customer\Api\Data\CustomerInterface as CustomerDataObject; use Magento\Customer\Model\AccountManagement; +use Magento\Framework\App\ObjectManager; use Magento\Paypal\Model\Config as PaypalConfig; +use Magento\Sales\Api\OrderRepositoryInterface; use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Quote\Model\Quote\Address; use Magento\Framework\DataObject; @@ -268,6 +270,11 @@ class Checkout */ protected $totalsCollector; + /** + * @var OrderRepositoryInterface + */ + private $orderRepository; + /** * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Customer\Model\Url $customerUrl @@ -789,7 +796,8 @@ class Checkout $this->ignoreAddressValidation(); $this->_quote->collectTotals(); - $order = $this->quoteManagement->submit($this->_quote); + $orderId = $this->quoteManagement->placeOrder($this->_quote->getId()); + $order = $this->getOrderRepository()->get($orderId); if (!$order) { return; @@ -1157,4 +1165,20 @@ class Checkout ->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID); return $this; } + + /** + * Returns order repository instance + * + * @return OrderRepositoryInterface + * @deprecated + */ + private function getOrderRepository() + { + if ($this->orderRepository === null) { + $this->orderRepository = ObjectManager::getInstance() + ->get(OrderRepositoryInterface::class); + } + + return $this->orderRepository; + } } diff --git a/app/code/Magento/Paypal/etc/di.xml b/app/code/Magento/Paypal/etc/di.xml index c5cbdbdc51331c95a269581a97a8ee3a94c25e0f..940876451fd591984937faeae1deef5ac1e4ea60 100644 --- a/app/code/Magento/Paypal/etc/di.xml +++ b/app/code/Magento/Paypal/etc/di.xml @@ -182,4 +182,32 @@ <argument name="paymentTokenFactory" xsi:type="object">Magento\Vault\Model\CreditCardTokenFactory</argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="paypal/general/business_account" xsi:type="string">1</item> + <item name="paypal/wpp/api_password" xsi:type="string">1</item> + <item name="paypal/wpp/api_signature" xsi:type="string">1</item> + <item name="paypal/wpp/api_username" xsi:type="string">1</item> + <item name="paypal/wpp/api_cert" xsi:type="string">1</item> + <item name="paypal/wpp/proxy_host" xsi:type="string">1</item> + <item name="paypal/wpp/proxy_port" xsi:type="string">1</item> + <item name="payment/paypal_express/merchant_id" xsi:type="string">1</item> + <item name="payment/paypal_express_bml/publisher_id" xsi:type="string">1</item> + <item name="paypal/fetch_reports/ftp_password" xsi:type="string">1</item> + <item name="paypal/fetch_reports/ftp_login" xsi:type="string">1</item> + <item name="paypal/fetch_reports/ftp_path" xsi:type="string">1</item> + <item name="paypal/fetch_reports/ftp_ip" xsi:type="string">1</item> + <item name="payment/payflow_advanced/user" xsi:type="string">1</item> + <item name="payment/payflow_advanced/pwd" xsi:type="string">1</item> + <item name="payment/payflow_link/user" xsi:type="string">1</item> + <item name="payment/payflow_link/pwd" xsi:type="string">1</item> + <item name="payment/payflowpro/user" xsi:type="string">1</item> + <item name="payment/payflowpro/pwd" xsi:type="string">1</item> + <item name="payment/payflowpro/partner" xsi:type="string">1</item> + <item name="payment/payflowpro/proxy_host" xsi:type="string">1</item> + <item name="payment/payflowpro/proxy_port" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 9c63c6958a465852ea3148cab659102880b07630..4ed6a998b084eb25a93ec939ebe20c70c6a4e5c2 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -9,6 +9,9 @@ "magento/module-customer": "100.2.*", "magento/framework": "100.2.*" }, + "suggest": { + "magento/module-config": "100.2.*" + }, "type": "magento2-module", "version": "100.2.0-dev", "license": [ diff --git a/app/code/Magento/ProductAlert/etc/di.xml b/app/code/Magento/ProductAlert/etc/di.xml index 734b0f6695778bc38744f185da7b58eb0faf50a1..d5c81adce46f0c66f10d5b60226f0525e3fd4c54 100644 --- a/app/code/Magento/ProductAlert/etc/di.xml +++ b/app/code/Magento/ProductAlert/etc/di.xml @@ -13,4 +13,12 @@ </argument> </arguments> </type> + + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="catalog/productalert_cron/error_email" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/ProductVideo/composer.json b/app/code/Magento/ProductVideo/composer.json index 08d21e4c2abbfb167aed2ca24c0ba012d6b2e8c8..726104c084677dfcb69e3721adfe63f4d71a7ecd 100644 --- a/app/code/Magento/ProductVideo/composer.json +++ b/app/code/Magento/ProductVideo/composer.json @@ -12,7 +12,8 @@ "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-customer": "100.2.*" + "magento/module-customer": "100.2.*", + "magento/module-config": "100.2.*" }, "type": "magento2-module", "version": "100.2.0-dev", diff --git a/app/code/Magento/ProductVideo/etc/di.xml b/app/code/Magento/ProductVideo/etc/di.xml index 7242a9d48ce1e3c0da66a3f4d5953cda705132cd..9aad01caaf72b65bc1a49951cb84c2f28a2de5e0 100644 --- a/app/code/Magento/ProductVideo/etc/di.xml +++ b/app/code/Magento/ProductVideo/etc/di.xml @@ -46,4 +46,11 @@ <type name="Magento\Catalog\Model\ResourceModel\Product\Gallery"> <plugin name="external_video_media_resource_backend" type="Magento\ProductVideo\Model\Plugin\ExternalVideoResourceBackend" /> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="catalog/product_video/youtube_api_key" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Review/etc/di.xml b/app/code/Magento/Review/etc/di.xml index d42d3e3330c670bce2c036cf8b100842f10a0a48..13f7d0b84bc505bb1fd66c9e16e36e75367219e2 100644 --- a/app/code/Magento/Review/etc/di.xml +++ b/app/code/Magento/Review/etc/di.xml @@ -26,4 +26,9 @@ <argument name="urlModel" xsi:type="object">Magento\Framework\Url</argument> </arguments> </type> + <type name="Magento\Review\Model\ResourceModel\Rating\Option"> + <arguments> + <argument name="customerSession" xsi:type="object">Magento\Customer\Model\Session\Proxy</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 4e2487d9dcada2eaf224f8cc30f65fc8fa4a4fc8..eb392fc83d8580e0cea6803a43c5f1a44f27fd58 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -956,4 +956,18 @@ <type name="Magento\Sales\Model\ResourceModel\Order\Handler\Address"> <plugin name="addressUpdate" type="Magento\Sales\Model\Order\Invoice\Plugin\AddressUpdate"/> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="sales_email/order/copy_to" xsi:type="string">1</item> + <item name="sales_email/order_comment/copy_to" xsi:type="string">1</item> + <item name="sales_email/invoice/copy_to" xsi:type="string">1</item> + <item name="sales_email/invoice_comment/copy_to" xsi:type="string">1</item> + <item name="sales_email/shipment/copy_to" xsi:type="string">1</item> + <item name="sales_email/shipment_comment/copy_to" xsi:type="string">1</item> + <item name="sales_email/creditmemo/copy_to" xsi:type="string">1</item> + <item name="sales_email/creditmemo_comment/copy_to" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 03f51bbd95e0ff5f65b88e565cfbe77102a44760..6f3f5c3925fa5431446d0c40ccf1e4bf902afede 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -21,7 +21,8 @@ }, "suggest": { "magento/module-fedex": "100.2.*", - "magento/module-ups": "100.2.*" + "magento/module-ups": "100.2.*", + "magento/module-config": "100.2.*" }, "type": "magento2-module", "version": "100.2.0-dev", diff --git a/app/code/Magento/Shipping/etc/di.xml b/app/code/Magento/Shipping/etc/di.xml index 1fe0657bf1337a1712c2aef7b614db6a45ea853f..44e138d6c9ac6f5c102727458edfe4d34fe4a9c5 100644 --- a/app/code/Magento/Shipping/etc/di.xml +++ b/app/code/Magento/Shipping/etc/di.xml @@ -9,4 +9,16 @@ <preference for="Magento\Quote\Model\Quote\Address\RateCollectorInterface" type="Magento\Shipping\Model\Shipping" /> <preference for="Magento\Shipping\Model\CarrierFactoryInterface" type="Magento\Shipping\Model\CarrierFactory" /> <preference for="Magento\Shipping\Model\Carrier\Source\GenericInterface" type="\Magento\Shipping\Model\Carrier\Source\GenericDefault" /> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="shipping/origin/country_id" xsi:type="string">1</item> + <item name="shipping/origin/region_id" xsi:type="string">1</item> + <item name="shipping/origin/postcode" xsi:type="string">1</item> + <item name="shipping/origin/city" xsi:type="string">1</item> + <item name="shipping/origin/street_line1" xsi:type="string">1</item> + <item name="shipping/origin/street_line2" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 9f556178fc2cccfd070c272a89164e438f1d33e8..307691a67d2e24617f381803d8a3f96a2c010d1b 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -12,6 +12,9 @@ "magento/module-media-storage": "100.2.*", "magento/framework": "100.2.*" }, + "suggest": { + "magento/module-config": "100.2.*" + }, "type": "magento2-module", "version": "100.2.0-dev", "license": [ diff --git a/app/code/Magento/Sitemap/etc/di.xml b/app/code/Magento/Sitemap/etc/di.xml index 7ce1fdee7b5b6a1de7947da82c2a1b93bf470bfc..dfe34a25fb7ba37766ae0247194df1cc85bdee28 100644 --- a/app/code/Magento/Sitemap/etc/di.xml +++ b/app/code/Magento/Sitemap/etc/di.xml @@ -11,4 +11,11 @@ <argument name="resource" xsi:type="object">Magento\Sitemap\Model\ResourceModel\Sitemap</argument> </arguments> </type> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="sitemap/generate/error_email" xsi:type="string">1</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js index c1d2fd3f910518ddcf15ae50122db3e5f30cd098..cd9794dc1757d4cfa5f092209ad8515557e42a4a 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js @@ -259,6 +259,9 @@ define([ // whether swatches are rendered in product list or on product page inProductList: false, + // sly-old-price block selector + slyOldPriceSelector: '.sly-old-price', + // tier prise selectors start tierPriceTemplateSelector: '#tier-prices-template', tierPriceBlockSelector: '[data-role="tier-price-block"]', @@ -837,6 +840,12 @@ define([ } ); + if (result.oldPrice.amount !== result.finalPrice.amount) { + $(this.options.slyOldPriceSelector).show(); + } else { + $(this.options.slyOldPriceSelector).hide(); + } + if (result.tierPrices.length) { if (this.options.tierPriceTemplate) { tierPriceHtml = mageTemplate( diff --git a/app/code/Magento/Theme/Model/Design/Config/DataProvider.php b/app/code/Magento/Theme/Model/Design/Config/DataProvider.php index c433b02fab240d736637bf41b571c2eb75d193bc..977295c1f80c466899284f0e8e18c373a6007445 100644 --- a/app/code/Magento/Theme/Model/Design/Config/DataProvider.php +++ b/app/code/Magento/Theme/Model/Design/Config/DataProvider.php @@ -5,9 +5,13 @@ */ namespace Magento\Theme\Model\Design\Config; +use Magento\Framework\App\Config\ScopeCodeResolver; +use Magento\Framework\App\ObjectManager; use Magento\Theme\Model\ResourceModel\Design\Config\Collection; use Magento\Theme\Model\ResourceModel\Design\Config\CollectionFactory; use Magento\Ui\DataProvider\AbstractDataProvider; +use Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker; +use Magento\Framework\App\RequestInterface; class DataProvider extends AbstractDataProvider { @@ -31,6 +35,21 @@ class DataProvider extends AbstractDataProvider */ private $metadataLoader; + /** + * @var SettingChecker + */ + private $settingChecker; + + /** + * @var RequestInterface + */ + private $request; + + /** + * @var ScopeCodeResolver + */ + private $scopeCodeResolver; + /** * @param string $name * @param string $primaryFieldName @@ -78,4 +97,84 @@ class DataProvider extends AbstractDataProvider $this->loadedData = $this->dataLoader->getData(); return $this->loadedData; } + + /** + * {@inheritdoc} + */ + public function getMeta() + { + $meta = parent::getMeta(); + if (!isset($meta['other_settings']['children'])) { + return $meta; + } + + $request = $this->getRequest()->getParams(); + if (!isset($request['scope'])) { + return $meta; + } + + $scope = $request['scope']; + $scopeCode = $this->getScopeCodeResolver()->resolve( + $scope, + isset($request['scope_id']) ? $request['scope_id'] : null + ); + + foreach ($meta['other_settings']['children'] as $settingGroupName => &$settingGroup) { + foreach ($settingGroup['children'] as $fieldName => &$field) { + $path = sprintf( + 'design/%s/%s', + $settingGroupName, + preg_replace('/^' . $settingGroupName . '_/', '', $fieldName) + ); + $isReadOnly = $this->getSettingChecker()->isReadOnly( + $path, + $scope, + $scopeCode + ); + + if ($isReadOnly) { + $field['arguments']['data']['config']['disabled'] = true; + $field['arguments']['data']['config']['is_disable_inheritance'] = true; + } + } + } + + return $meta; + } + + /** + * @deprecated + * @return ScopeCodeResolver + */ + private function getScopeCodeResolver() + { + if ($this->scopeCodeResolver === null) { + $this->scopeCodeResolver = ObjectManager::getInstance()->get(ScopeCodeResolver::class); + } + return $this->scopeCodeResolver; + } + + /** + * @deprecated + * @return SettingChecker + */ + private function getSettingChecker() + { + if ($this->settingChecker === null) { + $this->settingChecker = ObjectManager::getInstance()->get(SettingChecker::class); + } + return $this->settingChecker; + } + + /** + * @deprecated + * @return RequestInterface + */ + private function getRequest() + { + if ($this->request === null) { + $this->request = ObjectManager::getInstance()->get(RequestInterface::class); + } + return $this->request; + } } diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Config/DataProviderTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Config/DataProviderTest.php index 3ba61da79b5ca00073a14e11e7ab14c46b7af031..a5db6156efea32c56009620d9a8f2110f070bfe1 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Config/DataProviderTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Config/DataProviderTest.php @@ -5,11 +5,18 @@ */ namespace Magento\Theme\Test\Unit\Model\Design\Config; +use Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker; +use Magento\Framework\App\Config\ScopeCodeResolver; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Theme\Model\Design\Config\DataLoader; use Magento\Theme\Model\Design\Config\DataProvider; use Magento\Theme\Model\Design\Config\MetadataLoader; use Magento\Theme\Model\ResourceModel\Design\Config\Collection; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DataProviderTest extends \PHPUnit_Framework_TestCase { /** @@ -32,8 +39,29 @@ class DataProviderTest extends \PHPUnit_Framework_TestCase */ protected $collection; + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $requestMock; + + /** + * @var ScopeCodeResolver|\PHPUnit_Framework_MockObject_MockObject + */ + private $scopeCodeResolverMock; + + /** + * @var SettingChecker|\PHPUnit_Framework_MockObject_MockObject + */ + private $settingCheckerMock; + protected function setUp() { + $this->objectManager = new ObjectManager($this); $this->dataLoader = $this->getMockBuilder(\Magento\Theme\Model\Design\Config\DataProvider\DataLoader::class) ->disableOriginalConstructor() ->getMock(); @@ -56,6 +84,16 @@ class DataProviderTest extends \PHPUnit_Framework_TestCase ->method('create') ->willReturn($this->collection); + $this->requestMock = $this->getMockBuilder(RequestInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->scopeCodeResolverMock = $this->getMockBuilder(ScopeCodeResolver::class) + ->disableOriginalConstructor() + ->getMock(); + $this->settingCheckerMock = $this->getMockBuilder(SettingChecker::class) + ->disableOriginalConstructor() + ->getMock(); + $this->model = new DataProvider( 'scope', 'scope', @@ -64,6 +102,21 @@ class DataProviderTest extends \PHPUnit_Framework_TestCase $this->metadataLoader, $collectionFactory ); + $this->objectManager->setBackwardCompatibleProperty( + $this->model, + 'request', + $this->requestMock + ); + $this->objectManager->setBackwardCompatibleProperty( + $this->model, + 'scopeCodeResolver', + $this->scopeCodeResolverMock + ); + $this->objectManager->setBackwardCompatibleProperty( + $this->model, + 'settingChecker', + $this->settingCheckerMock + ); } public function testGetData() @@ -78,4 +131,119 @@ class DataProviderTest extends \PHPUnit_Framework_TestCase $this->assertEquals($data, $this->model->getData()); } + + /** + * @param array $inputMeta + * @param array $expectedMeta + * @param array $request + * @dataProvider getMetaDataProvider + */ + public function testGetMeta(array $inputMeta, array $expectedMeta, array $request) + { + $this->requestMock->expects($this->any()) + ->method('getParams') + ->willReturn($request); + $this->scopeCodeResolverMock->expects($this->any()) + ->method('resolve') + ->with('stores', 1) + ->willReturn('default'); + $this->settingCheckerMock->expects($this->any()) + ->method('isReadOnly') + ->withConsecutive( + ['design/head/welcome', 'stores', 'default'], + ['design/head/logo', 'stores', 'default'], + ['design/head/head', 'stores', 'default'] + ) + ->willReturnOnConsecutiveCalls( + true, + false, + true + ); + + $this->objectManager->setBackwardCompatibleProperty( + $this->model, + 'meta', + $inputMeta + ); + + $this->assertSame($expectedMeta, $this->model->getMeta()); + } + + /** + * @return array + */ + public function getMetaDataProvider() + { + return [ + [ + [ + 'option1' + ], + [ + 'option1' + ], + [ + 'scope' => 'default' + ] + ], + [ + [ + 'other_settings' => [ + 'children' => [ + 'head' => [ + 'children' => [ + 'head_welcome' => [ + + ], + 'head_logo' => [ + + ], + 'head_head' => [ + + ] + ] + ] + ] + ] + ], + [ + 'other_settings' => [ + 'children' => [ + 'head' => [ + 'children' => [ + 'head_welcome' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'disabled' => true, + 'is_disable_inheritance' => true, + ] + ] + ] + ], + 'head_logo' => [ + + ], + 'head_head' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'disabled' => true, + 'is_disable_inheritance' => true, + ] + ] + ] + ] + ] + ] + ] + ] + ], + [ + 'scope' => 'stores', + 'scope_id' => 1 + ] + ] + ]; + } } diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index c20dd28ba88876a70c04ea49038b94f82d3d9b06..e3cf2bce1813a0d6625f0b5dce2ac4cf0d8b5640 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -12,6 +12,9 @@ "magento/module-quote": "100.2.*", "magento/framework": "100.2.*" }, + "suggest": { + "magento/module-config": "100.2.*" + }, "type": "magento2-module", "version": "100.2.0-dev", "license": [ diff --git a/app/code/Magento/Ups/etc/di.xml b/app/code/Magento/Ups/etc/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..324349a82994fdadec4d4db33cdb66f28029b137 --- /dev/null +++ b/app/code/Magento/Ups/etc/di.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="carriers/ups/username" xsi:type="string">1</item> + <item name="carriers/ups/password" xsi:type="string">1</item> + <item name="carriers/ups/access_license_number" xsi:type="string">1</item> + <item name="carriers/ups/tracking_xml_url" xsi:type="string">1</item> + <item name="carriers/ups/gateway_xml_url" xsi:type="string">1</item> + <item name="carriers/ups/shipper_number" xsi:type="string">1</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index b2345a86bff4d6349035950373d1e7975076f513..d79d7747de8af69192f16f530a600cfe12dab355 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -1901,27 +1901,30 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C $response = $client->request()->getBody(); $response = $this->parseXml($response); - if ($response === false || $response->getName() == 'Error') { - $debugData['result'] = [ - 'error' => $response->Description, - 'code' => $response->Number, - 'xml' => $response->asXML(), - ]; - $this->_debug($debugData); - $result->setErrors($debugData['result']['error']); - } else { - if ($recipientUSCountry && $service == 'Priority Express') { - $labelContent = base64_decode((string)$response->EMLabel); - $trackingNumber = (string)$response->EMConfirmationNumber; - } elseif ($recipientUSCountry) { - $labelContent = base64_decode((string)$response->SignatureConfirmationLabel); - $trackingNumber = (string)$response->SignatureConfirmationNumber; + + if($response !== false) { + if ($response->getName() == 'Error') { + $debugData['result'] = [ + 'error' => $response->Description, + 'code' => $response->Number, + 'xml' => $response->asXML(), + ]; + $this->_debug($debugData); + $result->setErrors($debugData['result']['error']); } else { - $labelContent = base64_decode((string)$response->LabelImage); - $trackingNumber = (string)$response->BarcodeNumber; + if ($recipientUSCountry && $service == 'Priority Express') { + $labelContent = base64_decode((string)$response->EMLabel); + $trackingNumber = (string)$response->EMConfirmationNumber; + } elseif ($recipientUSCountry) { + $labelContent = base64_decode((string)$response->SignatureConfirmationLabel); + $trackingNumber = (string)$response->SignatureConfirmationNumber; + } else { + $labelContent = base64_decode((string)$response->LabelImage); + $trackingNumber = (string)$response->BarcodeNumber; + } + $result->setShippingLabelContent($labelContent); + $result->setTrackingNumber($trackingNumber); } - $result->setShippingLabelContent($labelContent); - $result->setTrackingNumber($trackingNumber); } $result->setGatewayResponse($response); diff --git a/app/code/Magento/Usps/etc/di.xml b/app/code/Magento/Usps/etc/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..450a24ad8b9f734ec85d1640ea1df8bf75e12225 --- /dev/null +++ b/app/code/Magento/Usps/etc/di.xml @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Config\Model\Config\Export\ExcludeList"> + <arguments> + <argument name="configs" xsi:type="array"> + <item name="carriers/usps/userid" xsi:type="string">1</item> + <item name="carriers/usps/password" xsi:type="string">1</item> + <item name="carriers/usps/gateway_url" xsi:type="string">1</item> + <item name="carriers/usps/gateway_secure_url" xsi:type="string">1</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/etc/di.xml b/app/etc/di.xml index e9767eccb28114ffa66bc8bc84829d92b1620e99..1b347574f4b2a2d3f010cb9a712da6cd6c7dbec2 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -433,7 +433,7 @@ </virtualType> <virtualType name="layoutObjectArgumentInterpreter" type="Magento\Framework\View\Layout\Argument\Interpreter\DataObject"> <arguments> - <argument name="expectedClass" xsi:type="string">Magento\Framework\Data\CollectionDataSourceInterface</argument> + <argument name="expectedClass" xsi:type="string">Magento\Framework\View\Element\Block\ArgumentInterface</argument> </arguments> </virtualType> <type name="Magento\Framework\View\Layout\Argument\Interpreter\NamedParams"> diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index e4a9bd10fa65832e7fdc4ae01f10578056b55a47..f170114a4ea8348714531af55ca805bb5e3442fe 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -1,6 +1,6 @@ { "require": { - "magento/mtf": "1.0.0-rc49", + "magento/mtf": "1.0.0-rc50", "php": "~5.6.5|7.0.2|~7.0.6", "phpunit/phpunit": "~4.8.0|~5.5.0", "phpunit/phpunit-selenium": ">=1.2" diff --git a/dev/tests/functional/credentials.xml.dist b/dev/tests/functional/credentials.xml.dist index 78186091a568ddba7368126c4b9217714e35d127..1061ca183f7f9e6ef4d4c1f740159423729e7c75 100644 --- a/dev/tests/functional/credentials.xml.dist +++ b/dev/tests/functional/credentials.xml.dist @@ -48,20 +48,32 @@ <field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_signature" value="" /> <field path="payment/paypal_express/merchant_id" value="" /> - <field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/business_account" value="" /> - <field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/partner" value="" /> - <field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/user" value="" /> - <field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/pwd" value="" /> - <field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/vendor" value="" /> + <field replace="payflow_pro_fraud_protection_enabled_business_account" value="" /> + <field replace="payflow_pro_fraud_protection_enabled_partner" value="" /> + <field replace="payflow_pro_fraud_protection_enabled_user" value="" /> + <field replace="payflow_pro_fraud_protection_enabled_pwd" value="" /> + <field replace="payflow_pro_fraud_protection_enabled_vendor" value="" /> + + <field replace="payflow_pro_business_account" value="" /> + <field replace="payflow_pro_partner" value="" /> + <field replace="payflow_pro_user" value="" /> + <field replace="payflow_pro_pwd" value="" /> + <field replace="payflow_pro_vendor" value="" /> + + <field replace="payflow_link_business_account_email" value="" /> + <field replace="payflow_link_partner" value="" /> + <field replace="payflow_link_user" value="" /> + <field replace="payflow_link_password" value="" /> + <field replace="payflow_link_vendor" value="" /> + + <field path="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/business_account" value="" /> + <field path="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/api_username" value="" /> + <field path="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/api_password" value="" /> + <field path="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/api_signature" value="" /> <field path="payment/paypal_alternative_payment_methods/express_checkout_us/express_checkout_required/express_checkout_required_express_checkout/business_account" value="" /> <field path="payment/paypal_alternative_payment_methods/express_checkout_us/express_checkout_required/express_checkout_required_express_checkout/api_username" value="" /> <field path="payment/paypal_alternative_payment_methods/express_checkout_us/express_checkout_required/express_checkout_required_express_checkout/api_password" value="" /> <field path="payment/paypal_alternative_payment_methods/express_checkout_us/express_checkout_required/express_checkout_required_express_checkout/api_signature" value="" /> - <field path="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/business_account" value="" /> - <field path="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/partner" value="" /> - <field path="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/user" value="" /> - <field path="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/pwd" value="" /> - <field path="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/vendor" value="" /> </replace> diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/DatepickerElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/DatepickerElement.php index e09ca5647cf590831e10b47ce8f86e20ef670ef3..07ac39363119094f9da91ab2b3d4dda8aa5129c3 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/DatepickerElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/DatepickerElement.php @@ -67,8 +67,8 @@ class DatepickerElement extends SimpleElement $date[1] = ltrim($date[1], '0'); $this->find($this->datePickerButton, Locator::SELECTOR_XPATH)->click(); $datapicker = $this->find($this->datePickerBlock, Locator::SELECTOR_XPATH); - $datapicker->find($this->datePickerMonth, Locator::SELECTOR_XPATH, 'select')->setValue($date[0]); $datapicker->find($this->datePickerYear, Locator::SELECTOR_XPATH, 'select')->setValue($date[2]); + $datapicker->find($this->datePickerMonth, Locator::SELECTOR_XPATH, 'select')->setValue($date[0]); $datapicker->find(sprintf($this->datePickerCalendar, $date[1]), Locator::SELECTOR_XPATH)->click(); if ($datapicker->isVisible()) { $datapicker->find($this->datePickerButtonClose, Locator::SELECTOR_XPATH)->click(); diff --git a/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php b/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php index ba1eca68a2436d1be756d82542ec412c95858e42..7114ec405ea28f4afd48537523ee9725e6058639 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php +++ b/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php @@ -118,8 +118,8 @@ abstract class AbstractAssertForm extends AbstractConstraint /** * Sort multidimensional array by paths. - * Pattern path: key/subKey::sorkKey. - * Exapmle: + * Pattern path: key/subKey::sortKey. + * Example: * $data = [ * 'custom_options' => [ * 'options' => [ diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.php b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.php deleted file mode 100644 index 7918859e53715c5215f772d988d91ac475a6150d..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Authorizenet\Test\Block\Form; - -use Magento\Payment\Test\Block\Form\Cc as CreditCard; - -/** - * Class Cc - * Form for filling credit card data for Authorize.Net payment method - */ -class Cc extends CreditCard -{ - // -} diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.xml deleted file mode 100755 index a7d2ae40b89c527f1d6bd5bcc1b55a9c0a8a4f03..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<mapping strict="0"> - <wrapper>payment</wrapper> - <fields> - <cc_number /> - <cc_exp_month> - <input>select</input> - </cc_exp_month> - <cc_exp_year> - <input>select</input> - </cc_exp_year> - <cc_cid /> - </fields> -</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Fixture/CreditCardAuthorizenet.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Fixture/CreditCardAuthorizenet.xml deleted file mode 100644 index 2777d09b4f16336c3b49a68fc6bdb1e47fe1d186..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Fixture/CreditCardAuthorizenet.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="credit_card_authorizenet" - module="Magento_Authorizenet" - type="virtual" - entity_type="credit_card_authorizenet" - repository_class="Magento\Authorizenet\Test\Repository\CreditCard" - class="Magento\Authorizenet\Test\Fixture\CreditCardAuthorizenet"> - <field name="cc_number" /> - <field name="cc_exp_month" /> - <field name="cc_exp_year" /> - <field name="cc_cid" /> - </fixture> -</config> 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 index d629bcba9e174251a1bc1e4c8fff6cc664911598..d25149f645f056d7f6e47e10706de3a0bc27e831 100644 --- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml @@ -17,9 +17,8 @@ <data name="prices" xsi:type="array"> <item name="grandTotal" xsi:type="string">15.00</item> </data> - <data name="creditCardClass" xsi:type="string">credit_card_authorizenet</data> <data name="payment/method" xsi:type="string">authorizenet_directpost</data> - <data name="creditCard/dataset" xsi:type="string">visa_authorizenet</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> <data name="configData" xsi:type="string">authorizenet</data> <data name="status" xsi:type="string">Processing</data> <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/Cc.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/BraintreeCc.php similarity index 65% rename from dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/Cc.php rename to dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/BraintreeCc.php index 2179efc0d5bf16c1299fba2439ddf415b3f575f7..60354b0f9ca28ae680039ecef9ce9cd47fd309e1 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/Cc.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/BraintreeCc.php @@ -9,26 +9,33 @@ namespace Magento\Braintree\Test\Block\Form; use Magento\Mtf\Client\Locator; use Magento\Mtf\Client\Element\SimpleElement; use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Payment\Test\Block\Form\Cc as CreditCard; +use Magento\Mtf\ObjectManager; +use Magento\Payment\Test\Block\Form\PaymentCc; /** - * Class Cc - * Form for filling credit card data for Braintree payment method + * Form for filling credit card data for Braintree payment method. */ -class Cc extends CreditCard +class BraintreeCc extends PaymentCc { /** - * Braintree iFrame locator + * Braintree iFrame locator. * * @var array */ protected $braintreeForm = [ - "credit_card_number" => "#braintree-hosted-field-number", - "credit_card_exp_month" => "#braintree-hosted-field-expirationMonth", - "credit_card_exp_year" => "#braintree-hosted-field-expirationYear", - "cvv" => "#braintree-hosted-field-cvv", + "cc_number" => "#braintree-hosted-field-number", + "cc_exp_month" => "#braintree-hosted-field-expirationMonth", + "cc_exp_year" => "#braintree-hosted-field-expirationYear", + "cc_cid" => "#braintree-hosted-field-cvv", ]; + /** + * Fill Braintree credit card form. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return void + */ public function fill(FixtureInterface $fixture, SimpleElement $element = null) { $mapping = $this->dataMapping($fixture->getData()); @@ -40,7 +47,8 @@ class Cc extends CreditCard return $fieldElement->isVisible() ? true : null; } ); - $this->browser->switchToFrame(new Locator($iframe)); + $iframeLocator = ObjectManager::getInstance()->create(Locator::class, ['value' => $iframe]); + $this->browser->switchToFrame($iframeLocator); $element = $this->browser->find('body'); $this->browser->waitUntil( function () use ($element) { diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/Cc.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/BraintreeCc.xml similarity index 63% rename from dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/Cc.xml rename to dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/BraintreeCc.xml index 6ea1ba9ee6e15ffe8d86aea81f8dc46aa5abc79d..d1d09ec7b1dd70bfa6413afe00bfff4ae95d735e 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/Cc.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/BraintreeCc.xml @@ -7,17 +7,17 @@ --> <mapping strict="0"> <fields> - <credit_card_number> + <cc_number> <selector>#credit-card-number</selector> - </credit_card_number> - <credit_card_exp_month> + </cc_number> + <cc_exp_month> <selector>#expiration-month</selector> - </credit_card_exp_month> - <credit_card_exp_year> + </cc_exp_month> + <cc_exp_year> <selector>#expiration-year</selector> - </credit_card_exp_year> - <cvv> + </cc_exp_year> + <cc_cid> <selector>#cvv</selector> - </cvv> + </cc_cid> </fields> </mapping> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Info.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Info.php deleted file mode 100644 index 32dfb8f40fe87695cbe251048757385dc8310116..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Info.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Braintree\Test\Block; - -use Magento\Mtf\Block\Block; -use Magento\Mtf\Client\Locator; - -/** - * Payment information block. - */ -class Info extends Block -{ - /** - * Braintree Payment information block locator. - */ - private $info = './/tr'; - - /** - * Get Braintree payment information block data. - * - * @return array - */ - public function getPaymentInfo() - { - $result = []; - $elements = $this->_rootElement->getElements($this->info, Locator::SELECTOR_XPATH); - foreach ($elements as $row) { - $key = rtrim($row->find('./th', Locator::SELECTOR_XPATH)->getText(), ':'); - $value = $row->find('./td', Locator::SELECTOR_XPATH)->getText(); - $result[$key] = $value; - } - return $result; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/Assert3dSecureInfoIsPresent.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/Assert3dSecureInfoIsPresent.php index bb1e0670231574d4e6c53eaf483e419e0ecab0ae..29af7632f7fd748a82e359164c80098c0fd59941 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/Assert3dSecureInfoIsPresent.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/Assert3dSecureInfoIsPresent.php @@ -6,13 +6,16 @@ namespace Magento\Braintree\Test\Constraint; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Mtf\Constraint\AbstractConstraint; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +/** + * Assert that 3D Secure information is present on order page in Admin. + */ class Assert3dSecureInfoIsPresent extends AbstractConstraint { /** - * Assert that 3D Secure information is present on order page in Admin. + * Assert that 3D Secure information is present on order page in Admin. * * @param SalesOrderView $salesOrderView * @param array $paymentInformation @@ -20,7 +23,9 @@ class Assert3dSecureInfoIsPresent extends AbstractConstraint */ public function processAssert(SalesOrderView $salesOrderView, array $paymentInformation) { - $actualPaymentInformation = $salesOrderView->getBraintreeInfoBlock()->getPaymentInfo(); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $actualPaymentInformation = $infoTab->getPaymentInfoBlock()->getData(); foreach ($paymentInformation as $key => $value) { \PHPUnit_Framework_Assert::assertArrayHasKey( $key, diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Fixture/CreditCardBraintree.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Fixture/CreditCardBraintree.xml deleted file mode 100644 index e9baa301509ce6212e0374dd26c8442157cb6cbf..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Fixture/CreditCardBraintree.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="credit_card_braintree" - module="Magento_Braintree" - type="virtual" - entity_type="credit_card_braintree" - repository_class="Magento\Braintree\Test\Repository\CreditCard" - class="Magento\Braintree\Test\Fixture\CreditCardBraintree"> - <field name="credit_card_number" /> - <field name="credit_card_exp_month" /> - <field name="credit_card_exp_year" /> - <field name="cvv" /> - </fixture> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Page/Adminhtml/SalesOrderView.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Page/Adminhtml/SalesOrderView.xml deleted file mode 100644 index be96e88c35f81a40cc384d4fb137effe58261e53..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Page/Adminhtml/SalesOrderView.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SalesOrderView" area="Adminhtml" mca="sales/order/view" module="Magento_Sales"> - <block name="BraintreeInfoBlock" class="Magento\Braintree\Test\Block\Info" locator="//div[contains(@class, 'admin__page-section-item order-payment-method')]" strategy="xpath"/> - </page> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/CreditCard.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/CreditCard.xml index 6aa9383ff2bd1051364b1498d799ebb681714aca..e780ece1ab971ef3edeb89fed253db6b1cd93a8c 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/CreditCard.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/CreditCard.xml @@ -6,33 +6,29 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Braintree\Test\Repository\CreditCard"> - <dataset name="visa_braintree"> - <field name="credit_card_number" xsi:type="string">4111111111111111</field> - <field name="credit_card_exp_month" xsi:type="string">01</field> - <field name="credit_card_exp_year" xsi:type="string">2020</field> - <field name="cvv" xsi:type="string">123</field> - </dataset> - + <repository class="Magento\Payment\Test\Repository\CreditCard"> <dataset name="visa_braintree_3dsecure"> - <field name="credit_card_number" xsi:type="string">4000000000000002</field> - <field name="credit_card_exp_month" xsi:type="string">01</field> - <field name="credit_card_exp_year" xsi:type="string">20</field> - <field name="cvv" xsi:type="string">123</field> + <field name="payment_code" xsi:type="string">braintree</field> + <field name="cc_number" xsi:type="string">4000000000000002</field> + <field name="cc_exp_month" xsi:type="string">01</field> + <field name="cc_exp_year" xsi:type="string">20</field> + <field name="cc_cid" xsi:type="string">123</field> </dataset> <dataset name="visa_braintree_3dsecure_failed"> - <field name="credit_card_number" xsi:type="string">4000000000000028</field> - <field name="credit_card_exp_month" xsi:type="string">01</field> - <field name="credit_card_exp_year" xsi:type="string">2020</field> - <field name="cvv" xsi:type="string">123</field> + <field name="payment_code" xsi:type="string">braintree</field> + <field name="cc_number" xsi:type="string">4000000000000028</field> + <field name="cc_exp_month" xsi:type="string">01</field> + <field name="cc_exp_year" xsi:type="string">2020</field> + <field name="cc_cid" xsi:type="string">123</field> </dataset> <dataset name="visa_braintree_fraud_rejected"> - <field name="credit_card_number" xsi:type="string">4000111111111511</field> - <field name="credit_card_exp_month" xsi:type="string">01</field> - <field name="credit_card_exp_year" xsi:type="string">2020</field> - <field name="cvv" xsi:type="string">123</field> + <field name="payment_code" xsi:type="string">braintree</field> + <field name="cc_number" xsi:type="string">4000111111111511</field> + <field name="cc_exp_month" xsi:type="string">01</field> + <field name="cc_exp_year" xsi:type="string">2020</field> + <field name="cc_cid" xsi:type="string">123</field> </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/BraintreeSettlementReportTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/BraintreeSettlementReportTest.xml index e80f6071ae5d1d33b37bb7c26c7389ed08aa8962..dba818e57659d86757a11c213c70e314ead2b0c7 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/BraintreeSettlementReportTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/BraintreeSettlementReportTest.xml @@ -18,8 +18,8 @@ <item name="grandTotal" xsi:type="string">15.00</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree</data> <data name="status" xsi:type="string">Processing</data> <data name="tag" xsi:type="string">test_type:extended_acceptance_test, test_type:3rd_party_test, severity:S1</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml index 53847e55fd9f91e29fbeeb6c71a0402a1fb6a6f6..2f14871eda96e102a51ed4ceefd4578af49967b8 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml @@ -14,7 +14,7 @@ <data name="checkoutMethod" xsi:type="string">login</data> <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> <data name="refundedPrices" xsi:type="array"> - <item name="0" xsi:type="string">139.9</item> + <item name="0" xsi:type="string">139.90</item> </data> <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> @@ -34,7 +34,7 @@ <data name="checkoutMethod" xsi:type="string">login</data> <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> <data name="refundedPrices" xsi:type="array"> - <item name="0" xsi:type="string">621.2</item> + <item name="0" xsi:type="string">621.20</item> </data> <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineInvoiceEntityTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineInvoiceEntityTest.xml index d9f382e4b650e5ce48955e264c67b36c893dbb84..da73da001338ade7fdd655609ff4b04d0f8602db 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineInvoiceEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineInvoiceEntityTest.xml @@ -18,11 +18,11 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="capturedPrices" xsi:type="array"> - <item name="0" xsi:type="string">139.9</item> + <item name="0" xsi:type="string">139.90</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree</data> <data name="status" xsi:type="string">Processing</data> <data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Credit Memo, Hold, Ship, Reorder</data> @@ -50,8 +50,8 @@ <item name="1" xsi:type="string">118.25</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree</data> <data name="status" xsi:type="string">Processing</data> <data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Credit Memo, Hold, Ship, Reorder</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOrderBackendTest.xml index 083bd33feca7b133903b9f83eb12c4d5b3f1fcfa..7e010fc4d1f0d31a9e735386ab36a47a5828d6da 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOrderBackendTest.xml @@ -22,8 +22,8 @@ <item name="grandTotal" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree</data> <data name="status" xsi:type="string">Processing</data> <data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Email, Hold, Invoice, Ship, Reorder, Edit</data> @@ -52,8 +52,8 @@ <item name="0" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree, braintree_sale</data> <data name="status" xsi:type="string">Processing</data> <data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Hold, Ship, Reorder</data> @@ -79,7 +79,6 @@ <item name="grandTotal" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> <data name="creditCard/dataset" xsi:type="string">visa_braintree_fraud_rejected</data> <data name="configData" xsi:type="string">braintree</data> <data name="status" xsi:type="string">Processing</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml index c9b26df050cfc9cf9ef4913a4f538459cee1923f..123a453a921d648fa3a5e2d579904d3373c5e1db 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml @@ -20,8 +20,8 @@ </data> <data name="payment/method" xsi:type="string">braintree</data> <data name="vault/method" xsi:type="string">braintree_cc_vault</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="creditCardSave" xsi:type="string">Yes</data> <data name="configData" xsi:type="string">braintree, braintree_use_vault</data> <data name="status" xsi:type="string">Processing</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml index 352e0ed684919a43df66b429d5b8250d90cae351..23985d208e5a675b997d330e792eb58f1045d7d9 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml @@ -15,10 +15,10 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="prices" xsi:type="array"> - <item name="grandTotal" xsi:type="string">139.9</item> + <item name="grandTotal" xsi:type="string">139.90</item> </data> <data name="capturedPrices" xsi:type="array"> - <item name="0" xsi:type="string">139.9</item> + <item name="0" xsi:type="string">139.90</item> </data> <data name="payment/method" xsi:type="string">braintree_paypal</data> <data name="configData" xsi:type="string">braintree, braintree_paypal, braintree_paypal_skip_order_review</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutAcceptPaymentTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutAcceptPaymentTest.xml index 841145d7a5fdfaa92f1a82ac00c9bf51f0601643..1b9540c443650216b2288dedab699f292f20aa77 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutAcceptPaymentTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutAcceptPaymentTest.xml @@ -17,8 +17,8 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree,braintree_fraudprotection</data> <data name="status" xsi:type="string">Processing</data> <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S2</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDeclinedTest.xml index 4a2aa551a18170002045f821de2d492ddb7a2082..510d27d324f928e46571708ea457256be5ad93a8 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDeclinedTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDeclinedTest.xml @@ -15,7 +15,6 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> <data name="creditCard/dataset" xsi:type="string">visa_braintree_fraud_rejected</data> <data name="expectedErrorMessage" xsi:type="string">Transaction has been declined. Please try again later.</data> <data name="configData" xsi:type="string">braintree_fraud_tool_enabled_account, braintree_fraudprotection</data> @@ -31,8 +30,8 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="expectedErrorMessage" xsi:type="string">Sorry, but something went wrong</data> <data name="configData" xsi:type="string">braintree, braintree_incorrect_merchant_account_id</data> <data name="status" xsi:type="string">Processing</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDenyPaymentTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDenyPaymentTest.xml index 95d07079ef36c9ae66672ec8cc465325273ecda4..8d16fcc3fcae11aa51f45c426406d842804fe936 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDenyPaymentTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutDenyPaymentTest.xml @@ -17,8 +17,8 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree,braintree_fraudprotection</data> <data name="status" xsi:type="string">Canceled</data> <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S2</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutTest.xml index 54fdfc96dc947db330c37b701132bfc0e3fcbeb0..c99a855b236a5ee45f7eba8d604bd3c0db50bb7a 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutTest.xml @@ -21,7 +21,6 @@ <item name="grandTotal" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> <data name="creditCard/dataset" xsi:type="string">visa_braintree_3dsecure</data> <data name="isVaultPresent" xsi:type="boolean">false</data> <data name="configData" xsi:type="string">braintree, braintree_3d_secure_not_triggered_due_threshold</data> @@ -45,7 +44,6 @@ <item name="grandTotal" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> <data name="creditCard/dataset" xsi:type="string">visa_braintree_3dsecure</data> <data name="isVaultPresent" xsi:type="boolean">false</data> <data name="configData" xsi:type="string">braintree, braintree_3d_secure_uk</data> @@ -69,8 +67,8 @@ <item name="grandTotal" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="isVaultPresent" xsi:type="boolean">false</data> <data name="configData" xsi:type="string">braintree</data> <data name="status" xsi:type="string">Processing</data> @@ -97,8 +95,8 @@ <item name="0" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="isVaultPresent" xsi:type="boolean">false</data> <data name="configData" xsi:type="string">braintree, braintree_sale</data> <data name="status" xsi:type="string">Processing</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureFailedTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureFailedTest.xml index 2a17d1496a72dfb1bb63073ccd982abf3522ca9f..12cde9b6233a96f0ff94396adf9e42e057af883b 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureFailedTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureFailedTest.xml @@ -15,7 +15,6 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> <data name="creditCard/dataset" xsi:type="string">visa_braintree_3dsecure_failed</data> <data name="secure3d/dataset" xsi:type="string">secure3d_braintree</data> <data name="configData" xsi:type="string">braintree, braintree_3d_secure</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureTest.xml index 295a9dcd5c5332dce7d6e5fad9dfcdc6f5352596..051700480fcb3f49f551190d557f210b3686e719 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWith3dSecureTest.xml @@ -22,7 +22,6 @@ <item name="grandTotal" xsi:type="string">145.98</item> </data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> <data name="creditCard/dataset" xsi:type="string">visa_braintree_3dsecure</data> <data name="paymentInformation" xsi:type="array"> <item name="Liability Shifted" xsi:type="string">1</item> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWithDiscountTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWithDiscountTest.xml index f8ffa51982f1fae4d34a6290e1bebce28ba85712..06299e2e5a10c3ea7658ff3e06c42861820edc13 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWithDiscountTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/OnePageCheckoutWithDiscountTest.xml @@ -17,8 +17,8 @@ <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="prices" xsi:type="array"> <item name="grandTotal" xsi:type="string">10.00</item> </data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/ReorderUsingVaultTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/ReorderUsingVaultTest.xml index 5f5e2f50594bf8d0473b65ee584e50f47bc852a4..1b7d248d537dc839ae258f3a1d16040d12f95fd1 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/ReorderUsingVaultTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/ReorderUsingVaultTest.xml @@ -21,8 +21,8 @@ <data name="payment/method" xsi:type="string">braintree</data> <data name="vault/method" xsi:type="string">braintree_cc_vault</data> <data name="isVaultPresent" xsi:type="boolean">false</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree, braintree_use_vault</data> <data name="status" xsi:type="string">Processing</data> <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml index 35d55784b676236d808cf0f54fc969fc65193b0b..327a1f8eb2ca2b9db845f7c78a98db11feb047ef 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml @@ -17,8 +17,8 @@ <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> <data name="vault/method" xsi:type="string">braintree_cc_vault</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> - <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="creditCardSave" xsi:type="string">Yes</data> <data name="configData" xsi:type="string">braintree, braintree_use_vault</data> <data name="status" xsi:type="string">Processing</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultWith3dSecureOnCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultWith3dSecureOnCheckoutTest.xml index a5aa7645148e158ad62a174bc26d08abfd037192..8dd9239d38526622b5facb9ab71b1c9e3e1511b3 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultWith3dSecureOnCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultWith3dSecureOnCheckoutTest.xml @@ -17,7 +17,6 @@ <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">braintree</data> <data name="vault/method" xsi:type="string">braintree_cc_vault</data> - <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> <data name="creditCard/dataset" xsi:type="string">visa_braintree_3dsecure</data> <data name="paymentInformation" xsi:type="array"> <item name="Liability Shifted" xsi:type="string">1</item> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php index cb46e728191bffb5a770a2809019fb2833f9f0d3..be3abf935c5a42557bea3b6feea86e4301b001f1 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php @@ -6,9 +6,6 @@ namespace Magento\Bundle\Test\Fixture\Cart; -use Magento\Bundle\Test\Fixture\BundleProduct; -use Magento\Mtf\Fixture\FixtureInterface; - /** * Data for verify cart item block on checkout page. * @@ -18,42 +15,32 @@ use Magento\Mtf\Fixture\FixtureInterface; class Item extends \Magento\Catalog\Test\Fixture\Cart\Item { /** - * @constructor - * @param FixtureInterface $product + * Return prepared dataset. + * + * @param null|string $key + * @return array */ - public function __construct(FixtureInterface $product) + public function getData($key = null) { - parent::__construct($product); - - /** @var BundleProduct $product */ - $bundleSelection = $product->getBundleSelections(); - $checkoutData = $product->getCheckoutData(); + parent::getData($key); + $bundleSelection = $this->product->getBundleSelections(); + $checkoutData = $this->product->getCheckoutData(); $checkoutBundleOptions = isset($checkoutData['options']['bundle_options']) ? $checkoutData['options']['bundle_options'] : []; + $productSku = [$this->product->getSku()]; foreach ($checkoutBundleOptions as $checkoutOptionKey => $checkoutOption) { - // Find option and value keys - $attributeKey = null; - $optionKey = null; - foreach ($bundleSelection['bundle_options'] as $key => $option) { - if ($option['title'] == $checkoutOption['title']) { - $attributeKey = $key; - - foreach ($option['assigned_products'] as $valueKey => $value) { - if (false !== strpos($value['search_data']['name'], $checkoutOption['value']['name'])) { - $optionKey = $valueKey; - } - } - } - } - + $keys = $this->getKeys($bundleSelection['bundle_options'], $checkoutOption); + $attributeKey = $keys['attribute']; + $optionKey = $keys['option']; // Prepare option data $bundleSelectionAttribute = $bundleSelection['products'][$attributeKey]; $bundleOptions = $bundleSelection['bundle_options'][$attributeKey]; $value = $bundleSelectionAttribute[$optionKey]->getName(); + $this->product->getSkuType() == 'No' ?: $productSku[] = $bundleSelectionAttribute[$optionKey]->getSku(); $qty = $bundleOptions['assigned_products'][$optionKey]['data']['selection_qty']; - $price = $product->getPriceType() == 'Yes' + $price = $this->product->getPriceType() == 'Yes' ? number_format($bundleSelectionAttribute[$optionKey]->getPrice(), 2) : number_format($bundleOptions['assigned_products'][$optionKey]['data']['selection_price_value'], 2); $optionData = [ @@ -64,6 +51,47 @@ class Item extends \Magento\Catalog\Test\Fixture\Cart\Item $checkoutBundleOptions[$checkoutOptionKey] = $optionData; } + $this->data['sku'] = implode('-', $productSku); $this->data['options'] += $checkoutBundleOptions; + + return $this->data; + } + + /** + * Get option key. + * + * @param array $assignedProducts + * @param string $checkoutOption + * @return null|string + */ + private function getOptionKey(array $assignedProducts, $checkoutOption) + { + foreach ($assignedProducts as $key => $value) { + if (false !== strpos($value['search_data']['name'], $checkoutOption)) { + return $key; + } + } + + return null; + } + + /** + * Find option and attribute keys. + * + * @param array $bundleOptions + * @param string $checkoutOption + * @return array + */ + private function getKeys(array $bundleOptions, $checkoutOption) + { + $keys = []; + foreach ($bundleOptions as $key => $option) { + if ($option['title'] == $checkoutOption['title']) { + $keys['attribute'] = $key; + $keys['option'] = $this->getOptionKey($option['assigned_products'], $checkoutOption['value']['name']); + } + } + + return $keys; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/CustomAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/CustomAttribute.php index 53fe49b759c64ec85b5eb8fedd8bae8aa7627757..3c324de0cabab5d35abf23d4d9ae354675bfdbe6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/CustomAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/CustomAttribute.php @@ -102,7 +102,7 @@ class CustomAttribute extends SimpleElement { $element = null; foreach (array_keys($this->classReferences) as $key) { - if (strpos($class, $key) !== false) { + if ($class == $key) { return $this->classReferences[$class]; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Cart/Item.php index c7dbba386958a30f19ec9001add2566da76a7b7f..fb0ecca863582cd50f619320f62d0b4ffc1f1a58 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Cart/Item.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Cart/Item.php @@ -8,7 +8,6 @@ namespace Magento\Catalog\Test\Fixture\Cart; use Magento\Mtf\Fixture\DataSource; use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Catalog\Test\Fixture\CatalogProductSimple; /** * Data for verify cart item block on checkout page. @@ -21,15 +20,31 @@ use Magento\Catalog\Test\Fixture\CatalogProductSimple; class Item extends DataSource { /** - * @constructor + * Product fixture. + * + * @var FixtureInterface + */ + protected $product; + + /** * @param FixtureInterface $product */ public function __construct(FixtureInterface $product) { - /** @var CatalogProductSimple $product */ - $checkoutData = $product->getCheckoutData(); + $this->product = $product; + } + + /** + * Return prepared dataset. + * + * @param null|string $key + * @return array + */ + public function getData($key = null) + { + $checkoutData = $this->product->getCheckoutData(); $cartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : []; - $customOptions = $product->hasData('custom_options') ? $product->getCustomOptions() : []; + $customOptions = $this->product->hasData('custom_options') ? $this->product->getCustomOptions() : []; $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : []; @@ -52,9 +67,12 @@ class Item extends DataSource ? $cartItem['options'] + $checkoutCustomOptions : $checkoutCustomOptions; $cartItem['qty'] = isset($checkoutData['qty']) - ? $checkoutData['qty'] - : 1; - + ? $checkoutData['qty'] + : 1; + $cartItem['sku'] = $this->product->getSku(); + $cartItem['name'] = $this->product->getName(); $this->data = $cartItem; + + return parent::getData($key); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml index 2fd8c04d1d80dfe643616ee7c550699da91aeece..dc5e9c12ebcaebc1e49c8394f4d4308a11762309 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml @@ -72,5 +72,18 @@ <field name="is_active" xsi:type="string">Yes</field> <field name="include_in_menu" xsi:type="string">Yes</field> </dataset> + + <dataset name="default_subcategory_with_assigned_simple_product"> + <field name="name" xsi:type="string">Category%isolation%</field> + <field name="url_key" xsi:type="string">category%isolation%</field> + <field name="is_active" xsi:type="string">Yes</field> + <field name="include_in_menu" xsi:type="string">Yes</field> + <field name="parent_id" xsi:type="array"> + <item name="dataset" xsi:type="string">default_category</item> + </field> + <field name="category_products" xsi:type="array"> + <item name="dataset" xsi:type="string">catalogProductSimple::default</item> + </field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml index 82a7c263b1ca9671d8b125ac6a3f07e6324fa072..fee6efedff2e281742738d02cfdf36a644203b4e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml @@ -167,7 +167,7 @@ <item name="selector" xsi:type="string">[name="product[%code%]"]</item> <item name="type" xsi:type="string">null</item> </item> - <item name="hasDatepicker" xsi:type="array"> + <item name="admin__control-text _has-datepicker" xsi:type="array"> <item name="selector" xsi:type="string">[name="product[%code%]"]</item> <item name="type" xsi:type="string">datepicker</item> </item> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php index ce8f5a4cbfd99b41e990a11fc89527f28b0fec5f..31002bd8129c4f39d6a2ffd670f70af7fcf48da2 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php @@ -7,7 +7,7 @@ namespace Magento\Checkout\Test\Block\Onepage; use Magento\Mtf\Block\Block; -use Magento\Mtf\Fixture\InjectableFixture; +use Magento\Payment\Test\Fixture\CreditCard; /** * Checkout payment block. @@ -47,7 +47,7 @@ class Payment extends Block * * @var string */ - protected $placeOrder = '.action.primary.checkout'; + protected $placeOrder = '.payment-method._active .action.primary.checkout'; /** * Wait element. @@ -74,14 +74,19 @@ class Payment extends Block * Select payment method. * * @param array $payment - * @param InjectableFixture|null $creditCard + * @param CreditCard|null $creditCard + * @param bool $fillCreditCardOn3rdParty * @throws \Exception * @return void */ - public function selectPaymentMethod(array $payment, InjectableFixture $creditCard = null) - { - $paymentSelector = sprintf($this->paymentMethodInput, $payment['method']); - $paymentLabelSelector = sprintf($this->paymentMethodLabel, $payment['method']); + public function selectPaymentMethod( + array $payment, + CreditCard $creditCard = null, + $fillCreditCardOn3rdParty = false + ) { + $paymentMethod = $payment['method']; + $paymentSelector = sprintf($this->paymentMethodInput, $paymentMethod); + $paymentLabelSelector = sprintf($this->paymentMethodLabel, $paymentMethod); try { $this->waitForElementNotVisible($this->waitElement); @@ -100,16 +105,15 @@ class Payment extends Block $paymentRadioButton->click(); } - if ($payment['method'] == "purchaseorder") { + if ($paymentMethod == "purchaseorder") { $this->_rootElement->find($this->purchaseOrderNumber)->setValue($payment['po_number']); } - if ($creditCard !== null) { - $class = explode('\\', get_class($creditCard)); - $module = $class[1]; - /** @var \Magento\Payment\Test\Block\Form\Cc $formBlock */ + if ($creditCard !== null && $fillCreditCardOn3rdParty === false) { + $module = $creditCard->hasData('payment_code') ? ucfirst($creditCard->getPaymentCode()) : 'Payment'; + /** @var \Magento\Payment\Test\Block\Form\PaymentCc $formBlock */ $formBlock = $this->blockFactory->create( - "\\Magento\\{$module}\\Test\\Block\\Form\\Cc", - ['element' => $this->_rootElement->find('#payment_form_' . $payment['method'])] + "\\Magento\\{$module}\\Test\\Block\\Form\\{$module}Cc", + ['element' => $this->_rootElement->find('#payment_form_' . $paymentMethod)] ); $formBlock->fill($creditCard); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart.xml index 04b191b2b65834a0786510a61fd4c3170530476b..5286881980704c62438816aa23155f092a6eb56c 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart.xml @@ -10,7 +10,6 @@ module="Magento_Checkout" type="flat" entity_type="quote" - repository_class="Magento\Checkout\Test\Repository\Cart" handler_interface="Magento\Checkout\Test\Handler\Cart\CartInterface" class="Magento\Checkout\Test\Fixture\Cart"> <field name="entity_id" is_required="1" /> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php index 0733d778b9662dba9c857eff90b213b4da77e4c3..e41af50cca9f624c489dd8af497d601f0d41a426 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php @@ -30,6 +30,7 @@ class AddProductsToShoppingCartEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S0'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml index 9a539d856e7082ae5131e903d7d86eec5f37d6c5..cac5e0a9c2182a05e8925a375396b7fe6f610a99 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\AddProductsToShoppingCartEntityTest" summary="Add Products to Shopping Cart" ticketId="MAGETWO-25382"> <variation name="AddProductsToShoppingCartEntityTestVariation1"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S2</data> <data name="productsData/0" xsi:type="string">bundleProduct::bundle_dynamic_product</data> <data name="cart/data/grand_total" xsi:type="string">210</data> <data name="cart/data/subtotal" xsi:type="string">200</data> @@ -21,7 +21,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart" /> </variation> <variation name="AddProductsToShoppingCartEntityTestVariation2"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S2</data> <data name="productsData/0" xsi:type="string">bundleProduct::bundle_fixed_product</data> <data name="cart/data/grand_total" xsi:type="string">761</data> <data name="cart/data/subtotal" xsi:type="string">756</data> @@ -34,7 +34,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart" /> </variation> <variation name="AddProductsToShoppingCartEntityTestVariation3"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S0</data> <data name="productsData/0" xsi:type="string">catalogProductSimple::with_two_custom_option</data> <data name="cart/data/grand_total" xsi:type="string">345</data> <data name="cart/data/subtotal" xsi:type="string">340</data> @@ -47,7 +47,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart" /> </variation> <variation name="AddProductsToShoppingCartEntityTestVariation4"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S1</data> <data name="productsData/0" xsi:type="string">catalogProductVirtual::product_50_dollar</data> <data name="cart/data/grand_total" xsi:type="string">50</data> <data name="cart/data/subtotal" xsi:type="string">50</data> @@ -60,7 +60,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart" /> </variation> <variation name="AddProductsToShoppingCartEntityTestVariation5"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S0</data> <data name="productsData/0" xsi:type="string">configurableProduct::default</data> <data name="cart/data/grand_total" xsi:type="string">135</data> <data name="cart/data/subtotal" xsi:type="string">120</data> @@ -73,6 +73,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart" /> </variation> <variation name="AddProductsToShoppingCartEntityTestVariation6"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="productsData/0" xsi:type="string">downloadableProduct::with_two_separately_links</data> <data name="cart/data/grand_total" xsi:type="string">22.43</data> <data name="cart/data/subtotal" xsi:type="string">22.43</data> @@ -85,7 +86,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart" /> </variation> <variation name="AddProductsToShoppingCartEntityTestVariation7"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S2</data> <data name="productsData/0" xsi:type="string">groupedProduct::three_simple_products</data> <data name="cart/data/grand_total" xsi:type="string">1950</data> <data name="cart/data/subtotal" xsi:type="string">1920</data> @@ -98,7 +99,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart" /> </variation> <variation name="AddProductsToShoppingCartEntityTestVariation8"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S0</data> <data name="productsData/0" xsi:type="string">catalogProductSimple::with_two_custom_option</data> <data name="productsData/1" xsi:type="string">catalogProductVirtual::product_50_dollar</data> <data name="productsData/2" xsi:type="string">downloadableProduct::with_two_separately_links</data> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php index f2a809656ed65449fc63d5405b3449f8587005c5..d19ad5497b5dc6009d6e825571dd2f0ab8d67df4 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.php @@ -32,6 +32,7 @@ class DeleteProductFromMiniShoppingCartTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S0'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.xml index 10f1245c2e4fbf20764519641b443e978bc04bf6..47387bb32ca9ebc857cf5df0d4c9129c8f459742 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductFromMiniShoppingCartTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\DeleteProductFromMiniShoppingCartTest" summary="Delete Product from Mini Shopping Cart" ticketId="MAGETWO-29104"> <variation name="DeleteProductFromMiniShoppingCartTestVariation1"> + <data name="tag" xsi:type="string">severity:S0</data> <data name="description" xsi:type="string">delete Simple</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="products/1" xsi:type="string">catalogProductVirtual::default</data> @@ -16,6 +17,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertProductPresentInMiniShoppingCart" /> </variation> <variation name="DeleteProductFromMiniShoppingCartTestVariation2"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="description" xsi:type="string">delete Simple</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="deletedProductIndex" xsi:type="string">0</data> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php index ae48e6e6b79487571539aa28567f7dd930b57237..877fd28593cfb060a0b1ac1e2d33bc3d42a425f7 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.php @@ -30,6 +30,7 @@ class DeleteProductsFromShoppingCartTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S1'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.xml index 033ea76a2a5ff17c5233d7f1b543f6b72f013c61..2af59cbaac6a49bd64706d52477e9b481a28e976 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/DeleteProductsFromShoppingCartTest.xml @@ -8,36 +8,42 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\DeleteProductsFromShoppingCartTest" summary="Delete Products from Shopping Cart" ticketId="MAGETWO-25218"> <variation name="DeleteProductsFromShoppingCartTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="productsData/0" xsi:type="string">bundleProduct::bundle_dynamic_product</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> </variation> <variation name="DeleteProductsFromShoppingCartTestVariation2"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="productsData/0" xsi:type="string">bundleProduct::bundle_fixed_product</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> </variation> <variation name="DeleteProductsFromShoppingCartTestVariation3"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S1</data> <data name="productsData/0" xsi:type="string">catalogProductSimple::with_two_custom_option</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> </variation> <variation name="DeleteProductsFromShoppingCartTestVariation4"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="productsData/0" xsi:type="string">catalogProductVirtual::product_50_dollar</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> </variation> <variation name="DeleteProductsFromShoppingCartTestVariation5"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="productsData/0" xsi:type="string">configurableProduct::default</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> </variation> <variation name="DeleteProductsFromShoppingCartTestVariation6"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="productsData/0" xsi:type="string">downloadableProduct::with_two_separately_links</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> </variation> <variation name="DeleteProductsFromShoppingCartTestVariation7"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="productsData/0" xsi:type="string">groupedProduct::three_simple_products</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> </variation> <variation name="DeleteProductsFromShoppingCartTestVariation8"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">to_maintain:yes, severity:S1</data> <data name="productsData/0" xsi:type="string">catalogProductSimple::with_two_custom_option</data> <data name="productsData/1" xsi:type="string">catalogProductVirtual::product_50_dollar</data> <data name="productsData/2" xsi:type="string">downloadableProduct::with_two_separately_links</data> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.php index 5361ee6e3c127bafc03e53cd717ac067688f826a..a3ba73a1caf41c3d5ab2220feeab58ff3bc510df 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.php @@ -21,6 +21,10 @@ use Magento\Mtf\TestCase\Scenario; */ class OnePageCheckoutJsValidationTest extends Scenario { + /* tags */ + const SEVERITY = 'S2'; + /* end tags */ + /** * Runs one page checkout js validation test. * diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.xml index e930ff29882ceed4e8f99947a6a6ef4b4acc1c7a..f8f9b93661aa1b914e6fd4000cd0ece8f7dac302 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutJsValidationTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\OnePageCheckoutJsValidationTest" summary="JS validation verification for Checkout flow" ticketId="MAGETWO-59697"> <variation name="OnePageCheckoutJsValidationTestVariation1" summary="JS validation is not applied for empty required checkout fields if customer did not fill them"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="checkoutMethod" xsi:type="string">guest</data> <constraint name="Magento\Checkout\Test\Constraint\AssertShippingAddressJsValidationMessagesIsAbsent" /> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php index 25922102e1269c95280697db6c3175c36d6253fc..63454c8137975a4a64ee36e20ac596c5fcbc4f7d 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php @@ -41,6 +41,7 @@ class OnePageCheckoutTest extends Scenario /* tags */ const MVP = 'yes'; const TEST_TYPE = 'acceptance_test, extended_acceptance_test, 3rd_party_test'; + const SEVERITY = 'S0'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml index 14d8ecccd1dc34e5dbde389f2c74ff15fcca6c20..1b6f78148a129a1bd575fe12a91b99e7cbde87aa 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\OnePageCheckoutTest" summary="OnePageCheckout within Offline Payment Methods" ticketId="MAGETWO-27485"> <variation name="OnePageCheckoutUsingLoginPopup" summary="Customer is redirected to checkout on login if guest is disabled, flow for existed Customer" ticketId="MAGETWO-49916"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">johndoe_with_addresses</data> <data name="checkoutMethod" xsi:type="string">login</data> @@ -21,6 +22,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> </variation> <variation name="OnePageCheckoutUsingRegisterLink" summary="Customer is redirected to checkout on login if guest is disabled, flow with registration new Customer" ticketId="MAGETWO-49917"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="issue" xsi:type="string">MAGETWO-59816: Redirect works improperly in a browser incognito mode</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">register_customer</data> @@ -36,6 +38,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> </variation> <variation name="OnePageCheckoutTestVariation1" summary="Checkout as UK guest with virtual product and downloadable product using coupon for not logged in customers"> + <data name="tag" xsi:type="string">severity:S0</data> <data name="products/0" xsi:type="string">catalogProductVirtual::default</data> <data name="products/1" xsi:type="string">downloadableProduct::with_two_separately_links</data> <data name="salesRule" xsi:type="string">active_sales_rule_for_all_groups</data> @@ -55,7 +58,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutTestVariation2" summary="US customer during checkout using coupon for all customer groups"> - <data name="tag" xsi:type="string">stable:no</data> + <data name="tag" xsi:type="string">stable:no, severity:S0</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="salesRule" xsi:type="string">active_sales_rule_for_all_groups</data> <data name="customer/dataset" xsi:type="string">default</data> @@ -77,7 +80,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutTestVariation3" summary="Checkout as UK guest with simple product" ticketId="MAGETWO-42603"> - <data name="tag" xsi:type="string">stable:no</data> + <data name="tag" xsi:type="string">stable:no, severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">default</data> <data name="checkoutMethod" xsi:type="string">guest</data> @@ -98,7 +101,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutTestVariation4" summary="One Page Checkout Products with Special Prices" ticketId="MAGETWO-12429"> - <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, severity:S0</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_with_special_price</data> <data name="products/1" xsi:type="string">configurableProduct::product_with_special_price</data> <data name="customer/dataset" xsi:type="string">default</data> @@ -120,7 +123,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal"/> </variation> <variation name="OnePageCheckoutTestVariation5" summary="Guest Checkout using Check/Money Order and Free Shipping with Prices/Taxes Verifications" ticketId="MAGETWO-12412"> - <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no, severity:S0</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> <data name="products/1" xsi:type="string">configurableProduct::with_one_option</data> <data name="products/2" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data> @@ -144,6 +147,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutTestVariation6" summary="Checkout as UK guest with virtual product using coupon for not logged in customers with Zero Subtotal Checkout payment method"> + <data name="tag" xsi:type="string">severity:S0</data> <data name="products/0" xsi:type="string">catalogProductVirtual::product_50_dollar</data> <data name="salesRule" xsi:type="string">active_sales_rule_with_fixed_price_discount_coupon</data> <data name="customer/dataset" xsi:type="string">default</data> @@ -163,6 +167,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutTestVariation7" summary="Checkout as UK guest with condition available product qty = ordered product qty"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_with_qty_25</data> <data name="checkoutMethod" xsi:type="string">guest</data> <data name="shippingAddress/dataset" xsi:type="string">UK_address</data> @@ -182,6 +187,7 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductsOutOfStock" /> </variation> <variation name="OnePageCheckoutTestVariation8" summary="Checkout as UK customer with different shipping/billing address and register checkout method"> + <data name="tag" xsi:type="string">severity:S0</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">default</data> <data name="checkoutMethod" xsi:type="string">register</data> @@ -197,7 +203,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutTestVariation9" summary="One Page Checkout Products with different shipping/billing address and Tier Prices" ticketId="MAGETWO-42604"> - <data name="tag" xsi:type="string">stable:no</data> + <data name="tag" xsi:type="string">stable:no, severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::simple_with_tier_price_and_order_qty_3</data> <data name="customer/dataset" xsi:type="string">default</data> <data name="checkoutMethod" xsi:type="string">login</data> @@ -216,7 +222,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutTestVariation10" summary="One Page Checkout with all product types"> - <data name="tag" xsi:type="string">stable:no</data> + <data name="tag" xsi:type="string">stable:no, severity:S0</data> <data name="products/0" xsi:type="string">catalogProductVirtual::default</data> <data name="products/1" xsi:type="string">downloadableProduct::with_two_separately_links</data> <data name="products/2" xsi:type="string">configurableProduct::with_one_option</data> @@ -237,6 +243,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> </variation> <variation name="OnePageCheckoutUsingSingInLink" summary="Login during checkout using 'Sign In' link" ticketId="MAGETWO-42547"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">customer_UK_US_addresses</data> <data name="checkoutMethod" xsi:type="string">sign_in</data> @@ -257,6 +264,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderAddresses" /> </variation> <variation name="OnePageCheckoutUsingNonDefaultAddress" summary="Checkout as Customer using non default address" ticketId="MAGETWO-42602"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">customer_US_DE_UK</data> <data name="checkoutMethod" xsi:type="string">login</data> @@ -278,6 +286,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderAddresses" /> </variation> <variation name="OnePageCheckoutUsingNewAddress" summary="Checkout as Customer using New address" ticketId="MAGETWO-42601"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">johndoe_with_addresses</data> <data name="checkoutMethod" xsi:type="string">sign_in</data> @@ -296,6 +305,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderAddresses" /> </variation> <variation name="OnePageCheckoutTestVariation11" summary="Checkout as Customer using default address" ticketId="MAGETWO-42600, MAGETWO-42546"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">customer_UK_US_addresses</data> <data name="checkoutMethod" xsi:type="string">login</data> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php index 0bfe42f7fe78ced0ffb2282d69790ca42c4a1dec..3a9d381de3d810b59437fd3a73028bb058d3915c 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php @@ -34,6 +34,7 @@ class UpdateProductFromMiniShoppingCartEntityTest extends Injectable /* tags */ const MVP = 'yes'; const TEST_TYPE = 'extended_acceptance_test'; + const SEVERITY = 'S0'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml index cd500a935485cd0e08981d32a53b9280a7d2ad57..f7a675d36c5bd38c5ffc2153f0c7f47fe60f986f 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\UpdateProductFromMiniShoppingCartEntityTest" summary="Update Product from Mini Shopping Cart" ticketId="MAGETWO-29812"> <variation name="UpdateProductFromMiniShoppingCartEntityTestVariation1" summary="Update Product Qty on Mini Shopping Cart" ticketId=" MAGETWO-35536"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, severity:S0</data> <data name="originalProduct/0" xsi:type="string">catalogProductSimple::default</data> <data name="checkoutData/dataset" xsi:type="string">simple_order_qty_2</data> <data name="use_minicart_to_edit_qty" xsi:type="boolean">true</data> @@ -25,7 +25,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertCustomerIsRedirectedToCheckoutFromCart" /> </variation> <variation name="UpdateProductFromMiniShoppingCartEntityTestVariation2" summary="Update Configurable and verify previous product was updated to new one in shopping cart and mini shopping cart"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes, severity:S0</data> <data name="originalProduct/0" xsi:type="string">configurableProduct::default</data> <data name="checkoutData/dataset" xsi:type="string">configurable_update_mini_shopping_cart</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartItemsOptions" /> @@ -34,7 +34,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertProductOptionsAbsentInShoppingCart" /> </variation> <variation name="UpdateProductFromMiniShoppingCartEntityTestVariation3" summary="Update Bundle and verify previous product was updated to new one in shopping cart and mini shopping cart"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes, severity:S0</data> <data name="originalProduct/0" xsi:type="string">bundleProduct::bundle_fixed_product</data> <data name="checkoutData/dataset" xsi:type="string">bundle_update_mini_shopping_cart</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartItemsOptions" /> @@ -43,7 +43,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertProductOptionsAbsentInShoppingCart" /> </variation> <variation name="UpdateProductFromMiniShoppingCartEntityTestVariation4" summary="Update Downloadable and check previous link was updated to new one in shopping cart and mini shopping cart"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes, severity:S1</data> <data name="originalProduct/0" xsi:type="string">downloadableProduct::with_two_separately_links</data> <data name="checkoutData/dataset" xsi:type="string">downloadable_update_mini_shopping_cart</data> <constraint name="Magento\Checkout\Test\Constraint\AssertCartItemsOptions" /> @@ -52,7 +52,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertProductOptionsAbsentInShoppingCart" /> </variation> <variation name="UpdateProductFromMiniShoppingCartEntityTestVariation5" summary="Update Virtual product in mini shopping cart"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, to_maintain:yes, severity:S1</data> <data name="originalProduct/0" xsi:type="string">catalogProductVirtual::default</data> <data name="checkoutData/dataset" xsi:type="string">virtual_update_mini_shopping_cart</data> <constraint name="Magento\Checkout\Test\Constraint\AssertProductDataInMiniShoppingCart" /> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.php index 3dba57e26e003726e856577f5e4b48a427428a24..57ef98528c877e96bd21d0773aa16d79466aed7a 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.php @@ -34,6 +34,7 @@ class UpdateShoppingCartTest extends Injectable /* tags */ const MVP = 'yes'; const STABLE = 'no'; + const SEVERITY = 'S0'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml index 42428189f44b06b3c33550efb453d34900045133..912bb57e3f1eb2b00e4e481b8fa83c64975380dd 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\UpdateShoppingCartTest" summary="Update Shopping Cart" ticketId="MAGETWO-25081"> <variation name="UpdateShoppingCartTestVariation1"> + <data name="tag" xsi:type="string">severity:S0</data> <data name="product/dataset" xsi:type="string">default</data> <data name="product/data/price/value" xsi:type="string">100</data> <data name="product/data/checkout_data/qty" xsi:type="string">3</data> @@ -19,6 +20,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInShoppingCart" /> </variation> <variation name="UpdateShoppingCartTestVariation2"> + <data name="tag" xsi:type="string">severity:S0</data> <data name="product/dataset" xsi:type="string">with_two_custom_option</data> <data name="product/data/price/value" xsi:type="string">50</data> <data name="product/data/checkout_data/qty" xsi:type="string">11</data> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/AddProductsToTheCartStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/AddProductsToTheCartStep.php index 37df8ea8b89255ca5a1d522b1b0c7c6bc6ffcf5c..d6fb3a272b4290f50a32c88a739f5620c0066c99 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/AddProductsToTheCartStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/AddProductsToTheCartStep.php @@ -10,6 +10,7 @@ use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Checkout\Test\Page\CheckoutCart; use Magento\Cms\Test\Page\CmsIndex; use Magento\Mtf\Client\BrowserInterface; +use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestStep\TestStepInterface; /** @@ -18,46 +19,53 @@ use Magento\Mtf\TestStep\TestStepInterface; class AddProductsToTheCartStep implements TestStepInterface { /** - * Array with products + * Array with products. * * @var array */ - protected $products; + private $products; /** - * Frontend product view page + * Storefront product view page. * * @var CatalogProductView */ - protected $catalogProductView; + private $catalogProductView; /** - * Page of checkout page + * Page of checkout page. * * @var CheckoutCart */ - protected $checkoutCart; + private $checkoutCart; /** - * Cms index page + * Cms index page. * * @var CmsIndex */ - protected $cmsIndex; + private $cmsIndex; /** - * Interface Browser + * Client Browser instance. * * @var BrowserInterface */ - protected $browser; + private $browser; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + private $fixtureFactory; /** - * @constructor * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param CmsIndex $cmsIndex * @param BrowserInterface $browser + * @param FixtureFactory $fixtureFactory * @param array $products */ public function __construct( @@ -65,19 +73,21 @@ class AddProductsToTheCartStep implements TestStepInterface CheckoutCart $checkoutCart, CmsIndex $cmsIndex, BrowserInterface $browser, + FixtureFactory $fixtureFactory, array $products ) { - $this->products = $products; $this->catalogProductView = $catalogProductView; $this->checkoutCart = $checkoutCart; $this->cmsIndex = $cmsIndex; $this->browser = $browser; + $this->fixtureFactory = $fixtureFactory; + $this->products = $products; } /** - * Add products to the cart + * Add products to the cart. * - * @return void + * @return array */ public function run() { @@ -89,5 +99,7 @@ class AddProductsToTheCartStep implements TestStepInterface $this->catalogProductView->getViewBlock()->addToCart($product); $this->catalogProductView->getMessagesBlock()->waitSuccessMessage(); } + $cart['data']['items'] = ['products' => $this->products]; + return ['cart' => $this->fixtureFactory->createByCode('cart', $cart)]; } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/GetPlacedOrderIdStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/GetPlacedOrderIdStep.php new file mode 100644 index 0000000000000000000000000000000000000000..8d4fa8e471fbc18519f9c9cc3a5917c51789a066 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/GetPlacedOrderIdStep.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Checkout\Test\TestStep; + +use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; +use Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator; + +/** + * Get successfully placed order id. + */ +class GetPlacedOrderIdStep implements TestStepInterface +{ + /** + * Order success page. + * + * @var CheckoutOnepageSuccess + */ + private $checkoutOnepageSuccess; + + /** + * Curl transport on webapi. + * + * @var WebapiDecorator + */ + private $decorator; + + /** + * @param CheckoutOnepageSuccess $checkoutOnepageSuccess + * @param WebapiDecorator $decorator + */ + public function __construct( + CheckoutOnepageSuccess $checkoutOnepageSuccess, + WebapiDecorator $decorator + ) { + $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; + $this->decorator = $decorator; + } + + /** + * Get success placed order id. + * + * @return array + */ + public function run() + { + $incrementId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); + return [ + 'entityId' => $this->getEntityId($incrementId), + 'orderId' => $incrementId + ]; + } + + /** + * Get order entity id by increment id. + * + * @param string $incrementId + * @return string + */ + private function getEntityId($incrementId) + { + $url = $_ENV['app_frontend_url'] . 'rest/V1/orders/'; + $url .= '?searchCriteria[filterGroups][0][filters][0][field]=increment_id'; + $url .= '&searchCriteria[filterGroups][0][filters][0][value]=' . $incrementId; + $this->decorator->write($url, [], WebapiDecorator::GET); + $response = json_decode($this->decorator->read(), true); + $this->decorator->close(); + return $response['items'][0]['entity_id']; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php index 2bfd346fbcaebe0545a3b65ce76af7a8bc52de25..8beada29036b8a3cf2ff367a0b30b59b78faf0e8 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php @@ -22,41 +22,44 @@ class PlaceOrderStep implements TestStepInterface * * @var CheckoutOnepage */ - protected $checkoutOnepage; + private $checkoutOnepage; /** * Assert that Order Grand Total is correct on checkout page review block. * * @var AssertGrandTotalOrderReview */ - protected $assertGrandTotalOrderReview; + private $assertGrandTotalOrderReview; /** * One page checkout success page. * * @var CheckoutOnepageSuccess */ - protected $checkoutOnepageSuccess; + private $checkoutOnepageSuccess; /** * Price array. * * @var array */ - protected $prices; + private $prices; /** + * Factory for fixtures. + * * @var FixtureFactory */ private $fixtureFactory; /** + * Array of product entities. + * * @var array */ private $products; /** - * @construct * @param CheckoutOnepage $checkoutOnepage * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview * @param CheckoutOnepageSuccess $checkoutOnepageSuccess @@ -74,10 +77,10 @@ class PlaceOrderStep implements TestStepInterface ) { $this->checkoutOnepage = $checkoutOnepage; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; - $this->prices = $prices; $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; $this->fixtureFactory = $fixtureFactory; $this->products = $products; + $this->prices = $prices; } /** @@ -91,18 +94,20 @@ class PlaceOrderStep implements TestStepInterface $this->assertGrandTotalOrderReview->processAssert($this->checkoutOnepage, $this->prices['grandTotal']); } $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); + $orderId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); $order = $this->fixtureFactory->createByCode( 'orderInjectable', [ 'data' => [ - 'entity_id' => ['products' => $this->products] + 'id' => $orderId, + 'entity_id' => ['products' => $this->products], ] ] ); return [ - 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), - 'order' => $order + 'orderId' => $orderId, + 'order' => $order, ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectPaymentMethodStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectPaymentMethodStep.php index 1f5d80bdbde49f35a62dad5dd9fbefb326107b45..5eea876f02b40c6dd93de18d9f7c378179772756 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectPaymentMethodStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectPaymentMethodStep.php @@ -7,68 +7,73 @@ namespace Magento\Checkout\Test\TestStep; use Magento\Checkout\Test\Page\CheckoutOnepage; -use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestStep\TestStepInterface; use Magento\Payment\Test\Fixture\CreditCard; /** - * Class SelectPaymentMethodStep - * Selecting payment method + * Select payment method step. */ class SelectPaymentMethodStep implements TestStepInterface { /** - * Onepage checkout page + * Onepage checkout page. * * @var CheckoutOnepage */ protected $checkoutOnepage; /** - * Payment information + * Payment information. * * @var string */ protected $payment; /** - * Credit card information + * Credit card information. * * @var string */ protected $creditCard; /** - * @constructor + * If fill credit card data should be filled on 3rd party side. + * + * @var bool + */ + private $fillCreditCardOn3rdParty; + + /** * @param CheckoutOnepage $checkoutOnepage * @param array $payment - * @param FixtureFactory $fixtureFactory - * @param string $creditCardClass - * @param array|CreditCard|null $creditCard + * @param CreditCard|null $creditCard + * @param bool $fillCreditCardOn3rdParty */ public function __construct( CheckoutOnepage $checkoutOnepage, array $payment, - FixtureFactory $fixtureFactory, - $creditCardClass = 'credit_card', - $creditCard = null + CreditCard $creditCard = null, + $fillCreditCardOn3rdParty = false ) { $this->checkoutOnepage = $checkoutOnepage; $this->payment = $payment; - if (isset($creditCard['dataset'])) { - $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]); - } + $this->creditCard = $creditCard; + $this->fillCreditCardOn3rdParty = $fillCreditCardOn3rdParty; } /** - * Run step that selecting payment method + * Run step that selecting payment method. * * @return void */ public function run() { if ($this->payment['method'] !== 'free') { - $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment, $this->creditCard); + $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod( + $this->payment, + $this->creditCard, + $this->fillCreditCardOn3rdParty + ); } } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml index d7a61b0eaaa2fece41b7d1f464f0e56bdb80d159..9f13d8dddb9a768442f7051a6e11be16f7df9233 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml @@ -7,9 +7,9 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <type name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty"> + <type name="Magento\Checkout\Test\Constraint\AssertAddedProductToCartSuccessMessage"> <arguments> - <argument name="severity" xsi:type="string">middle</argument> + <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> <type name="Magento\Checkout\Test\Constraint\AssertBillingAddressAbsentInPayment"> @@ -17,9 +17,19 @@ <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> - <type name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage"> + <type name="Magento\Checkout\Test\Constraint\AssertBillingAddressSameAsShippingCheckbox"> <arguments> - <argument name="severity" xsi:type="string">S0</argument> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertCartItemsOptions"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> <type name="Magento\Checkout\Test\Constraint\AssertCheckoutErrorMessage"> @@ -27,4 +37,124 @@ <argument name="severity" xsi:type="string">S1</argument> </arguments> </type> + <type name="Magento\Checkout\Test\Constraint\AssertCustomerIsRedirectedToCheckoutFromCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertDiscountInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertEstimateShippingAndTax"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertGrandTotalInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertGrandTotalOrderReview"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage"> + <arguments> + <argument name="severity" xsi:type="string">S0</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertPriceInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductAbsentInMiniShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductDataInMiniShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductIsNotEditable"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductOptionsAbsentInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductPresentInMiniShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductPresentInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductsAbsentInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertShippingAddressJsValidationMessagesIsAbsent"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertShippingInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertShippingTotalOrderReview"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertSubtotalInMiniShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertSubtotalInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertSubTotalOrderReview"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertTaxInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertTaxTotalOrderReview"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.php index 21f48abef963d288415d09b24d08a3fe8fd34ebe..b397b73f3a43d6c3d819d105e82efdb48568ec76 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.php @@ -27,6 +27,7 @@ class CreateTermEntityTest extends Scenario /* tags */ const MVP = 'yes'; const TEST_TYPE = 'extended_acceptance_test'; + const SEVERITY = 'S3'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml index 8b1c1929d0f9d068d5a78382beb8237e3dced4fe..8f418b92e09a5ff53c44d3d4bacd538347e2ccfa 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CheckoutAgreements\Test\TestCase\CreateTermEntityTest" summary="Create Terms And Conditions" ticketId="MAGETWO-29586"> <variation name="CreateTermEntityTestVariation1" summary="Create enabled term entity with text value"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, severity:S3</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="agreement/data/name" xsi:type="string">name%isolation%</data> @@ -26,6 +26,7 @@ <constraint name="Magento\CheckoutAgreements\Test\Constraint\AssertTermOnCheckout" /> </variation> <variation name="CreateTermEntityTestVariation2" summary="Create enabled term entity with HTML value"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="agreement/data/name" xsi:type="string">name%isolation%</data> @@ -43,6 +44,7 @@ <constraint name="Magento\CheckoutAgreements\Test\Constraint\AssertTermOnCheckout" /> </variation> <variation name="CreateTermEntityTestVariation3" summary="Create disabled term entity"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="agreement/data/name" xsi:type="string">name%isolation%</data> @@ -60,7 +62,7 @@ <constraint name="Magento\CheckoutAgreements\Test\Constraint\AssertTermAbsentOnCheckout" /> </variation> <variation name="CreateTermEntityTestVariation4" summary="Terms and conditions on multishipping" ticketId="MAGETWO-32499"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, severity:S3</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="products/1" xsi:type="string">catalogProductSimple::default</data> diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.php index 2c65150aa697371c1fe050e5e4f5f9dfbdcb25b1..0f7dd2c1bf1631557de590ee37fb804c020c5ad9 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.php @@ -26,6 +26,7 @@ class DeleteTermEntityTest extends Scenario { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S3'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml index 50e4af5a2dc36ce151de313ad22fc906921a59ac..3bfd5a63cc4e387c3ec52cba76def7601eff5cb1 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CheckoutAgreements\Test\TestCase\DeleteTermEntityTest" summary="Delete Terms And Conditions" ticketId="MAGETWO-29687"> <variation name="DeleteTermEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="agreement/dataset" xsi:type="string">term_enabled_text</data> diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/NavigateMenuTest.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/NavigateMenuTest.xml index 1387c7e1e1268085d100112302054fa9c374cde5..57580e2f10e1dc07a8034b414a28b556b6337897 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/NavigateMenuTest.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/NavigateMenuTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Backend\Test\TestCase\NavigateMenuTest"> <variation name="NavigateMenuTest17"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="menuItem" xsi:type="string">Stores > Terms and Conditions</data> <data name="pageTitle" xsi:type="string">Terms and Conditions</data> <constraint name="Magento\Backend\Test\Constraint\AssertBackendPageIsAvailable"/> diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.php index 277f38e0c7e1f1bdda9f122183415b35aa772f40..4266338ac6ef7818a5a670646be2090c64bf20a9 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.php @@ -27,6 +27,7 @@ class UpdateTermEntityTest extends Scenario { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S2'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml index 69ea6309843d1ad7452c463a7d951675c745714d..537c61d83d7b5d079a6e80a174544f5aa7cbbead 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CheckoutAgreements\Test\TestCase\UpdateTermEntityTest" summary="Update Terms And Conditions" ticketId="MAGETWO-29635"> <variation name="UpdateTermEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="agreement/dataset" xsi:type="string">term_disabled_text</data> @@ -26,6 +27,7 @@ <constraint name="Magento\CheckoutAgreements\Test\Constraint\AssertTermOnCheckout" /> </variation> <variation name="UpdateTermEntityTestVariation2"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="agreement/dataset" xsi:type="string">term_disabled_html</data> @@ -44,6 +46,7 @@ <constraint name="Magento\CheckoutAgreements\Test\Constraint\AssertTermOnCheckout" /> </variation> <variation name="UpdateTermEntityTestVariation3"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="configData" xsi:type="string">checkout_term_condition</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="agreement/dataset" xsi:type="string">term_enabled_text</data> diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/etc/di.xml index 7dc8356351f2f7228a2c4ac5ceec524380dcd5e6..66381d8985802ed12fd9a83633e2ef8c1eebc75c 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/etc/di.xml @@ -6,9 +6,39 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermRequireMessageOnMultishippingCheckout"> - <arguments> - <argument name="severity" xsi:type="string">high</argument> - </arguments> - </type> + <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermRequireMessageOnMultishippingCheckout"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermSuccessSaveMessage"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermOnCheckout"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermAbsentOnCheckout"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermSuccessDeleteMessage"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\CheckoutAgreements\Test\Constraint\AssertTermAbsentInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php index d2a999627cb95d8336314bc643e194e5fb3461c8..46cf2ceefe8ac9e830b029e0357c0735465503b2 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php @@ -6,9 +6,6 @@ namespace Magento\ConfigurableProduct\Test\Fixture\Cart; -use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; -use Magento\Mtf\Fixture\FixtureInterface; - /** * Data for verify cart item block on checkout page. * @@ -20,25 +17,27 @@ use Magento\Mtf\Fixture\FixtureInterface; class Item extends \Magento\Catalog\Test\Fixture\Cart\Item { /** - * @constructor - * @param FixtureInterface $product + * Return prepared dataset. + * + * @param null|string $key + * @return array */ - public function __construct(FixtureInterface $product) + public function getData($key = null) { - parent::__construct($product); - - /** @var ConfigurableProduct $product */ - $checkoutData = $product->getCheckoutData(); + parent::getData($key); + $productData = $this->product->getData(); + $checkoutData = $this->product->getCheckoutData(); $cartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : []; - $attributesData = $product->getConfigurableAttributesData()['attributes_data']; + $attributesData = $this->product->getConfigurableAttributesData()['attributes_data']; $checkoutConfigurableOptions = isset($checkoutData['options']['configurable_options']) ? $checkoutData['options']['configurable_options'] : []; + $attributeKey = []; foreach ($checkoutConfigurableOptions as $key => $checkoutConfigurableOption) { $attribute = $checkoutConfigurableOption['title']; $option = $checkoutConfigurableOption['value']; - + $attributeKey[] = "$attribute:$option"; $checkoutConfigurableOptions[$key] = [ 'title' => isset($attributesData[$attribute]['label']) ? $attributesData[$attribute]['label'] @@ -48,10 +47,15 @@ class Item extends \Magento\Catalog\Test\Fixture\Cart\Item : $option, ]; } + $attributeKey = implode(' ', $attributeKey); + $cartItem['sku'] = $productData['configurable_attributes_data']['matrix'][$attributeKey]['sku']; + $cartItem['name'] = $productData['name']; $cartItem['options'] = isset($cartItem['options']) ? $cartItem['options'] + $checkoutConfigurableOptions : $checkoutConfigurableOptions; $this->data = $cartItem; + + return $this->data; } } diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml index 3a099d79d370a97b9d75afb419bd36860e559a1a..77b311bd7a51f80b0347ba092dc700e467c2cf84 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml @@ -17,7 +17,6 @@ </item> </field> </dataset> - <dataset name="config_currency_symbols_usd_and_uah_rollback"> <field name="currency/options/allow" xsi:type="array"> <item name="scope" xsi:type="string">currency</item> @@ -83,7 +82,6 @@ <item name="value" xsi:type="string">CHF</item> </field> </dataset> - <dataset name="config_base_currency_ch_rollback"> <field name="currency/options/allow" xsi:type="array"> <item name="scope" xsi:type="string">currency</item> @@ -127,7 +125,6 @@ <item name="value" xsi:type="string">GBP</item> </field> </dataset> - <dataset name="config_base_currency_gb_rollback"> <field name="currency/options/allow" xsi:type="array"> <item name="scope" xsi:type="string">currency</item> @@ -150,6 +147,49 @@ </field> </dataset> + <dataset name="config_base_currency_aud"> + <field name="currency/options/allow" xsi:type="array"> + <item name="scope" xsi:type="string">currency</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="value" xsi:type="array"> + <item name="Australian Dollar" xsi:type="string">AUD</item> + </item> + </field> + <field name="currency/options/base" xsi:type="array"> + <item name="scope" xsi:type="string">currency</item> + <item name="label" xsi:type="string">Australian Dollar</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="value" xsi:type="string">AUD</item> + </field> + <field name="currency/options/default" xsi:type="array"> + <item name="scope" xsi:type="string">currency</item> + <item name="label" xsi:type="string">Australian Dollar</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="value" xsi:type="string">AUD</item> + </field> + </dataset> + <dataset name="config_base_currency_aud_rollback"> + <field name="currency/options/allow" xsi:type="array"> + <item name="scope" xsi:type="string">currency</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="value" xsi:type="array"> + <item name="US Dollar" xsi:type="string">USD</item> + </item> + </field> + <field name="currency/options/base" xsi:type="array"> + <item name="scope" xsi:type="string">currency</item> + <item name="label" xsi:type="string">US Dollar</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="value" xsi:type="string">USD</item> + </field> + <field name="currency/options/default" xsi:type="array"> + <item name="scope" xsi:type="string">currency</item> + <item name="label" xsi:type="string">US Dollar</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="value" xsi:type="string">USD</item> + </field> + </dataset> + <dataset name="config_currency_symbols_usd_and_eur"> <field name="currency/options/allow" xsi:type="array"> <item name="scope" xsi:type="string">currency</item> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml index ba85d0d13bfc68761ea562802f259dcda28ff738..2edc328b5c5df40df321e66a34fa1ee7c6d4e835 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml @@ -285,5 +285,17 @@ <item name="dataset" xsi:type="string">UK_address_default_billing, US_address_default_shipping</item> </field> </dataset> + + <dataset name="AVS_street_match_address"> + <field name="firstname" xsi:type="string">John</field> + <field name="lastname" xsi:type="string">Doe</field> + <field name="company" xsi:type="string">Magento %isolation%</field> + <field name="city" xsi:type="string">Culver City</field> + <field name="street" xsi:type="string">24285 Elm</field> + <field name="telephone" xsi:type="string">555-55-555-55</field> + <field name="country_id" xsi:type="string">United States</field> + <field name="region_id" xsi:type="string">California</field> + <field name="postcode" xsi:type="string">90230</field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/Cart/Item.php index dd388ae11d2f66990e3f2bb54e83399ec7562d5c..1d0fabeceb771ebd61d73ee16bed79ba91efcc3a 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/Cart/Item.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/Cart/Item.php @@ -6,9 +6,6 @@ namespace Magento\Downloadable\Test\Fixture\Cart; -use Magento\Downloadable\Test\Fixture\DownloadableProduct; -use Magento\Mtf\Fixture\FixtureInterface; - /** * Data for verify cart item block on checkout page. * @@ -18,17 +15,17 @@ use Magento\Mtf\Fixture\FixtureInterface; class Item extends \Magento\Catalog\Test\Fixture\Cart\Item { /** - * @constructor - * @param FixtureInterface $product + * Return prepared dataset. + * + * @param null|string $key + * @return array */ - public function __construct(FixtureInterface $product) + public function getData($key = null) { - parent::__construct($product); - - /** @var DownloadableProduct $product */ + parent::getData($key); $checkoutDownloadableOptions = []; - $checkoutData = $product->getCheckoutData(); - $downloadableOptions = $product->getDownloadableLinks(); + $checkoutData = $this->product->getCheckoutData(); + $downloadableOptions = $this->product->getDownloadableLinks(); foreach ($checkoutData['options']['links'] as $link) { $keyLink = str_replace('link_', '', $link['label']); $checkoutDownloadableOptions[] = [ @@ -38,5 +35,7 @@ class Item extends \Magento\Catalog\Test\Fixture\Cart\Item } $this->data['options'] += $checkoutDownloadableOptions; + + return $this->data; } } diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.php index e33adb68be4eb6eeb05753b072d394804acefb4a..40b622882d357a8c4770ace4b555230a134554f9 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.php @@ -29,6 +29,7 @@ class CheckoutWithGiftMessagesTest extends Scenario { /* tags */ const MVP = 'no'; + const SEVERITY = 'S2'; const TO_MAINTAIN = 'yes'; // Consider variation #2 to work correctly with Virtual products /* end tags */ diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml index 6226713f316c5f0a90f06291a3a8160a65ac912f..c4f03f0f3d317f3f8b4caa5eae6ad22ed0d475a9 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\GiftMessage\Test\TestCase\CheckoutWithGiftMessagesTest" summary="One Page Checkout with Gift Messages" ticketId="MAGETWO-28978"> <variation name="CheckoutWithGiftMessagesTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="products/1" xsi:type="string">catalogProductVirtual::default</data> <data name="customer/dataset" xsi:type="string">default</data> @@ -27,7 +28,7 @@ <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrder" /> </variation> <variation name="CheckoutWithGiftMessagesTestVariation2"> - <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="tag" xsi:type="string">severity:S2,to_maintain:yes</data> <data name="products/0" xsi:type="string">catalogProductSimple::default</data> <data name="products/1" xsi:type="string">catalogProductVirtual::default</data> <data name="customer/dataset" xsi:type="string">default</data> diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CreateGiftMessageOnBackendTest.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CreateGiftMessageOnBackendTest.php new file mode 100644 index 0000000000000000000000000000000000000000..962d94ab6d59acf09f89c4b9b21a07dcf5e2cb92 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CreateGiftMessageOnBackendTest.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\GiftMessage\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Create Product according dataset. + * 2. Enable Gift Messages (Order/Items level). + * + * Steps: + * 1. Login to backend + * 2. Go to Sales >Orders + * 3. Create new order + * 4. Fill data form dataset + * 5. Perform all asserts + * + * @group Gift_Messages + * @ZephyrId MAGETWO-29642 + */ +class CreateGiftMessageOnBackendTest extends Scenario +{ + /* tags */ + const MVP = 'no'; + const SEVERITY = 'S2'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Run CreateGiftMessageOnBackend test. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CreateGiftMessageOnBackendTest.xml b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CreateGiftMessageOnBackendTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..bc29b300b220e190e3ac6d00149520c44b493a7a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CreateGiftMessageOnBackendTest.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\GiftMessage\Test\TestCase\CreateGiftMessageOnBackendTest" summary="Create Gift Message On Backend" ticketId="MAGETWO-29642"> + <variation name="CreateGiftMessageOnBackendTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> + <data name="configData" xsi:type="string">cashondelivery, enable_gift_messages</data> + <data name="products/0" xsi:type="string">catalogProductSimple::default</data> + <data name="products/1" xsi:type="string">catalogProductVirtual::default</data> + <data name="customer/dataset" xsi:type="string">johndoe_with_addresses</data> + <data name="billingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="giftMessage/data/allow_gift_options" xsi:type="string">Yes</data> + <data name="giftMessage/data/allow_gift_options_for_items" xsi:type="string">Yes</data> + <data name="giftMessage/data/sender" xsi:type="string">John Doe</data> + <data name="giftMessage/data/recipient" xsi:type="string">Jane Doe</data> + <data name="giftMessage/data/message" xsi:type="string">text_gift_message</data> + <data name="giftMessage/data/items/datasets" xsi:type="string">default</data> + <data name="payment/method" xsi:type="string">cashondelivery</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInBackendOrder" /> + <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrderItems" /> + </variation> + <variation name="CreateGiftMessageOnBackendTestVariation2"> + <data name="tag" xsi:type="string">severity:S2</data> + <data name="configData" xsi:type="string">cashondelivery, enable_gift_messages</data> + <data name="products/0" xsi:type="string">catalogProductSimple::default</data> + <data name="products/1" xsi:type="string">catalogProductVirtual::default</data> + <data name="customer/dataset" xsi:type="string">johndoe_with_addresses</data> + <data name="billingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="giftMessage/data/allow_gift_options" xsi:type="string">Yes</data> + <data name="giftMessage/data/allow_gift_messages_for_order" xsi:type="string">Yes</data> + <data name="giftMessage/data/allow_gift_options_for_items" xsi:type="string">-</data> + <data name="giftMessage/data/sender" xsi:type="string">John Doe</data> + <data name="giftMessage/data/recipient" xsi:type="string">Jane Doe</data> + <data name="giftMessage/data/message" xsi:type="string">text_gift_message</data> + <data name="payment/method" xsi:type="string">cashondelivery</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInBackendOrder" /> + <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrder" /> + </variation> + <variation name="CreateGiftMessageOnBackendTestVariation3"> + <data name="tag" xsi:type="string">severity:S2</data> + <data name="configData" xsi:type="string">cashondelivery, enable_gift_messages</data> + <data name="products/0" xsi:type="string">catalogProductSimple::default</data> + <data name="products/1" xsi:type="string">catalogProductVirtual::default</data> + <data name="customer/dataset" xsi:type="string">johndoe_with_addresses</data> + <data name="billingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="giftMessage/data/allow_gift_options" xsi:type="string">Yes</data> + <data name="giftMessage/data/allow_gift_messages_for_order" xsi:type="string">Yes</data> + <data name="giftMessage/data/allow_gift_options_for_items" xsi:type="string">Yes</data> + <data name="giftMessage/data/sender" xsi:type="string">John Doe</data> + <data name="giftMessage/data/recipient" xsi:type="string">Jane Doe</data> + <data name="giftMessage/data/message" xsi:type="string">text_gift_message</data> + <data name="giftMessage/data/items/datasets" xsi:type="string">default</data> + <data name="payment/method" xsi:type="string">cashondelivery</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInBackendOrder" /> + <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrder" /> + <constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrderItems" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/di.xml index bda2dc3ea97b95dead3597444f2a1438b88e2da7..a7ff131c0674637fd0c5c6c333d520649834b1cd 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/di.xml @@ -8,17 +8,17 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrderItems"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> <type name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrder"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> <type name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInBackendOrder"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/Cart/Item.php index cc0cd2e9f09a49b04de46062905406bba68b7916..2aaf1253885a158f63a3a2aaf2df049d2c1ab105 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/Cart/Item.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/Cart/Item.php @@ -6,9 +6,6 @@ namespace Magento\GroupedProduct\Test\Fixture\Cart; -use Magento\GroupedProduct\Test\Fixture\GroupedProduct; -use Magento\Mtf\Fixture\FixtureInterface; - /** * Data for verify cart item block on checkout page. * @@ -18,18 +15,19 @@ use Magento\Mtf\Fixture\FixtureInterface; class Item extends \Magento\Catalog\Test\Fixture\Cart\Item { /** - * @constructor - * @param FixtureInterface $product + * Return prepared dataset. + * + * @param null|string $key + * @return array */ - public function __construct(FixtureInterface $product) + public function getData($key = null) { - /** @var GroupedProduct $product */ - $checkoutData = $product->getCheckoutData(); + $checkoutData = $this->product->getCheckoutData(); $this->data = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : []; $associatedProducts = []; $cartItem = []; - foreach ($product->getAssociated()['products'] as $key => $product) { + foreach ($this->product->getAssociated()['products'] as $key => $product) { $key = 'product_key_' . $key; $associatedProducts[$key] = $product; } @@ -51,5 +49,7 @@ class Item extends \Magento\Catalog\Test\Fixture\Cart\Item } $this->data = $cartItem; + + return $this->data; } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml index 7648899060f8f3314d1a33b26082724ae1495fa8..7f1fd69d8e784d08363b07837c35e9ec30c54ea0 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml @@ -33,6 +33,9 @@ <field name="attribute_set_id" xsi:type="array"> <item name="dataset" xsi:type="string">default</item> </field> + <field name="checkout_data" xsi:type="array"> + <item name="dataset" xsi:type="string">default</item> + </field> </dataset> <dataset name="grouped_product_out_of_stock"> diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct/CheckoutData.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct/CheckoutData.xml index e6529d1afe6778f9c97396c20186be44f110545d..e2e17977b7dd6f43f68de86f0bfc2b060693a50e 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct/CheckoutData.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct/CheckoutData.xml @@ -7,6 +7,33 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> <repository class="Magento\GroupedProduct\Test\Repository\GroupedProduct\CheckoutData"> + <dataset name="default"> + <field name="options" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="name" xsi:type="string">product_key_0</item> + <item name="qty" xsi:type="string">2</item> + </item> + <item name="1" xsi:type="array"> + <item name="name" xsi:type="string">product_key_1</item> + <item name="qty" xsi:type="string">1</item> + </item> + </field> + <field name="cartItem" xsi:type="array"> + <item name="price" xsi:type="array"> + <item name="product_key_0" xsi:type="string">100</item> + <item name="product_key_1" xsi:type="string">560</item> + </item> + <item name="qty" xsi:type="array"> + <item name="product_key_0" xsi:type="string">2</item> + <item name="product_key_1" xsi:type="string">1</item> + </item> + <item name="subtotal" xsi:type="array"> + <item name="product_key_0" xsi:type="string">200</item> + <item name="product_key_1" xsi:type="string">560</item> + </item> + </field> + </dataset> + <dataset name="grouped_three_simple_products"> <field name="options" xsi:type="array"> <item name="0" xsi:type="array"> diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml index 56431ee145d18d1fcae4df990a0a388a9e7f99f0..6594757fe15ee54f2d2b2e0f34344a3b40812a0b 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Integration\Test\TestCase\DeleteIntegrationEntityTest" summary="Delete Integration" ticketId="MAGETWO-26058"> <variation name="DeleteIntegrationEntityTestVariation1"> + <data name="integration/dataset" xsi:type="string">default</data> <constraint name="Magento\Integration\Test\Constraint\AssertIntegrationSuccessDeleteMessage" /> <constraint name="Magento\Integration\Test\Constraint\AssertIntegrationNotInGrid" /> </variation> diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Multishipping/Test/etc/di.xml index 2eac5848ace436ca634913d40d9b88cbeac67f7c..c792d650be0c1a4f8d2b094c78a8e59ee71346b4 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/etc/di.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Multishipping\Test\Constraint\AssertMultishippingOrderSuccessPlacedMessage"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S3</argument> </arguments> </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/Cc.php b/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/Cc.php deleted file mode 100644 index 3e8226d371ff4546d7b243834485d2b0dff37d8a..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/Cc.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Payment\Test\Block\Form; - -use Magento\Mtf\Block\Form; - -/** - * Form for filling credit card data. - */ -class Cc extends Form -{ - // -} diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/PaymentCc.php b/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/PaymentCc.php new file mode 100644 index 0000000000000000000000000000000000000000..474052114c4d396476f5c5083c53e42109f662e6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/PaymentCc.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Payment\Test\Block\Form; + +use Magento\Mtf\Block\Form; +use Magento\Mtf\Client\Element\SimpleElement; +use Magento\Mtf\Fixture\FixtureInterface; + +/** + * Form for filling credit card data. + */ +class PaymentCc extends Form +{ + /** + * Fill credit card form. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return $this + */ + public function fill(FixtureInterface $fixture, SimpleElement $element = null) + { + $data = $fixture->getData(); + unset($data['payment_code']); + $mapping = $this->dataMapping($data); + $this->_fill($mapping, $element); + + return $this; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/Cc.xml b/dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/PaymentCc.xml similarity index 100% rename from dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/Cc.xml rename to dev/tests/functional/tests/app/Magento/Payment/Test/Block/Form/PaymentCc.xml diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Constraint/AssertCardRequiredFields.php b/dev/tests/functional/tests/app/Magento/Payment/Test/Constraint/AssertCardRequiredFields.php index 2b1d9bdcf2df8fdb32869731b7b3af05d47bc417..c8b52ed317d0fe7454277464d638c63209556298 100644 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Constraint/AssertCardRequiredFields.php +++ b/dev/tests/functional/tests/app/Magento/Payment/Test/Constraint/AssertCardRequiredFields.php @@ -7,7 +7,7 @@ namespace Magento\Payment\Test\Constraint; use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\Payment\Test\Repository\CreditCardAdmin; +use Magento\Payment\Test\Repository\CreditCard; use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; /** @@ -30,10 +30,10 @@ class AssertCardRequiredFields extends AbstractConstraint /** * Assert required fields on credit card payment method in backend. * @param OrderCreateIndex $orderCreateIndex - * @param CreditCardAdmin $creditCard + * @param CreditCard $creditCard * @return void */ - public function processAssert(OrderCreateIndex $orderCreateIndex, CreditCardAdmin $creditCard) + public function processAssert(OrderCreateIndex $orderCreateIndex, CreditCard $creditCard) { $actualRequiredFields = $orderCreateIndex->getCreateBlock()->getBillingMethodBlock() ->getJsErrors(); diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Fixture/CreditCard.xml b/dev/tests/functional/tests/app/Magento/Payment/Test/Fixture/CreditCard.xml index 6fd5d8675b8b0f38d929d1372dbde9b3aeb601b7..2fe0da150438a784742c3930a41ad5e0362e40a1 100644 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Fixture/CreditCard.xml +++ b/dev/tests/functional/tests/app/Magento/Payment/Test/Fixture/CreditCard.xml @@ -12,6 +12,8 @@ entity_type="credit_card" repository_class="Magento\Payment\Test\Repository\CreditCard" class="Magento\Payment\Test\Fixture\CreditCard"> + <field name="payment_code" /> + <field name="cc_type" /> <field name="cc_number" /> <field name="cc_exp_month" /> <field name="cc_exp_year" /> diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Fixture/CreditCardAdmin.xml b/dev/tests/functional/tests/app/Magento/Payment/Test/Fixture/CreditCardAdmin.xml deleted file mode 100644 index 87e69cee86addd91d612fb66c594b1bfb89c2638..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Fixture/CreditCardAdmin.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="credit_card_admin" - module="Magento_Payment" - type="virtual" - entity_type="credit_card_admin" - repository_class="Magento\Payment\Test\Repository\CreditCardAdmin" - class="Magento\Payment\Test\Fixture\CreditCardAdmin"> - <field name="cc_type" /> - <field name="cc_number" /> - <field name="cc_exp_month" /> - <field name="cc_exp_year" /> - <field name="cc_cid" /> - </fixture> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml b/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml index 8e742ab30ba960dd022870fea86e08c74d71c3fd..80c337d0a8578fb9115ff6382fabba5f6b1b844b 100644 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml +++ b/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml @@ -14,6 +14,14 @@ <field name="cc_cid" xsi:type="string">123</field> </dataset> + <dataset name="visa_default_admin"> + <field name="cc_type" xsi:type="string">Visa</field> + <field name="cc_number" xsi:type="string">4111111111111111</field> + <field name="cc_exp_month" xsi:type="string">01 - January</field> + <field name="cc_exp_year" xsi:type="string">2020</field> + <field name="cc_cid" xsi:type="string">123</field> + </dataset> + <dataset name="visa_alt"> <field name="cc_number" xsi:type="string">4012888888881881</field> <field name="cc_exp_month" xsi:type="string">02 - February</field> @@ -34,5 +42,13 @@ <field name="cc_exp_year" xsi:type="string">2020</field> <field name="cc_cid" xsi:type="string">123</field> </dataset> + + <dataset name="visa_empty"> + <field name="cc_type" xsi:type="string" /> + <field name="cc_number" xsi:type="string" /> + <field name="cc_exp_month" xsi:type="string" /> + <field name="cc_exp_year" xsi:type="string" /> + <field name="cc_cid" xsi:type="string" /> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCardAdmin.xml b/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCardAdmin.xml deleted file mode 100644 index 371c8f350c6af028ddc544c23142f2886d699dbd..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCardAdmin.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" ?> -<!-- -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Payment\Test\Repository\CreditCardAdmin"> - <dataset name="visa_default"> - <field name="cc_type" xsi:type="string">Visa</field> - <field name="cc_number" xsi:type="string">4111111111111111</field> - <field name="cc_exp_month" xsi:type="string">01 - January</field> - <field name="cc_exp_year" xsi:type="string">2020</field> - <field name="cc_cid" xsi:type="string">123</field> - </dataset> - - <dataset name="visa_direct"> - <field name="cc_type" xsi:type="string">Visa</field> - <field name="cc_number" xsi:type="string">4617747819866651</field> - <field name="cc_exp_month" xsi:type="string">01 - January</field> - <field name="cc_exp_year" xsi:type="string">2020</field> - <field name="cc_cid" xsi:type="string">123</field> - </dataset> - <dataset name="visa_empty"> - <field name="cc_type" xsi:type="string">Please Select</field> - <field name="cc_number" xsi:type="string" /> - <field name="cc_exp_month" xsi:type="string">Month</field> - <field name="cc_cid" xsi:type="string" /> - </dataset> - </repository> -</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/HostedPro/Cc.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/HostedPro/Cc.php new file mode 100644 index 0000000000000000000000000000000000000000..53fd258b84cbb0ca65b588672eaeeaaf21f43041 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/HostedPro/Cc.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\Block\Form\HostedPro; + +use Magento\Payment\Test\Block\Form\PaymentCc as CreditCard; + +/** + * Form for filling credit card data for Hosted Pro payment method. + */ +class Cc extends CreditCard +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/HostedPro/Cc.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/HostedPro/Cc.xml new file mode 100644 index 0000000000000000000000000000000000000000..b6a0945a693a954bd2602031ebf0ae4f94b81beb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/HostedPro/Cc.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="0"> + <fields> + <cc_type> + <input>select</input> + <selector>#credit_card_type</selector> + </cc_type> + <cc_number> + <selector>#credit_card_number</selector> + </cc_number> + <cc_exp_month> + <selector>[name=expiryMonth]</selector> + </cc_exp_month> + <cc_exp_year> + <selector>[name=expiryYear]</selector> + </cc_exp_year> + <cc_cid> + <selector>[name=cvv2]</selector> + </cc_cid> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PayflowLink/Cc.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PayflowLink/Cc.php new file mode 100644 index 0000000000000000000000000000000000000000..3f369efc7e829c2e427e883320183a51565006d4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PayflowLink/Cc.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\Block\Form\PayflowLink; + +use Magento\Payment\Test\Block\Form\PaymentCc as CreditCard; + +/** + * Form for filling credit card data for Payflow Link payment method. + */ +class Cc extends CreditCard +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PayflowLink/Cc.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PayflowLink/Cc.xml new file mode 100644 index 0000000000000000000000000000000000000000..1eaabeede0d49c5dc1387e7e27c560510e6db0a3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PayflowLink/Cc.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" ?> +<!-- +/** +* Copyright © 2016 Magento. All rights reserved. +* See COPYING.txt for license details. +*/ +--> +<mapping strict="0"> + <fields> + <cc_number> + <selector>#cc_number</selector> + </cc_number> + <cc_exp_month> + <selector>#expdate_month</selector> + </cc_exp_month> + <cc_exp_year> + <selector>#expdate_year</selector> + </cc_exp_year> + <cc_cid> + <selector>#cvv2_number</selector> + </cc_cid> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PaymentsAdvanced/Cc.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PaymentsAdvanced/Cc.php new file mode 100644 index 0000000000000000000000000000000000000000..a990a41cd69afa9e9969ed6668e17125647aee77 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PaymentsAdvanced/Cc.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\Block\Form\PaymentsAdvanced; + +use Magento\Payment\Test\Block\Form\PaymentCc as CreditCard; + +/** + * Form for filling credit card data for Payments Advanced payment method. + */ +class Cc extends CreditCard +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PaymentsAdvanced/Cc.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PaymentsAdvanced/Cc.xml new file mode 100644 index 0000000000000000000000000000000000000000..1eaabeede0d49c5dc1387e7e27c560510e6db0a3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Form/PaymentsAdvanced/Cc.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" ?> +<!-- +/** +* Copyright © 2016 Magento. All rights reserved. +* See COPYING.txt for license details. +*/ +--> +<mapping strict="0"> + <fields> + <cc_number> + <selector>#cc_number</selector> + </cc_number> + <cc_exp_month> + <selector>#expdate_month</selector> + </cc_exp_month> + <cc_exp_year> + <selector>#expdate_year</selector> + </cc_exp_year> + <cc_cid> + <selector>#cvv2_number</selector> + </cc_cid> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/HostedPro.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/HostedPro.php new file mode 100644 index 0000000000000000000000000000000000000000..f7ee9fc20947e5c4a7bf0acc5bf2ff829aad87c0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/HostedPro.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\Block\Onepage\Payment; + +/** + * Hosted Pro credit card block. + */ +class HostedPro extends PaypalIframe +{ + /** + * Block for filling credit card data for Hosted Pro payment method. + * + * @var string + */ + protected $formBlockCc = \Magento\Paypal\Test\Block\Form\HostedPro\Cc::class; +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PayflowLink.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PayflowLink.php new file mode 100644 index 0000000000000000000000000000000000000000..c6b8d37dc3faa1634450e9152636171e44ec9139 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PayflowLink.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\Block\Onepage\Payment; + +/** + * Payflow Link credit card block. + */ +class PayflowLink extends PaypalIframe +{ + /** + * Block for filling credit card data for Payflow Link payment method. + * + * @var string + */ + protected $formBlockCc = \Magento\Paypal\Test\Block\Form\PayflowLink\Cc::class; +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PaymentsAdvanced.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PaymentsAdvanced.php new file mode 100644 index 0000000000000000000000000000000000000000..bb80ab1ccfc3be3892813f744da23f56a0f11ac3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PaymentsAdvanced.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\Block\Onepage\Payment; + +/** + * Payments Advanced credit card block. + */ +class PaymentsAdvanced extends PaypalIframe +{ + /** + * Block for filling credit card data for Payments Advanced payment method. + * + * @var string + */ + protected $formBlockCc = \Magento\Paypal\Test\Block\Form\PaymentsAdvanced\Cc::class; +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PaypalIframe.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PaypalIframe.php new file mode 100644 index 0000000000000000000000000000000000000000..574dc256589b6afec1ea5d4f2252bf390b31a7e5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Onepage/Payment/PaypalIframe.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\Block\Onepage\Payment; + +use Magento\Checkout\Test\Block\Onepage\Payment\Method; +use Magento\Mtf\Client\ElementInterface; +use Magento\Mtf\Fixture\FixtureInterface; + +/** + * Paypal Iframe block. + */ +class PaypalIframe extends Method +{ + /** + * 'Pay Now' button selector. + * + * @var string + */ + private $payNowButton = '#btn_pay_cc'; + + /** + * PayPal iframe selector. + * + * @var string + */ + private $paypalIframe = '.paypal.iframe'; + + /** + * Credit card form selector. + * + * @var string + */ + private $creditCardForm = '#formCreditCard'; + + /** + * Error message selector. + * + * @var string + */ + private $errorMessage = '#messageBox'; + + /** + * Block for filling credit card data for payment method. + * + * @var string + */ + protected $formBlockCc; + + /** + * Fill credit card data in PayPal iframe form. + * + * @param FixtureInterface $creditCard + * @return void + */ + public function fillPaymentData(FixtureInterface $creditCard) + { + $iframeRootElement = $this->switchToPaypalFrame(); + $formBlock = $this->blockFactory->create( + $this->formBlockCc, + ['element' => $this->_rootElement->find($this->creditCardForm)] + ); + $formBlock->fill($creditCard, $iframeRootElement); + $iframeRootElement->find($this->payNowButton)->click(); + $this->browser->switchToFrame(); + } + + /** + * Check if error message is appeared. + * + * @return bool + */ + public function isErrorMessageVisible() + { + $isErrorMessageVisible = false; + if ($this->_rootElement->find($this->paypalIframe)->isPresent()) { + $iframeRootElement = $this->switchToPaypalFrame(); + $isErrorMessageVisible = $iframeRootElement->find($this->errorMessage)->isVisible(); + $this->browser->switchToFrame(); + } + return $isErrorMessageVisible; + } + + /** + * Change the focus to a PayPal frame. + * + * @return ElementInterface + */ + private function switchToPaypalFrame() + { + $iframeLocator = $this->browser->find($this->paypalIframe)->getLocator(); + $this->browser->switchToFrame($iframeLocator); + return $this->browser->find('body'); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Page/CheckoutOnepage.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Page/CheckoutOnepage.xml new file mode 100644 index 0000000000000000000000000000000000000000..da37a44f9bf3db04ff42c1a14a0f36e0e499b9c7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Page/CheckoutOnepage.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="CheckoutOnepage" mca="checkout" module="Magento_Checkout"> + <block name="payflowLinkBlock" class="Magento\Paypal\Test\Block\Onepage\Payment\PayflowLink" locator="#checkout-step-payment" strategy="css selector" /> + <block name="paymentsAdvancedBlock" class="Magento\Paypal\Test\Block\Onepage\Payment\PaymentsAdvanced" locator="#checkout-step-payment" strategy="css selector" /> + <block name="hostedProBlock" class="Magento\Paypal\Test\Block\Onepage\Payment\HostedPro" locator="#checkout-step-payment" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml index 0706f45beeb4bdfa39bfd65f6a76094ef77574e7..1669352dc026ef02c295fce1153f63e3beabf225 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml @@ -7,6 +7,23 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> <repository class="Magento\Config\Test\Repository\ConfigData"> + <dataset name="merchant_country_gb"> + <field name="paypal/general/merchant_country" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">United Kingdom</item> + <item name="value" xsi:type="string">GB</item> + </field> + </dataset> + <dataset name="merchant_country_gb_rollback"> + <field name="paypal/general/merchant_country" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">United States</item> + <item name="value" xsi:type="string">US</item> + </field> + </dataset> + <dataset name="paypal_direct"> <field name="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/business_account" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> @@ -64,32 +81,32 @@ <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/business_account" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> - <item name="value" xsi:type="string">PAYPAL_BUSINESS_ACCOUNT</item> + <item name="label" xsi:type="string">Email Associated with PayPal Merchant Account (Optional)</item> + <item name="value" xsi:type="string">%payflow_pro_business_account%</item> </field> <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/partner" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWPRO_PARTNER</item> + <item name="label" xsi:type="string">Partner</item> + <item name="value" xsi:type="string">%payflow_pro_partner%</item> </field> <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/user" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWPRO_USER</item> + <item name="label" xsi:type="string">User</item> + <item name="value" xsi:type="string">%payflow_pro_user%</item> </field> <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/pwd" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWPRO_PWD</item> + <item name="label" xsi:type="string">Password</item> + <item name="value" xsi:type="string">%payflow_pro_pwd%</item> </field> <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/vendor" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWPRO_VENDOR</item> + <item name="label" xsi:type="string">Vendor</item> + <item name="value" xsi:type="string">%payflow_pro_vendor%</item> </field> <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/sandbox_flag" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> @@ -124,9 +141,133 @@ </dataset> <dataset name="payflowpro_rollback"> <field name="payment/payflowpro/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">No</item> + <item name="value" xsi:type="number">0</item> + </field> + </dataset> + + <dataset name="payflowpro_fraud_filters_enabled"> + <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/business_account" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Email Associated with PayPal Merchant Account (Optional)</item> + <item name="value" xsi:type="string">%payflow_pro_fraud_protection_enabled_business_account%</item> + </field> + <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/partner" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Partner</item> + <item name="value" xsi:type="string">%payflow_pro_fraud_protection_enabled_partner%</item> + </field> + <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/user" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">User</item> + <item name="value" xsi:type="string">%payflow_pro_fraud_protection_enabled_user%</item> + </field> + <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/pwd" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Password</item> + <item name="value" xsi:type="string">%payflow_pro_fraud_protection_enabled_pwd%</item> + </field> + <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/vendor" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Vendor</item> + <item name="value" xsi:type="string">%payflow_pro_fraud_protection_enabled_vendor%</item> + </field> + <field name="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/sandbox_flag" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string"/> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/payflowpro/debug" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/payflowpro/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/payflow_express/debug" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/payflow_express/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + </dataset> + <dataset name="payflowpro_fraud_filters_enabled_rollback"> + <field name="payment/payflowpro/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">No</item> + <item name="value" xsi:type="number">0</item> + </field> + </dataset> + + <dataset name="hosted_pro"> + <field name="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/business_account" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="string">HOSTED_PRO_BUSINESS_ACCOUNT</item> + </field> + <field name="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/api_username" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string"/> + <item name="value" xsi:type="string">HOSTED_PRO_API_USERNAME</item> + </field> + <field name="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/api_password" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string"/> + <item name="value" xsi:type="string">HOSTED_PRO_API_PASSWORD</item> + </field> + <field name="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/api_signature" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string"/> + <item name="value" xsi:type="string">HOSTED_PRO_API_SIGNATURE</item> + </field> + <field name="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/sandbox_flag" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/hosted_pro/debug" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/hosted_pro/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + </dataset> + <dataset name="hosted_pro_rollback"> + <field name="payment/hosted_pro/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">No</item> <item name="value" xsi:type="number">0</item> </field> </dataset> @@ -184,41 +325,100 @@ </field> </dataset> + <dataset name="payments_advanced"> + <field name="payment/paypal_group_all_in_one/payflow_advanced/required_settings/payments_advanced/business_account" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Email Associated with PayPal Merchant Account</item> + <item name="value" xsi:type="string">%payflow_link_business_account_email%</item> + </field> + <field name="payment/paypal_group_all_in_one/payflow_advanced/required_settings/payments_advanced/partner" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Partner</item> + <item name="value" xsi:type="string">%payflow_link_partner%</item> + </field> + <field name="payment/paypal_group_all_in_one/payflow_advanced/required_settings/payments_advanced/user" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">User</item> + <item name="value" xsi:type="string">%payflow_link_user%</item> + </field> + <field name="payment/paypal_group_all_in_one/payflow_advanced/required_settings/payments_advanced/pwd" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Password</item> + <item name="value" xsi:type="string">%payflow_link_password%</item> + </field> + <field name="payment/paypal_group_all_in_one/payflow_advanced/required_settings/payments_advanced/vendor" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Vendor</item> + <item name="value" xsi:type="string">%payflow_link_vendor%</item> + </field> + <field name="payment/paypal_group_all_in_one/payflow_advanced/required_settings/payments_advanced/sandbox_flag" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/payflow_advanced/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + </dataset> + <dataset name="payments_advanced_rollback"> + <field name="payment/payflow_advanced/active" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">No</item> + <item name="value" xsi:type="number">0</item> + </field> + </dataset> + <dataset name="payflowlink"> <field name="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/business_account" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> - <item name="value" xsi:type="string">PAYPAL_BUSINESS_ACCOUNT</item> + <item name="label" xsi:type="string">Email Associated with PayPal Merchant Account</item> + <item name="value" xsi:type="string">%payflow_link_business_account_email%</item> </field> <field name="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/partner" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWLINK_PARTNER</item> + <item name="label" xsi:type="string">Partner</item> + <item name="value" xsi:type="string">%payflow_link_partner%</item> </field> <field name="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/user" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWLINK_USER</item> + <item name="label" xsi:type="string">User</item> + <item name="value" xsi:type="string">%payflow_link_user%</item> </field> <field name="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/pwd" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWLINK_PWD</item> + <item name="label" xsi:type="string">Password</item> + <item name="value" xsi:type="string">%payflow_link_password%</item> </field> <field name="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/vendor" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYMENT_PAYFLOWLINK_VENDOR</item> + <item name="label" xsi:type="string">Vendor</item> + <item name="value" xsi:type="string">%payflow_link_vendor%</item> </field> <field name="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/payflow_link_payflow_link/sandbox_flag" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + <field name="payment/paypal_payment_gateways/payflow_link_us/payflow_link_required/enable_payflow_link" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> <item name="value" xsi:type="number">1</item> </field> <field name="payment/payflowlink/debug" xsi:type="array"> @@ -250,7 +450,7 @@ <field name="payment/payflowlink/active" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> + <item name="label" xsi:type="string">No</item> <item name="value" xsi:type="number">0</item> </field> </dataset> diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/CreditCard.xml similarity index 60% rename from dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml rename to dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/CreditCard.xml index c6b8eab58205e649e87e0acb760339bb9aafc273..9383dcd3faf4b40b23e665c4fb243cd45954e215 100644 --- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/CreditCard.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/CreditCard.xml @@ -6,10 +6,11 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> - <repository class="Magento\Authorizenet\Test\Repository\CreditCard"> - <dataset name="visa_authorizenet"> - <field name="cc_number" xsi:type="string">4111111111111111</field> - <field name="cc_exp_month" xsi:type="string">01 - January</field> + <repository class="Magento\Payment\Test\Repository\CreditCard"> + <dataset name="visa_hosted_pro"> + <field name="cc_type" xsi:type="string">V</field> + <field name="cc_number" xsi:type="string">4032034402702800</field> + <field name="cc_exp_month" xsi:type="string">01</field> <field name="cc_exp_year" xsi:type="string">2020</field> <field name="cc_cid" xsi:type="string">123</field> </dataset> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseSalesWithHostedProTest.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseSalesWithHostedProTest.php new file mode 100644 index 0000000000000000000000000000000000000000..11acf819c992692a856cf93c679c79a5c7a1aa8b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseSalesWithHostedProTest.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Order is placed via WPPHS. + * + * Steps: + * 1. Log in to Admin. + * 2. Go to Sales > Orders page. + * 3. Open order. + * 4. Click 'Ship' button and submit shipment. + * 5. Click 'Invoice' button. + * 6. Select Amount=Capture Online. + * 7. Click 'Submit Invoice' button. + * 11. Perform assertions. + * + * @group Paypal + * @ZephyrId MAGETWO-13016 + */ +class CloseSalesWithHostedProTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const TEST_TYPE = '3rd_party_test'; + /* end tags */ + + /** + * Complete order paid PayPal Payments Pro Hosted Solution. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseSalesWithHostedProTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseSalesWithHostedProTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..a7e058b4fba445c74febc19a71f7962c3b4af3b6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseSalesWithHostedProTest.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Paypal\Test\TestCase\CloseSalesWithHostedProTest" summary="Complete order paid with PayPal Payments Pro Hosted Solution"> + <variation name="CloseSalesWithHostedProVariation1" summary="Complete order paid with PayPal Payments Pro Hosted Solution" ticketId="MAGETWO-13016"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="products/1" xsi:type="string">configurableProduct::with_one_option</data> + <data name="products/2" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data> + <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">hosted_pro</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">145.98</item> + </data> + <data name="capturedPrices" xsi:type="array"> + <item name="0" xsi:type="string">145.98</item> + </data> + <data name="creditCardClass" xsi:type="string">credit_card_hostedpro</data> + <data name="creditCard/dataset" xsi:type="string">visa_hosted_pro</data> + <data name="isVaultPresent" xsi:type="boolean">false</data> + <data name="status" xsi:type="string">Complete</data> + <data name="configData" xsi:type="string">merchant_country_gb, hosted_pro, config_base_currency_gb</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + <constraint name="Magento\Sales\Test\Constraint\AssertCaptureInCommentsHistory" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreatePayFlowOrderBackendNegativeTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreatePayFlowOrderBackendNegativeTest.xml index 4ad751de68a71f0330aa547bf74481c3e306f379..ea4dc7b7231466e1473fe4690d73a5ffe3af376b 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreatePayFlowOrderBackendNegativeTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreatePayFlowOrderBackendNegativeTest.xml @@ -19,7 +19,6 @@ <item name="grandTotal" xsi:type="string">15.00</item> </data> <data name="payment/method" xsi:type="string">payflowpro</data> - <data name="creditCardClass" xsi:type="string">credit_card_admin</data> <data name="creditCard/dataset" xsi:type="string">visa_empty</data> <data name="creditCardSave" xsi:type="string">Yes</data> <data name="configData" xsi:type="string">payflowpro, payflowpro_use_vault</data> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateVaultOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateVaultOrderBackendTest.xml index ca26ad42a020c80ab0540c21a2928b8a1874cae7..53e9c7b83900ac1c9422d0ed52ce761b05e24dc0 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateVaultOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateVaultOrderBackendTest.xml @@ -20,8 +20,7 @@ </data> <data name="payment/method" xsi:type="string">payflowpro</data> <data name="vault/method" xsi:type="string">payflowpro_cc_vault</data> - <data name="creditCardClass" xsi:type="string">credit_card_admin</data> - <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCard/dataset" xsi:type="string">visa_default_admin</data> <data name="creditCardSave" xsi:type="string">Yes</data> <data name="configData" xsi:type="string">payflowpro, payflowpro_use_vault</data> <data name="status" xsi:type="string">Processing</data> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutHostedProTest.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutHostedProTest.php new file mode 100644 index 0000000000000000000000000000000000000000..12cedd4ffa458d3418f6834ea330a12c9b0c3c6b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutHostedProTest.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Configure shipping method. + * 2. Configure payment method. + * 3. Create products. + * 4. Create sales rule according to dataset. + * + * Steps: + * 1. Go to Storefront. + * 2. Add products to the cart. + * 3. Click the 'Go to Checkout' button. + * 4. Fill shipping information. + * 5. Select shipping method. + * 6. Click 'Next' button. + * 7. Select Hosted Pro method. + * 8. Click 'Continue' button. + * 9. Specify credit card data in Paypal iframe. + * 10. Click 'Pay Now' button. + * 11. Perform assertions. + * + * @group Paypal + * @ZephyrId MAGETWO-12971 + */ +class OnePageCheckoutHostedProTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const TEST_TYPE = '3rd_party_test'; + const SEVERITY = 'S0'; + /* end tags */ + + /** + * Place order using PayPal Payments Pro Hosted Solution. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutHostedProTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutHostedProTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..6583aa9cc873c9e3c8fc17255127a1fc62680cb5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutHostedProTest.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Paypal\Test\TestCase\OnePageCheckoutHostedProTest" summary="Guest Checkout using PayPal Payments Pro Hosted Solution and Offline Shipping Method"> + <variation name="OnePageCheckoutHostedProVariation1" summary="Guest Checkout using PayPal Payments Pro Hosted Solution and Offline Shipping Method" ticketId="MAGETWO-12971"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="products/1" xsi:type="string">configurableProduct::with_one_option</data> + <data name="products/2" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data> + <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">hosted_pro</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">145.98</item> + </data> + <data name="creditCardClass" xsi:type="string">credit_card_hostedpro</data> + <data name="creditCard/dataset" xsi:type="string">visa_hosted_pro</data> + <data name="isVaultPresent" xsi:type="boolean">false</data> + <data name="configData" xsi:type="string">merchant_country_gb, hosted_pro, config_base_currency_gb</data> + <data name="status" xsi:type="string">Processing</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPayflowLinkTest.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPayflowLinkTest.php new file mode 100644 index 0000000000000000000000000000000000000000..726d6833660be0cfd2c838985724a88f680cea44 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPayflowLinkTest.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Configure shipping method. + * 2. Configure payment method. + * 3. Create products. + * 4. Create tax rule according to dataset. + * + * Steps: + * 1. Go to Storefront. + * 2. Add products to the cart. + * 3. Click the 'Go to Checkout' button. + * 4. Fill shipping information. + * 5. Select shipping method. + * 6. Click 'Next' button. + * 7. Select 'Credit Card' method. + * 8. Click 'Continue' button. + * 9. Specify credit card data in Paypal iframe. + * 10. Click 'Pay Now' button. + * 11. Perform assertions. + * + * @group Paypal + * @ZephyrId MAGETWO-12974 + */ +class OnePageCheckoutPayflowLinkTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const TEST_TYPE = '3rd_party_test'; + const SEVERITY = 'S0'; + /* end tags */ + + /** + * Place order using PayPal Payflow Link Solution. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPayflowLinkTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPayflowLinkTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..b23a1c6ae9d79e20bee3af1fcd81f2e116fd6d8e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPayflowLinkTest.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Paypal\Test\TestCase\OnePageCheckoutPayflowLinkTest" summary="Guest Checkout using PayPal Payflow Link and Flat Rate"> + <variation name="OnePageCheckoutPayflowLinkVariation1" summary="Guest Checkout using PayPal Payflow Link and Flat Rate" ticketId="MAGETWO-12974"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="products/1" xsi:type="string">configurableProduct::with_one_option</data> + <data name="products/2" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data> + <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflow_link</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">145.98</item> + </data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="isVaultPresent" xsi:type="boolean">false</data> + <data name="configData" xsi:type="string">payflowlink</data> + <data name="status" xsi:type="string">Processing</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPaymentsAdvancedTest.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPaymentsAdvancedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..789b5ddd27faaf2723e0feb909e1561e164df56d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPaymentsAdvancedTest.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Configure shipping method. + * 2. Configure payment method. + * 3. Create products. + * 4. Create tax rule according to dataset. + * + * Steps: + * 1. Go to Storefront. + * 2. Add products to the cart. + * 3. Click the 'Go to Checkout' button. + * 4. Fill shipping information. + * 5. Select shipping method. + * 6. Click 'Next' button. + * 7. Select 'Credit Card' method. + * 8. Click 'Continue' button. + * 9. Specify credit card data in Paypal iframe. + * 10. Click 'Pay Now' button. + * 11. Perform assertions. + * + * @group Paypal + * @ZephyrId MAGETWO-12991 + */ +class OnePageCheckoutPaymentsAdvancedTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const TEST_TYPE = '3rd_party_test'; + const SEVERITY = 'S0'; + /* end tags */ + + /** + * Place order using PayPal Payments Advanced Solution. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPaymentsAdvancedTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPaymentsAdvancedTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..279a47689548ba0e3a08ba0d8070490bb417e09a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutPaymentsAdvancedTest.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Paypal\Test\TestCase\OnePageCheckoutPaymentsAdvancedTest" summary="Guest Checkout using PayPal Payments Advanced and Flat Rate"> + <variation name="OnePageCheckoutPaymentsAdvancedVariation1" summary="Guest Checkout using PayPal Payments Advanced and Flat Rate" ticketId="MAGETWO-12991"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="products/1" xsi:type="string">configurableProduct::with_one_option</data> + <data name="products/2" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data> + <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflow_advanced</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">145.98</item> + </data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="isVaultPresent" xsi:type="boolean">false</data> + <data name="configData" xsi:type="string">payments_advanced</data> + <data name="status" xsi:type="string">Processing</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> + </variation> + </testCase> +</config> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml index 11f9d9d5270e679df9cd5237b4a51139cb51475e..655b2f5f9d3fb83eaca544d74db4e9adf0732bbe 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml @@ -19,7 +19,6 @@ <data name="prices" xsi:type="array"> <item name="grandTotal" xsi:type="string">15.83</item> </data> - <data name="creditCardClass" xsi:type="string">credit_card</data> <data name="creditCard/dataset" xsi:type="string">visa_default</data> <data name="isVaultPresent" xsi:type="boolean">false</data> <data name="configData" xsi:type="string">payflowpro</data> @@ -28,5 +27,58 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> </variation> + <variation name="OnePageCheckoutPayflowProWithInternationalAVSFilter" summary="Place order via Payflow Pro with fraud filters triggering" ticketId="MAGETWO-37476"> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="billingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="shippingAddress/dataset" xsi:type="string">UK_address_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">15.00</item> + </data> + <data name="creditCardClass" xsi:type="string">credit_card</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="isVaultPresent" xsi:type="boolean">false</data> + <data name="configData" xsi:type="string">payflowpro_fraud_filters_enabled</data> + <data name="paymentInfo" xsi:type="array"> + <item name="Triggered Fraud Filters" xsi:type="string">Under review by Fraud Service</item> + <item name="International AVS response" xsi:type="string">#N: No Details matched</item> + </data> + <data name="status" xsi:type="string">Processing</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderPaymentInformation" /> + </variation> + <variation name="OnePageCheckoutPayflowProWithAVSStreetMatches" summary="Place Order via Payflow Pro with success AVS Street verification" ticketId="MAGETWO-37479"> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">AVS_street_match_address</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">15.00</item> + </data> + <data name="creditCardClass" xsi:type="string">credit_card</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="isVaultPresent" xsi:type="boolean">false</data> + <data name="configData" xsi:type="string">payflowpro_fraud_filters_enabled</data> + <data name="paymentInfo" xsi:type="array"> + <item name="AVS Street Match" xsi:type="string">#Y: Yes. Matched Address and five-didgit ZIP</item> + </data> + <data name="status" xsi:type="string">Processing</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderPaymentInformation" /> + </variation> </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ReorderUsingVaultTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ReorderUsingVaultTest.xml index ad937cf472de7145429b16983288df69bb851134..f5dd4b9604e0a1843c67cc470d607aaf93684eec 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ReorderUsingVaultTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ReorderUsingVaultTest.xml @@ -20,7 +20,6 @@ </data> <data name="payment/method" xsi:type="string">payflowpro</data> <data name="vault/method" xsi:type="string">payflowpro_cc_vault</data> - <data name="creditCardClass" xsi:type="string">credit_card</data> <data name="creditCard/dataset" xsi:type="string">visa_default</data> <data name="configData" xsi:type="string">payflowpro, payflowpro_use_vault</data> <data name="status" xsi:type="string">Processing</data> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml index 92b4be03b5937ffa318f9d3cd05f6e6d2290f6bc..b81d36ad33038279d0563ca704098b759e93773e 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml @@ -16,7 +16,6 @@ <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="payment/method" xsi:type="string">payflowpro</data> <data name="vault/method" xsi:type="string">payflowpro_cc_vault</data> - <data name="creditCardClass" xsi:type="string">credit_card</data> <data name="creditCard/dataset" xsi:type="string">visa_default</data> <data name="creditCardSave" xsi:type="string">Yes</data> <data name="configData" xsi:type="string">payflowpro, payflowpro_use_vault</data> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/GetPlacedOrderIdStep.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/GetPlacedOrderIdStep.php deleted file mode 100644 index bb1e1416dc9339498c35fda85d1703b5fe62d69b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/GetPlacedOrderIdStep.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Paypal\Test\TestStep; - -use Magento\Mtf\TestStep\TestStepInterface; -use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; - -/** - * Get success placed order id. - */ -class GetPlacedOrderIdStep implements TestStepInterface -{ - /** - * Order success page. - * - * @var CheckoutOnepageSuccess - */ - protected $checkoutOnepageSuccess; - - /** - * @constructor - * @param CheckoutOnepageSuccess $checkoutOnepageSuccess - */ - public function __construct(CheckoutOnepageSuccess $checkoutOnepageSuccess) - { - $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; - } - - /** - * Get success placed order id. - * - * @return array - */ - public function run() - { - return [ - 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), - ]; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithHostedProStep.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithHostedProStep.php new file mode 100644 index 0000000000000000000000000000000000000000..cf602190a6286d30a860633fc3fb61fca718fe3a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithHostedProStep.php @@ -0,0 +1,104 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\TestStep; + +use Magento\Checkout\Test\Page\CheckoutOnepage; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Payment\Test\Fixture\CreditCard; +use Magento\Sales\Test\Fixture\OrderInjectable; + +/** + * Place order using PayPal Payments Pro Hosted Solution during one page checkout. + */ +class PlaceOrderWithHostedProStep implements TestStepInterface +{ + /** + * Onepage checkout page. + * + * @var CheckoutOnepage + */ + private $checkoutOnepage; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * Products fixtures. + * + * @var FixtureInterface[] + */ + private $products; + + /** + * Payment information. + * + * @var string + */ + private $payment; + + /** + * Credit card information. + * + * @var string + */ + private $creditCard; + + /** + * @param CheckoutOnepage $checkoutOnepage + * @param FixtureFactory $fixtureFactory + * @param CreditCard $creditCard + * @param array $payment + * @param array $products + */ + public function __construct( + CheckoutOnepage $checkoutOnepage, + FixtureFactory $fixtureFactory, + CreditCard $creditCard, + array $payment, + array $products + ) { + $this->checkoutOnepage = $checkoutOnepage; + $this->fixtureFactory = $fixtureFactory; + $this->creditCard = $creditCard; + $this->payment = $payment; + $this->products = $products; + } + + /** + * Place order with Hosted Pro. + * + * @return array + */ + public function run() + { + $attempts = 1; + $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment); + $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); + $this->checkoutOnepage->getHostedProBlock()->fillPaymentData($this->creditCard); + // As Paypal Sandbox is not stable there are three attempts given to place order + while ($this->checkoutOnepage->getHostedProBlock()->isErrorMessageVisible() && $attempts <= 3) { + $this->checkoutOnepage->getHostedProBlock()->fillPaymentData($this->creditCard); + $attempts++; + } + /** @var OrderInjectable $order */ + $order = $this->fixtureFactory->createByCode( + 'orderInjectable', + [ + 'data' => [ + 'entity_id' => ['products' => $this->products] + ] + ] + ); + return ['order' => $order]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithPayflowLinkStep.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithPayflowLinkStep.php new file mode 100644 index 0000000000000000000000000000000000000000..926dabe9722b65e8c906cb18fb1a1e9df462dc4a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithPayflowLinkStep.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\TestStep; + +use Magento\Checkout\Test\Page\CheckoutOnepage; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Payment\Test\Fixture\CreditCard; +use Magento\Sales\Test\Fixture\OrderInjectable; + +/** + * Place order using PayPal Payflow Link Solution during one page checkout. + */ +class PlaceOrderWithPayflowLinkStep implements TestStepInterface +{ + /** + * Onepage checkout page. + * + * @var CheckoutOnepage + */ + private $checkoutOnepage; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * Products fixtures. + * + * @var array + */ + private $products; + + /** + * Payment information. + * + * @var array + */ + private $payment; + + /** + * Credit card information. + * + * @var CreditCard + */ + private $creditCard; + + /** + * @param CheckoutOnepage $checkoutOnepage + * @param FixtureFactory $fixtureFactory + * @param CreditCard $creditCard + * @param array $payment + * @param array $products + */ + public function __construct( + CheckoutOnepage $checkoutOnepage, + FixtureFactory $fixtureFactory, + CreditCard $creditCard, + array $payment, + array $products + ) { + $this->checkoutOnepage = $checkoutOnepage; + $this->fixtureFactory = $fixtureFactory; + $this->creditCard = $creditCard; + $this->payment = $payment; + $this->products = $products; + } + + /** + * Place order with Payflow Link. + * + * @return array + */ + public function run() + { + $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment); + $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); + $this->checkoutOnepage->getPayflowLinkBlock()->fillPaymentData($this->creditCard); + + /** @var OrderInjectable $order */ + $order = $this->fixtureFactory->createByCode( + 'orderInjectable', + [ + 'data' => [ + 'entity_id' => ['products' => $this->products] + ] + ] + ); + return ['order' => $order]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithPaymentsAdvancedStep.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithPaymentsAdvancedStep.php new file mode 100644 index 0000000000000000000000000000000000000000..c39a742c07c091cad853bdf716e7e3122f7c0965 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/PlaceOrderWithPaymentsAdvancedStep.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Paypal\Test\TestStep; + +use Magento\Checkout\Test\Page\CheckoutOnepage; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Payment\Test\Fixture\CreditCard; +use Magento\Sales\Test\Fixture\OrderInjectable; + +/** + * Place order using PayPal Payments Advanced Solution during one page checkout. + */ +class PlaceOrderWithPaymentsAdvancedStep implements TestStepInterface +{ + /** + * Onepage checkout page. + * + * @var CheckoutOnepage + */ + private $checkoutOnepage; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * Products fixtures. + * + * @var array + */ + private $products; + + /** + * Payment information. + * + * @var array + */ + private $payment; + + /** + * Credit card information. + * + * @var CreditCard + */ + private $creditCard; + + /** + * @param CheckoutOnepage $checkoutOnepage + * @param FixtureFactory $fixtureFactory + * @param CreditCard $creditCard + * @param array $payment + * @param array $products + */ + public function __construct( + CheckoutOnepage $checkoutOnepage, + FixtureFactory $fixtureFactory, + CreditCard $creditCard, + array $payment, + array $products + ) { + $this->checkoutOnepage = $checkoutOnepage; + $this->fixtureFactory = $fixtureFactory; + $this->creditCard = $creditCard; + $this->payment = $payment; + $this->products = $products; + } + + /** + * Place order with Payments Advanced. + * + * @return array + */ + public function run() + { + $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment); + $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); + $this->checkoutOnepage->getPaymentsAdvancedBlock()->fillPaymentData($this->creditCard); + + /** @var OrderInjectable $order */ + $order = $this->fixtureFactory->createByCode( + 'orderInjectable', + [ + 'data' => [ + 'entity_id' => ['products' => $this->products] + ] + ] + ); + return ['order' => $order]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/etc/testcase.xml index 89cf35b73bc3ed292a152358fd5265a71d566983..e333b4b4ffefcf02ce59d632b9346831d974fb0b 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/etc/testcase.xml @@ -13,7 +13,7 @@ <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" /> <step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" /> <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" /> - <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" /> <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> <step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" /> <step name="selectPaymentMethod" module="Magento_Checkout" next="continueToPaypalInContext" /> @@ -59,7 +59,7 @@ <step name="selectPaymentMethod" module="Magento_Checkout" next="continueToPaypal" /> <step name="continueToPaypal" module="Magento_Paypal" next="continuePaypalCheckout" /> <step name="continuePaypalCheckout" module="Magento_Paypal" next="getPlacedOrderId" /> - <step name="getPlacedOrderId" module="Magento_Paypal" /> + <step name="getPlacedOrderId" module="Magento_Checkout" /> </scenario> <scenario name="ConflictResolutionTest" firstStep="checkExpressConfig"> <step name="checkExpressConfig" module="Magento_Paypal" next="checkBraintreeConfig" /> @@ -85,4 +85,58 @@ <step name="saveCreditCardOnBackend" module="Magento_Vault" next="submitOrderNegative" /> <step name="submitOrderNegative" module="Magento_Sales" /> </scenario> + <scenario name="OnePageCheckoutHostedProTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="createTaxRule" /> + <step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" /> + <step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" /> + <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" /> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" /> + <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> + <step name="fillShippingMethod" module="Magento_Checkout" next="placeOrderWithHostedPro" /> + <step name="placeOrderWithHostedPro" module="Magento_Paypal" next="getPlacedOrderId" /> + <step name="getPlacedOrderId" module="Magento_Checkout" /> + </scenario> + <scenario name="CloseSalesWithHostedProTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="createTaxRule" /> + <step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" /> + <step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" /> + <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" /> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/> + <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> + <step name="fillShippingMethod" module="Magento_Checkout" next="placeOrderWithHostedPro" /> + <step name="placeOrderWithHostedPro" module="Magento_Paypal" next="getPlacedOrderId" /> + <step name="getPlacedOrderId" module="Magento_Checkout" next="createInvoice" /> + <step name="createInvoice" module="Magento_Sales" next="createShipment" /> + <step name="createShipment" module="Magento_Sales" /> + </scenario> + <scenario name="OnePageCheckoutPaymentsAdvancedTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="createTaxRule" /> + <step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" /> + <step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" /> + <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" /> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" /> + <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> + <step name="fillShippingMethod" module="Magento_Checkout" next="placeOrderWithPaymentsAdvanced" /> + <step name="placeOrderWithPaymentsAdvanced" module="Magento_Paypal" next="getPlacedOrderId" /> + <step name="getPlacedOrderId" module="Magento_Checkout" /> + </scenario> + <scenario name="OnePageCheckoutPayflowLinkTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="createTaxRule" /> + <step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" /> + <step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" /> + <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" /> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" /> + <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> + <step name="fillShippingMethod" module="Magento_Checkout" next="placeOrderWithPayflowLink" /> + <step name="placeOrderWithPayflowLink" module="Magento_Paypal" next="getPlacedOrderId" /> + <step name="getPlacedOrderId" module="Magento_Checkout" /> + </scenario> </config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php index d76461b9ae5f071d8dcdddc2c473ebba01698bfc..d7a89b68c553808cfdbb7de9854ce37e82464618 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php @@ -7,6 +7,7 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order; use Magento\Mtf\Block\Block; +use Magento\Mtf\Client\ElementInterface; /** * Base Items block on Credit Memo, Invoice, Shipment view page. @@ -18,56 +19,63 @@ class AbstractItems extends Block * * @var string */ - protected $rowItem = 'tbody'; + private $rowItem = 'tbody'; /** - * Locator for "Product" column. + * Locator for product sku column. * * @var string */ - protected $product = '.col-product'; + private $sku = '.col-product .product-sku-block'; + + /** + * Locator for product title column. + * + * @var string + */ + private $title = '.col-product .product-title'; /** * Locator for "Price" column. * * @var string */ - protected $price = '.col-price .price'; + private $price = '.col-price .price'; /** * Locator for "Qty" column. * * @var string */ - protected $qty = '.col-qty'; + private $qty = '.col-qty'; /** * Locator for "Subtotal" column. * * @var string */ - protected $subtotal = '.col-subtotal .price'; + private $subtotal = '.col-subtotal .price'; /** * Locator for "Tax Amount" column. * * @var string */ - protected $taxAmount = '.col-tax .price'; + private $taxAmount = '.col-tax .price'; /** * Locator for "Discount Amount" column. * * @var string */ - protected $discountAmount = '.col-discount .price'; + private $discountAmount = '.col-discount .price'; /** * Locator for "Row total" column. * * @var string */ - protected $rowTotal = '.col-total .price'; + private $rowTotal = '.col-total .price'; /** * Get items data. @@ -82,9 +90,10 @@ class AbstractItems extends Block foreach ($items as $item) { $itemData = []; - $itemData += $this->parseProductName($item->find($this->product)->getText()); + $itemData['product'] = preg_replace('/\n|\r/', '', $item->find($this->title)->getText()); + $itemData['sku'] = $this->getSku($item); $itemData['price'] = $this->escapePrice($item->find($this->price)->getText()); - $itemData['qty'] = $item->find($this->qty)->getText(); + $itemData['qty'] = $this->getQty($item); $itemData['subtotal'] = $this->escapePrice($item->find($this->subtotal)->getText()); $itemData['tax'] = $this->escapePrice($item->find($this->taxAmount)->getText()); $itemData['discount'] = $this->escapePrice($item->find($this->discountAmount)->getText()); @@ -97,18 +106,33 @@ class AbstractItems extends Block } /** - * Parse product name to title and sku product. + * Get product quantity. * - * @param string $product - * @return array + * @param ElementInterface $item + * @return null|int + */ + private function getQty(ElementInterface $item) + { + $qty = null; + $elements = $item->getElements($this->qty); + foreach ($elements as $element) { + $qty += (int) $element->getText(); + } + return $qty; + } + + /** + * Get product SKU. + * + * @param ElementInterface $item + * @return string */ - protected function parseProductName($product) + private function getSku(ElementInterface $item) { - $data = array_map('trim', explode('SKU:', str_replace("\n", '', $product))); - return [ - 'product' => $data[0], - 'sku' => isset($data[1]) ? $data[1] : '' - ]; + $itemContent = $item->find($this->sku)->getText(); + $itemContent = preg_replace('/\n|\r/', '', $itemContent); + $itemContent = str_replace('SKU: ', '', $itemContent); + return $itemContent; } /** @@ -117,7 +141,7 @@ class AbstractItems extends Block * @var string $price * @return string */ - protected function escapePrice($price) + private function escapePrice($price) { return preg_replace('[^0-9\.]', '', $price); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Method.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Method.php index 8477af0087fd47e07b8fee3e6c5138c690369d05..0d443eb1db9ff3c5e3eee8a4efcaffbea5d44df9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Method.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Method.php @@ -7,8 +7,8 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing; use Magento\Mtf\Block\Block; -use Magento\Mtf\Fixture\InjectableFixture; use Magento\Mtf\Client\Locator; +use Magento\Payment\Test\Fixture\CreditCard; /** * Adminhtml sales order create payment method block. @@ -20,66 +20,60 @@ class Method extends Block * * @var string */ - protected $paymentMethod = '#p_method_%s'; + private $paymentMethod = '#p_method_%s'; /** * Purchase order number selector. * * @var string */ - protected $purchaseOrderNumber = '#po_number'; - - /** - * Payment form. - * - * @var string - */ - protected $paymentForm = '#payment_form_%s'; + private $purchaseOrderNumber = '#po_number'; /** * Magento loader selector. * * @var string */ - protected $loader = '[data-role=loader]'; + private $loader = '[data-role=loader]'; /** * Field with Mage error. * * @var string */ - protected $mageErrorField = '//fieldset/*[contains(@class,"field ")][.//*[contains(@class,"error")]]'; + private $mageErrorField = './/*[contains(@name, "payment[")]/following-sibling::label[@class="mage-error"]'; /** - * Mage error text. + * Error label preceding field of credit card form. * * @var string */ - protected $mageErrorText = './/label[contains(@class,"error")]'; + private $errorLabelPrecedingField = './preceding-sibling::*[1][contains(@name, "payment")]'; /** * Select payment method. * - * @param array $paymentCode - * @param InjectableFixture|null $creditCard + * @param array $payment + * @param CreditCard|null $creditCard + * @return void */ - public function selectPaymentMethod(array $paymentCode, InjectableFixture $creditCard = null) + public function selectPaymentMethod(array $payment, CreditCard $creditCard = null) { - $paymentInput = $this->_rootElement->find(sprintf($this->paymentMethod, $paymentCode['method'])); + $paymentMethod = $payment['method']; + $paymentInput = $this->_rootElement->find(sprintf($this->paymentMethod, $paymentMethod)); if ($paymentInput->isVisible()) { $paymentInput->click(); $this->waitForElementNotVisible($this->loader); } - if (isset($paymentCode['po_number'])) { - $this->_rootElement->find($this->purchaseOrderNumber)->setValue($paymentCode['po_number']); + if (isset($payment['po_number'])) { + $this->_rootElement->find($this->purchaseOrderNumber)->setValue($payment['po_number']); } if ($creditCard !== null) { - $class = explode('\\', get_class($creditCard)); - $module = $class[1]; - /** @var \Magento\Payment\Test\Block\Form\Cc $formBlock */ + $module = $creditCard->hasData('payment_code') ? ucfirst($creditCard->getPaymentCode()) : 'Payment'; + /** @var \Magento\Payment\Test\Block\Form\PaymentCc $formBlock */ $formBlock = $this->blockFactory->create( - "\\Magento\\{$module}\\Test\\Block\\Form\\Cc", - ['element' => $this->_rootElement->find('#payment_form_' . $paymentCode['method'])] + "\\Magento\\{$module}\\Test\\Block\\Form\\{$module}Cc", + ['element' => $this->_rootElement->find('#payment_form_' . $paymentMethod)] ); $formBlock->fill($creditCard); } @@ -92,10 +86,9 @@ class Method extends Block { $data = []; $elements = $this->_rootElement->getElements($this->mageErrorField, Locator::SELECTOR_XPATH); - foreach ($elements as $element) { - $error = $element->find($this->mageErrorText, Locator::SELECTOR_XPATH); + foreach ($elements as $error) { if ($error->isVisible()) { - $label = $element->find('.//*[contains(@name,"payment")]', Locator::SELECTOR_XPATH); + $label = $error->find($this->errorLabelPrecedingField, Locator::SELECTOR_XPATH); $label = $label->getAttribute('name'); $label = preg_replace('/payment\[(.*)\]/u', '$1', $label); $data[$label] = $error->getText(); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php index b6b14670c0f56ce8c6439c26fb606b2c35e85dc9..3433447222ccbbd92ee75f161c2c4f24dfb453c1 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php @@ -28,6 +28,13 @@ class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\Totals */ protected $capture = '[name="invoice[capture_case]"]'; + /** + * Offline capture text message selector. + * + * @var string + */ + private $captureOfflineMessage = './/input[@value="offline"]/following-sibling::div[1]'; + /** * Submit invoice * @@ -58,4 +65,15 @@ class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\Totals { $this->_rootElement->find($this->capture, Locator::SELECTOR_CSS, 'select')->setValue($option); } + + /** + * Get message that invoice can be created only offline. + * + * @return null|string + */ + public function getCaptureOfflineMessage() + { + $captureCaseMessage = $this->_rootElement->find($this->captureOfflineMessage, Locator::SELECTOR_XPATH); + return $captureCaseMessage->isVisible() ? $captureCaseMessage->getText() : null; + } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php index 757a025605b9b69271e33848a019dd299f6034d9..2261257ca70fe093db941bca8a693d34ce813ae4 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.php @@ -7,30 +7,11 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\View; use Magento\Backend\Test\Block\Widget\FormTabs; -use Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info as OrderInformationBlock; /** - * Order view tabs + * Order view tabs. */ class OrderForm extends FormTabs { - /** - * Order information block. - * - * @var string - */ - protected $orderInfoBlock = '[data-ui-id="sales-order-tabs-tab-content-order-info"]'; - - /** - * Get order information block. - * - * @return OrderInformationBlock - */ - public function getOrderInfoBlock() - { - return $this->blockFactory->create( - \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info::class, - ['element' => $this->_rootElement->find($this->orderInfoBlock)] - ); - } + // } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.xml index 383dfb8b7b6aade39bf531312101387fc5c9bac7..0a5aa8e1993a8e84963b981849f18b19a8a22372 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/OrderForm.xml @@ -6,6 +6,11 @@ */ --> <tabs> + <info> + <class>Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info</class> + <selector>#sales_order_view_tabs_order_info</selector> + <strategy>css selector</strategy> + </info> <invoices> <class>Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices</class> <selector>#sales_order_view_tabs_order_invoices</selector> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php index 50c5a077e9b5511bd98d15306a5f3de15f6ad6a0..146e3facccb6196f154af1487053f8e8b17e1991 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php @@ -6,22 +6,30 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\View\Tab; -use Magento\Mtf\Block\Block; +use Magento\Backend\Test\Block\Widget\Tab; +use Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info\PaymentInfoBlock; /** * Order information tab block. */ -class Info extends Block +class Info extends Tab { /** - * Order status selector + * Order status selector. * * @var string */ protected $orderStatus = '#order_status'; /** - * Get order status from info block + * Selector for 'Payment Information' block. + * + * @var string + */ + private $paymentInfoBlockSelector = '.order-payment-method'; + + /** + * Get order status from info block. * * @return array|string */ @@ -29,4 +37,17 @@ class Info extends Block { return $this->_rootElement->find($this->orderStatus)->getText(); } + + /** + * Returns Payment Information block. + * + * @return PaymentInfoBlock + */ + public function getPaymentInfoBlock() + { + return $this->blockFactory->create( + PaymentInfoBlock::class, + ['element' => $this->_rootElement->find($this->paymentInfoBlockSelector)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/PaymentInfoBlock.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/PaymentInfoBlock.php new file mode 100644 index 0000000000000000000000000000000000000000..818a9b9717cb989c5b352dfed121525f2b7bc4c3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/PaymentInfoBlock.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info; + +use Magento\Mtf\Block\Block; + +/** + * Order payment information block. + */ +class PaymentInfoBlock extends Block +{ + /** + * Payment info row selector. + * + * @var string + */ + private $info = 'tr'; + + /** + * Get payment information block data. + * + * @return array + */ + public function getData() + { + $result = []; + $elements = $this->_rootElement->getElements($this->info); + foreach ($elements as $row) { + $key = rtrim($row->find('th')->getText(), ':'); + $value = $row->find('td')->getText(); + $result[$key] = $value; + } + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php index 4b3768295799695fbb45db1a17e75acb193b91f7..41fbd8979b58df8fb58f000e3ea79e0f289344c4 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php @@ -25,6 +25,13 @@ class Grid extends \Magento\Ui\Test\Block\Adminhtml\DataGrid */ protected $invoiceId = 'tbody td:nth-child(2)'; + /** + * Invoices data grid loader locator. + * + * @var string + */ + protected $loader = '[data-component="sales_order_view_invoice_grid"]'; + /** * Filters array mapping. * @@ -57,6 +64,7 @@ class Grid extends \Magento\Ui\Test\Block\Adminhtml\DataGrid public function getIds() { $result = []; + $this->waitForElementNotVisible($this->loader); $invoiceIds = $this->_rootElement->getElements($this->invoiceId); foreach ($invoiceIds as $invoiceId) { $result[] = trim($invoiceId->getText()); @@ -72,6 +80,7 @@ class Grid extends \Magento\Ui\Test\Block\Adminhtml\DataGrid */ public function viewInvoice() { + $this->waitForElementNotVisible($this->loader); $this->_rootElement->find($this->invoiceId)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertItems.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertItems.php index 26978343fb2c26336e3e9902f46ca730a54ce6d8..fc9bd8275d650f19bedfebec0fe3f52c836d0623 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertItems.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertItems.php @@ -6,25 +6,25 @@ namespace Magento\Sales\Test\Constraint; -use Magento\Catalog\Test\Fixture\CatalogProductSimple; -use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Checkout\Test\Fixture\Cart; use Magento\Mtf\Constraint\AbstractAssertForm; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Sales\Test\Fixture\OrderInjectable; /** - * Class AbstractAssertArchiveItems - * Assert items represented in order's entity view page + * Assert items represented in order's entity view page. */ abstract class AbstractAssertItems extends AbstractAssertForm { /** - * Key for sort data + * Key for sort data. * * @var string */ protected $sortKey = "::sku"; /** - * List compare fields + * List compare fields. * * @var array */ @@ -35,25 +35,29 @@ abstract class AbstractAssertItems extends AbstractAssertForm ]; /** - * Prepare order products + * Prepare order products. * * @param OrderInjectable $order * @param array|null $data [optional] + * @param Cart|null $cart [optional] * @return array */ - protected function prepareOrderProducts(OrderInjectable $order, array $data = null) + protected function prepareOrderProducts(OrderInjectable $order, array $data = null, Cart $cart = null) { - $products = $order->getEntityId()['products']; $productsData = []; - - /** @var CatalogProductSimple $product */ - foreach ($products as $key => $product) { + if ($cart === null) { + $cart['data']['items'] = ['products' => $order->getEntityId()['products']]; + $fixtureFactory = $this->objectManager->create(FixtureFactory::class); + $cart = $fixtureFactory->createByCode('cart', $cart); + } + /** @var \Magento\Catalog\Test\Fixture\Cart\Item $item */ + foreach ($cart->getItems() as $key => $item) { $productsData[] = [ - 'product' => $product->getName(), - 'sku' => $product->getSku(), + 'product' => $item->getData()['name'], + 'sku' => $item->getData()['sku'], 'qty' => (isset($data[$key]['qty']) && $data[$key]['qty'] != '-') ? $data[$key]['qty'] - : $product->getCheckoutData()['qty'], + : $item->getData()['qty'], ]; } @@ -61,7 +65,7 @@ abstract class AbstractAssertItems extends AbstractAssertForm } /** - * Prepare invoice data + * Prepare invoice data. * * @param array $itemsData * @return array diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php index a6b8e8983d2b617953b93490dc4c3a3e1079cec2..8b34837bc8df3efe77a348070abdcf12de71ac7f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php @@ -6,8 +6,8 @@ namespace Magento\Sales\Test\Constraint; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Mtf\Constraint\AbstractConstraint; /** @@ -16,9 +16,9 @@ use Magento\Mtf\Constraint\AbstractConstraint; class AssertAuthorizationInCommentsHistory extends AbstractConstraint { /** - * Message about authorized amount in order. + * Pattern of message about authorized amount in order. */ - const AUTHORIZED_AMOUNT = 'Authorized amount of $'; + const AUTHORIZED_AMOUNT_PATTERN = '/(IPN "Pending" )*Authorized amount of \w*\W{1,2}%s. Transaction ID: "[\w\-]*"/'; /** * Assert that comment about authorized amount exist in Comments History section on order page in Admin. @@ -37,11 +37,10 @@ class AssertAuthorizationInCommentsHistory extends AbstractConstraint ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $actualAuthorizedAmount = $salesOrderView->getOrderHistoryBlock()->getAuthorizedAmount(); - \PHPUnit_Framework_Assert::assertContains( - self::AUTHORIZED_AMOUNT . $prices['grandTotal'], + \PHPUnit_Framework_Assert::assertRegExp( + sprintf(self::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']), $actualAuthorizedAmount, 'Incorrect authorized amount value for the order #' . $orderId ); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php index c46a161cc63723b6fc4d2376e6f3160ed5e7eb54..90e0e7b091a11f51c04e8f719b3e1b4382080d61 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php @@ -6,6 +6,7 @@ namespace Magento\Sales\Test\Constraint; +use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -16,9 +17,9 @@ use Magento\Mtf\Constraint\AbstractConstraint; class AssertCaptureInCommentsHistory extends AbstractConstraint { /** - * Message about captured amount in order. + * Pattern of message about captured amount in order. */ - const CAPTURED_AMOUNT = 'Captured amount of $'; + const CAPTURED_AMOUNT_PATTERN = '/^Captured amount of \w*\W{1,2}%s online. Transaction ID: "[\w\-]*"/'; /** * Assert that comment about captured amount exist in Comments History section on order page in Admin. @@ -40,8 +41,8 @@ class AssertCaptureInCommentsHistory extends AbstractConstraint $actualCapturedAmount = $salesOrderView->getOrderHistoryBlock()->getCapturedAmount(); foreach ($capturedPrices as $key => $capturedPrice) { - \PHPUnit_Framework_Assert::assertContains( - self::CAPTURED_AMOUNT . $capturedPrice, + \PHPUnit_Framework_Assert::assertRegExp( + sprintf(self::CAPTURED_AMOUNT_PATTERN, $capturedPrice), $actualCapturedAmount[$key], 'Incorrect captured amount value for the order #' . $orderId ); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertInvoiceItems.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertInvoiceItems.php index 9b43a3917aac199a5dc2e2255f6db5e2eb615dc6..cbcb725df05ffb0516497847f26440ee3f0790d7 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertInvoiceItems.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertInvoiceItems.php @@ -6,6 +6,7 @@ namespace Magento\Sales\Test\Constraint; +use Magento\Checkout\Test\Fixture\Cart; use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\Adminhtml\InvoiceIndex; use Magento\Sales\Test\Page\Adminhtml\SalesInvoiceView; @@ -23,6 +24,7 @@ class AssertInvoiceItems extends AbstractAssertItems * @param OrderInjectable $order * @param array $ids * @param array|null $data [optional] + * @param Cart|null $cart [optional] * @return void */ public function processAssert( @@ -30,10 +32,11 @@ class AssertInvoiceItems extends AbstractAssertItems SalesInvoiceView $salesInvoiceView, OrderInjectable $order, array $ids, - array $data = null + array $data = null, + Cart $cart = null ) { $orderId = $order->getId(); - $productsData = $this->prepareOrderProducts($order, $data['items_data']); + $productsData = $this->prepareOrderProducts($order, $data['items_data'], $cart); foreach ($ids['invoiceIds'] as $invoiceId) { $filter = [ 'order_id' => $orderId, diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOnlineInvoiceCannotBeCreated.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOnlineInvoiceCannotBeCreated.php new file mode 100644 index 0000000000000000000000000000000000000000..437dc8cc1be280f2edfd46baac79cad24e5748c0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOnlineInvoiceCannotBeCreated.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Constraint; + +use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceNew; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert message that invoice can be created only offline is present. + */ +class AssertOnlineInvoiceCannotBeCreated extends AbstractConstraint +{ + /** + * Message that invoice can be created only offline. + */ + const OFFLINE_INVOICE_MESSAGE = 'The invoice will be created offline without the payment gateway.'; + + /** + * Assert message that invoice can be created only offline is present. + * + * @param SalesOrderView $salesOrderView + * @param OrderIndex $salesOrder + * @param OrderInvoiceNew $orderInvoiceNew + * @param string $orderId + * @return void + */ + public function processAssert( + SalesOrderView $salesOrderView, + OrderIndex $salesOrder, + OrderInvoiceNew $orderInvoiceNew, + $orderId + ) { + $salesOrder->open(); + $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); + $salesOrderView->getPageActions()->invoice(); + + \PHPUnit_Framework_Assert::assertEquals( + self::OFFLINE_INVOICE_MESSAGE, + $orderInvoiceNew->getTotalsBlock()->getCaptureOfflineMessage(), + 'Message incorrect or is not present.' + ); + } + + /** + * Returns string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return "Message that invoice can be created only offline is present."; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php index 4c30d5f68d208a2b53f54fd7607f7fec276c7c63..1de6de50612481e6bd90b209fcef59e5b3f68706 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php @@ -6,29 +6,29 @@ namespace Magento\Sales\Test\Constraint; -use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Mtf\Constraint\AbstractConstraint; /** - * Assert that Order Grand Total is correct on order page in backend + * Assert that Order Grand Total is correct on order page in Admin. */ class AssertOrderGrandTotal extends AbstractConstraint { /** - * Assert that Order Grand Total is correct on order page in backend + * Assert that Order Grand Total is correct on order page in Admin. * * @param SalesOrderView $salesOrderView - * @param string $orderId * @param OrderIndex $salesOrder * @param array $prices + * @param string $orderId * @return void */ public function processAssert( SalesOrderView $salesOrderView, OrderIndex $salesOrder, - $orderId, - array $prices + array $prices, + $orderId ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); @@ -41,7 +41,7 @@ class AssertOrderGrandTotal extends AbstractConstraint } /** - * Returns a string representation of the object + * Returns a string representation of the object. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderPaymentInformation.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderPaymentInformation.php new file mode 100644 index 0000000000000000000000000000000000000000..18119ddbf95d6864311e750bd6844ba43062c73b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderPaymentInformation.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Constraint; + +use Magento\Mtf\Constraint\AbstractConstraint; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; + +/** + * Assert that payment information is valid and matches with expected values. + */ +class AssertOrderPaymentInformation extends AbstractConstraint +{ + /** + * Assert that payment information is valid and matches with expected values. + * + * @param OrderInjectable $order + * @param OrderIndex $orderIndex + * @param SalesOrderView $salesOrderView + * @param array $paymentInfo + * @return void + */ + public function processAssert( + OrderInjectable $order, + OrderIndex $orderIndex, + SalesOrderView $salesOrderView, + array $paymentInfo + ) { + $orderIndex->open(); + $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $actualPaymentInformation = $infoTab->getPaymentInfoBlock()->getData(); + + \PHPUnit_Framework_Assert::assertEmpty( + array_diff($paymentInfo, $actualPaymentInformation), + 'Payment Information missmatch with expected values.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Payment Information valid and matches with expected values.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCorrect.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCorrect.php index 056e97c1b62626e0e10352d1bae9a078dea9021d..3623de40b06f165bf4f891d19d379f4d9104f336 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCorrect.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCorrect.php @@ -11,13 +11,12 @@ use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertOrderStatusIsCorrect - * Assert that status is correct on order page in backend (same with value of orderStatus variable) + * Assert that status is correct on order page in admin panel (same with value of orderStatus variable). */ class AssertOrderStatusIsCorrect extends AbstractConstraint { /** - * Assert that status is correct on order page in backend (same with value of orderStatus variable) + * Assert that status is correct on order page in admin panel (same with value of orderStatus variable). * * @param string $status * @param string $orderId @@ -37,14 +36,16 @@ class AssertOrderStatusIsCorrect extends AbstractConstraint $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); $orderStatus = $statusToCheck == null ? $status : $statusToCheck; + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); \PHPUnit_Framework_Assert::assertEquals( - $salesOrderView->getOrderForm()->getOrderInfoBlock()->getOrderStatus(), + $infoTab->getOrderStatus(), $orderStatus ); } /** - * Returns a string representation of the object + * Returns a string representation of the object. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php index 9cbb7b2c9ebbb684fcccbde61c7fc5e9bf82cee4..c0ce2a87fc1c3f62b1a934852c206358a3e76760 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php @@ -16,9 +16,9 @@ use Magento\Mtf\Constraint\AbstractConstraint; class AssertRefundInCommentsHistory extends AbstractConstraint { /** - * Message about refunded amount in order. + * Pattern of message about refunded amount in order. */ - const REFUNDED_AMOUNT = 'We refunded $'; + const REFUNDED_AMOUNT_PATTERN = '/^We refunded \w*\W{1,2}%s online. Transaction ID: "[\w\-]*"/'; /** * Assert that comment about refunded amount exist in Comments History section on order page in Admin. @@ -40,8 +40,8 @@ class AssertRefundInCommentsHistory extends AbstractConstraint $actualRefundedAmount = $salesOrderView->getOrderHistoryBlock()->getRefundedAmount(); foreach ($refundedPrices as $key => $refundedPrice) { - \PHPUnit_Framework_Assert::assertContains( - self::REFUNDED_AMOUNT . $refundedPrice, + \PHPUnit_Framework_Assert::assertRegExp( + sprintf(self::REFUNDED_AMOUNT_PATTERN, $refundedPrice), $actualRefundedAmount[$key], 'Incorrect refunded amount value for the order #' . $orderId ); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php index 89faffc8ec0729082c81839ccd4762fdc335a8f3..557e29a0b9830200381f7651e3807cff39247040 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php @@ -11,7 +11,7 @@ use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Sales\Test\Fixture\OrderInjectable; /** - * Class AssertRefundOrderStatusInCommentsHistory + * Assert that comment about refunded amount exist in Comments History section on order page in Admin. */ class AssertRefundOrderStatusInCommentsHistory extends AbstractConstraint { @@ -30,8 +30,11 @@ class AssertRefundOrderStatusInCommentsHistory extends AbstractConstraint ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); + + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); \PHPUnit_Framework_Assert::assertContains( - $salesOrderView->getOrderForm()->getOrderInfoBlock()->getOrderStatus(), + $infoTab->getOrderStatus(), $salesOrderView->getOrderHistoryBlock()->getStatus() ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertReorderStatusIsCorrect.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertReorderStatusIsCorrect.php index 804c607814a3da0cf081cbd9b5fa1b34617d0988..9c034d2ea7085d3aa35bfe5cf06af42edcd672a1 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertReorderStatusIsCorrect.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertReorderStatusIsCorrect.php @@ -12,13 +12,12 @@ use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertReorderStatusIsCorrect - * Assert that status is correct on order page in backend + * Assert that status is correct on order page in admin panel. */ class AssertReorderStatusIsCorrect extends AbstractConstraint { /** - * Assert that status is correct on order page in backend (same with value of orderStatus variable) + * Assert that status is correct on order page in admin panel (same with value of orderStatus variable). * * @param string $previousOrderStatus * @param OrderInjectable $order @@ -35,15 +34,17 @@ class AssertReorderStatusIsCorrect extends AbstractConstraint $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); \PHPUnit_Framework_Assert::assertEquals( $previousOrderStatus, - $salesOrderView->getOrderForm()->getOrderInfoBlock()->getOrderStatus(), + $infoTab->getOrderStatus(), 'Order status is incorrect on order page in backend.' ); } /** - * Returns a string representation of the object + * Returns a string representation of the object. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddProductsStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddProductsStep.php index 594f7098e45592f61ba83544f80a742f9eeb5b2e..0caeb235119c86debf0cc6de86e69cbb0f6b3883 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddProductsStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddProductsStep.php @@ -6,44 +6,55 @@ namespace Magento\Sales\Test\TestStep; +use Magento\Mtf\Fixture\FixtureFactory; use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; use Magento\Mtf\TestStep\TestStepInterface; /** - * Class AddProductsStep - * Add Products Step + * Add Products Step. */ class AddProductsStep implements TestStepInterface { /** - * Sales order create index page + * Sales order create index page. * * @var OrderCreateIndex */ - protected $orderCreateIndex; + private $orderCreateIndex; /** - * Array products + * Array products. * * @var array */ - protected $products; + private $products; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + private $fixtureFactory; /** - * @constructor * @param OrderCreateIndex $orderCreateIndex + * @param FixtureFactory $fixtureFactory * @param array $products */ - public function __construct(OrderCreateIndex $orderCreateIndex, array $products) - { + public function __construct( + OrderCreateIndex $orderCreateIndex, + FixtureFactory $fixtureFactory, + array $products + ) { $this->orderCreateIndex = $orderCreateIndex; $this->products = $products; + $this->fixtureFactory = $fixtureFactory; } /** - * Add product to sales + * Add product to sales. * - * @return void + * @return array */ public function run() { @@ -58,5 +69,8 @@ class AddProductsStep implements TestStepInterface } $createBlock->addSelectedProductsToOrder(); $createBlock->getTemplateBlock()->waitLoader(); + + $cart['data']['items'] = ['products' => $this->products]; + return ['cart' => $this->fixtureFactory->createByCode('cart', $cart)]; } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SelectPaymentMethodForOrderStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SelectPaymentMethodForOrderStep.php index c05dfc4fac2dcbb8bea98ec39c705c9ff419e559..fa0a62d79625e1e23602aed9f37ab153f8d2ee76 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SelectPaymentMethodForOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SelectPaymentMethodForOrderStep.php @@ -6,7 +6,6 @@ namespace Magento\Sales\Test\TestStep; -use Magento\Mtf\Fixture\FixtureFactory; use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; use Magento\Mtf\TestStep\TestStepInterface; use Magento\Payment\Test\Fixture\CreditCard; @@ -38,29 +37,22 @@ class SelectPaymentMethodForOrderStep implements TestStepInterface private $creditCard; /** - * @constructor * @param OrderCreateIndex $orderCreateIndex * @param array $payment - * @param FixtureFactory $fixtureFactory - * @param string $creditCardClass - * @param array|CreditCard|null $creditCard + * @param CreditCard|null $creditCard */ public function __construct( OrderCreateIndex $orderCreateIndex, array $payment, - FixtureFactory $fixtureFactory, - $creditCardClass = 'credit_card', - array $creditCard = null + CreditCard $creditCard = null ) { $this->orderCreateIndex = $orderCreateIndex; $this->payment = $payment; - if (isset($creditCard['dataset'])) { - $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]); - } + $this->creditCard = $creditCard; } /** - * Fill Payment data + * Fill Payment data. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml index df10cccbd82136f027f4ee6b236cafe272cdbdc8..157dfc0f77302318bdce435dd3af7f6de5e261fb 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml @@ -91,4 +91,19 @@ <argument name="severity" xsi:type="string">S0</argument> </arguments> </type> + <type name="Magento\Sales\Test\Constraint\AssertOnlineInvoiceCannotBeCreated"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Sales\Test\Constraint\AssertOrderPaymentInformation"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Sales\Test\Constraint\AssertOnlineInvoiceCannotBeCreated"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php index e6462e4697aa612c1239b92b3c7b7e847bd252ba..37aa17e95b2ff4803d95d7865f4892190f940e15 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php @@ -6,6 +6,7 @@ namespace Magento\Vault\Test\TestCase; use Magento\Checkout\Test\Page\CheckoutOnepage; +use Magento\Customer\Test\Fixture\Customer; use Magento\Mtf\ObjectManager; use Magento\Mtf\TestCase\Injectable; use Magento\Vault\Test\Constraint\AssertCreditCardNotPresentOnCheckout; @@ -95,7 +96,7 @@ class DeleteSavedCreditCardTest extends Injectable if ($key >= 2) { // if this order will be placed via stored credit card $this->useSavedCreditCard($payment['vault']); } else { - $this->selectPaymentMethod($payment, $payment['creditCardClass'], $payment['creditCard']); + $this->selectPaymentMethod($payment, $payment['creditCard']); $this->saveCreditCard($payment, $creditCardSave); } $this->placeOrder(); @@ -105,8 +106,7 @@ class DeleteSavedCreditCardTest extends Injectable for ($i = 2; $i < $paymentsCount; $i++) { $deletedCard = $this->deleteCreditCardFromMyAccount( $customer, - $payments[$i]['creditCard'], - $payments[$i]['creditCardClass'] + $payments[$i]['creditCard'] ); $this->addToCart($products); $this->proceedToCheckout(); @@ -119,9 +119,12 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Setup configuration step. + * * @param $configData + * @return void */ - protected function setupConfiguration($configData) + private function setupConfiguration($configData) { $setupConfigurationStep = ObjectManager::getInstance()->create( \Magento\Config\Test\TestStep\SetupConfigurationStep::class, @@ -132,7 +135,7 @@ class DeleteSavedCreditCardTest extends Injectable } /** - * Create products + * Create products step. * * @param string $productList * @return array @@ -149,6 +152,8 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Add to cart step. + * * @param array $products * @return void */ @@ -162,6 +167,8 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Proceed to checkout step. + * * @return void */ protected function proceedToCheckout() @@ -173,7 +180,10 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Create customer step. + * * @param array $customer + * @return Customer */ protected function createCustomer(array $customer) { @@ -186,8 +196,11 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Select Checkout method step. + * * @param $checkoutMethod * @param $customer + * @return void */ protected function selectCheckoutMethod($checkoutMethod, $customer) { @@ -202,7 +215,10 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Fill shipping address step. + * * @param array $shippingAddress + * @return void */ protected function fillShippingAddress(array $shippingAddress) { @@ -214,9 +230,10 @@ class DeleteSavedCreditCardTest extends Injectable } /** - * Add products to cart + * Add products to cart. * * @param array $shipping + * @return void */ protected function fillShippingMethod(array $shipping) { @@ -228,17 +245,18 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Select payment method step. + * * @param array $payment - * @param $creditCardClass * @param array $creditCard + * @return void */ - protected function selectPaymentMethod(array $payment, $creditCardClass, array $creditCard) + protected function selectPaymentMethod(array $payment, array $creditCard) { $selectPaymentMethodStep = ObjectManager::getInstance()->create( \Magento\Checkout\Test\TestStep\SelectPaymentMethodStep::class, [ 'payment' => $payment, - 'creditCardClass' => $creditCardClass, 'creditCard' => $creditCard, ] ); @@ -250,6 +268,7 @@ class DeleteSavedCreditCardTest extends Injectable * * @param $payment * @param $creditCardSave + * @return void */ protected function saveCreditCard($payment, $creditCardSave) { @@ -264,6 +283,8 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Fill billing information step. + * * @return void */ protected function fillBillingInformation() @@ -275,6 +296,8 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Place order step. + * * @return void */ protected function placeOrder() @@ -286,7 +309,10 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Use saved credit card step. + * * @param $payment + * @return void */ protected function useSavedCreditCard($payment) { @@ -298,18 +324,19 @@ class DeleteSavedCreditCardTest extends Injectable } /** + * Delete credit card from My Account step. + * * @param $customer * @param $creditCard - * @param $creditCardClass + * @return array */ - protected function deleteCreditCardFromMyAccount($customer, $creditCard, $creditCardClass) + protected function deleteCreditCardFromMyAccount($customer, $creditCard) { $deleteCreditCardFromMyAccountStep = ObjectManager::getInstance()->create( \Magento\Vault\Test\TestStep\DeleteCreditCardFromMyAccountStep::class, [ 'customer' => $customer, - 'creditCard' => $creditCard, - 'creditCardClass' => $creditCardClass + 'creditCard' => $creditCard ] ); $deletedCard = $deleteCreditCardFromMyAccountStep->run(); diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.xml b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.xml index 2cafc815fed1dfc1865d1f2627f536d1ba909563..c6daa6ac89d58c68f9edc9c7e9372780107f56a7 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.xml +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.xml @@ -17,23 +17,29 @@ <data name="payments" xsi:type="array"> <item name="0" xsi:type="array"> <item name="method" xsi:type="string">braintree</item> - <item name="creditCardClass" xsi:type="string">credit_card_braintree</item> <item name="creditCard" xsi:type="array"> - <item name="dataset" xsi:type="string">visa_braintree</item> + <item name="dataset" xsi:type="string">visa_default</item> + <item name="data" xsi:type="array"> + <item name="payment_code" xsi:type="string">braintree</item> + </item> </item> </item> <item name="1" xsi:type="array"> <item name="method" xsi:type="string">payflowpro</item> - <item name="creditCardClass" xsi:type="string">credit_card</item> <item name="creditCard" xsi:type="array"> <item name="dataset" xsi:type="string">visa_alt</item> + <item name="data" xsi:type="array"> + <item name="payment_code" xsi:type="string">payment</item> + </item> </item> </item> <item name="2" xsi:type="array"> <item name="method" xsi:type="string">braintree</item> - <item name="creditCardClass" xsi:type="string">credit_card_braintree</item> <item name="creditCard" xsi:type="array"> - <item name="dataset" xsi:type="string">visa_braintree</item> + <item name="dataset" xsi:type="string">visa_default</item> + <item name="data" xsi:type="array"> + <item name="payment_code" xsi:type="string">braintree</item> + </item> </item> <item name="vault" xsi:type="array"> <item name="method" xsi:type="string">braintree_cc_vault</item> @@ -41,9 +47,11 @@ </item> <item name="3" xsi:type="array"> <item name="method" xsi:type="string">payflowpro</item> - <item name="creditCardClass" xsi:type="string">credit_card</item> <item name="creditCard" xsi:type="array"> <item name="dataset" xsi:type="string">visa_alt</item> + <item name="data" xsi:type="array"> + <item name="payment_code" xsi:type="string">payment</item> + </item> </item> <item name="vault" xsi:type="array"> <item name="method" xsi:type="string">payflowpro_cc_vault</item> diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php index c3cb46347dd8c50bfa372b84df66231086e054a5..f751108d28b16600c0b61050923174f81a98678c 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php @@ -7,86 +7,87 @@ namespace Magento\Vault\Test\TestStep; use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\CustomerAccountIndex; -use Magento\Mtf\Fixture\FixtureFactory; -use Magento\Mtf\Fixture\InjectableFixture; use Magento\Mtf\ObjectManager; use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Payment\Test\Fixture\CreditCard; use Magento\Vault\Test\Constraint\AssertStoredPaymentDeletedMessage; use Magento\Vault\Test\Page\StoredPaymentMethods; /** + * Delete credit card from My Account step. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class DeleteCreditCardFromMyAccountStep implements TestStepInterface { /** + * Customer Fixture. + * * @var Customer */ private $customer; /** + * Object manager. + * * @var ObjectManager */ private $objectManager; /** + * Customer account index page. + * * @var CustomerAccountIndex */ private $customerAccountIndex; /** - * @var FixtureFactory - */ - private $fixtureFactory; - - /** - * @var \Magento\Mtf\Fixture\FixtureInterface + * Credit card fixture. + * + * @var CreditCard */ private $creditCard; /** + * Assert message of success deletion of stored payment method. + * * @var AssertStoredPaymentDeletedMessage */ private $assertStoredPaymentDeletedMessage; /** + * Stored payment methods page. + * * @var StoredPaymentMethods */ private $storedPaymentMethodsPage; /** - * DeleteCreditCardFromMyAccountStep constructor. - * * @param StoredPaymentMethods $storedPaymentMethodsPage * @param Customer $customer * @param ObjectManager $objectManager * @param CustomerAccountIndex $customerAccountIndex - * @param FixtureFactory $fixtureFactory * @param AssertStoredPaymentDeletedMessage $assertStoredPaymentDeletedMessage - * @param array $creditCard - * @param string $creditCardClass + * @param CreditCard $creditCard */ public function __construct( StoredPaymentMethods $storedPaymentMethodsPage, Customer $customer, ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, - FixtureFactory $fixtureFactory, AssertStoredPaymentDeletedMessage $assertStoredPaymentDeletedMessage, - array $creditCard, - $creditCardClass = 'credit_card' + CreditCard $creditCard ) { $this->storedPaymentMethodsPage = $storedPaymentMethodsPage; $this->customer = $customer; $this->objectManager = $objectManager; $this->customerAccountIndex = $customerAccountIndex; - $this->fixtureFactory = $fixtureFactory; $this->assertStoredPaymentDeletedMessage = $assertStoredPaymentDeletedMessage; - $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]); + $this->creditCard = $creditCard; } /** - * @inheritdoc + * Run Delete credit card from My Account step. * * @return array */ diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/SaveCreditCardOnBackendStep.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/SaveCreditCardOnBackendStep.php index 24d1c76c01621fa9b6ce892aa8fd3262e3f7090a..3a378633bd4036737f391185ecd1bebb697609f1 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/SaveCreditCardOnBackendStep.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/SaveCreditCardOnBackendStep.php @@ -5,13 +5,12 @@ */ namespace Magento\Vault\Test\TestStep; -use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestStep\TestStepInterface; use Magento\Payment\Test\Fixture\CreditCard; use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; /** - * Class SaveCreditCardOnBackendStep + * Save credit card during order placement from Admin. */ class SaveCreditCardOnBackendStep implements TestStepInterface { @@ -44,22 +43,18 @@ class SaveCreditCardOnBackendStep implements TestStepInterface /** * @param OrderCreateIndex $orderCreateIndex * @param array $payment - * @param FixtureFactory $fixtureFactory - * @param $creditCardClass - * @param array $creditCard + * @param CreditCard $creditCard * @param string $creditCardSave */ public function __construct( OrderCreateIndex $orderCreateIndex, array $payment, - FixtureFactory $fixtureFactory, - $creditCardClass, - array $creditCard, + CreditCard $creditCard, $creditCardSave = 'No' ) { $this->orderCreatePage = $orderCreateIndex; $this->payment = $payment; - $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]); + $this->creditCard = $creditCard; $this->creditCardSave = $creditCardSave; } diff --git a/dev/tests/functional/utils/generate.php b/dev/tests/functional/utils/generate.php index e374dae4ccfc2fec002e7be5d63782f7b9c357e3..d53ac44451376dd8d8a4dd0c69d5802a2ce6f1fe 100644 --- a/dev/tests/functional/utils/generate.php +++ b/dev/tests/functional/utils/generate.php @@ -3,12 +3,17 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem; + require_once dirname(__FILE__) . '/' . 'bootstrap.php'; // Generate fixtures $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); $magentoObjectManager = $magentoObjectManagerFactory->create($_SERVER); - +// Remove previously generated static classes +$fs = $magentoObjectManager->create(Filesystem::class); +$fs->getDirectoryWrite(DirectoryList::ROOT)->delete('dev/tests/functional/generated/'); // Generate factories for old end-to-end tests $magentoObjectManager->create(\Magento\Mtf\Util\Generate\Factory::class)->launch(); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php index 1bbf40ca6dc72999e4d2bd0c65987d25ee2e6f2a..8c0a7dd201d62abd7e823de4c31c2e9aec57f954 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/MassactionTest.php @@ -3,11 +3,10 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - namespace Magento\Backend\Block\Widget\Grid; +use Magento\TestFramework\App\State; + /** * @magentoAppArea adminhtml * @magentoComponentsDir Magento/Backend/Block/_files/design @@ -25,18 +24,43 @@ class MassactionTest extends \PHPUnit_Framework_TestCase */ protected $_layout; + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + + /** + * @var string + */ + private $mageMode; + protected function setUp() { - $this->markTestIncomplete('MAGETWO-6406'); - parent::setUp(); - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $this->mageMode = $this->objectManager->get(State::class)->getMode(); + /** @var \Magento\Theme\Model\Theme\Registration $registration */ - $registration = $objectManager->get(\Magento\Theme\Model\Theme\Registration::class); + $registration = $this->objectManager->get(\Magento\Theme\Model\Theme\Registration::class); $registration->register(); - $objectManager->get(\Magento\Framework\View\DesignInterface::class)->setDesignTheme('BackendTest/test_default'); - $this->_layout = $objectManager->create( + $this->objectManager->get(\Magento\Framework\View\DesignInterface::class) + ->setDesignTheme('BackendTest/test_default'); + } + + protected function tearDown() + { + $this->objectManager->get(State::class)->setMode($this->mageMode); + } + + /** + * @param string $mageMode + */ + private function loadLayout($mageMode = State::MODE_DEVELOPER) + { + $this->objectManager->get(State::class)->setMode($mageMode); + $this->_layout = $this->objectManager->create( \Magento\Framework\View\LayoutInterface::class, ['area' => 'adminhtml'] ); @@ -48,20 +72,14 @@ class MassactionTest extends \PHPUnit_Framework_TestCase $this->assertNotFalse($this->_block, 'Could not load the block for testing'); } - /** - * @covers \Magento\Backend\Block\Widget\Grid\Massaction::getItems - * @covers \Magento\Backend\Block\Widget\Grid\Massaction::getCount - * @covers \Magento\Backend\Block\Widget\Grid\Massaction::getItemsJson - * @covers \Magento\Backend\Block\Widget\Grid\Massaction::isAvailable - */ public function testMassactionDefaultValues() { + $this->loadLayout(); + /** @var $blockEmpty \Magento\Backend\Block\Widget\Grid\Massaction */ - $blockEmpty = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\View\LayoutInterface::class - )->createBlock( - \Magento\Backend\Block\Widget\Grid\Massaction::class - ); + $blockEmpty = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\View\LayoutInterface::class) + ->createBlock(\Magento\Backend\Block\Widget\Grid\Massaction::class); $this->assertEmpty($blockEmpty->getItems()); $this->assertEquals(0, $blockEmpty->getCount()); $this->assertSame('[]', $blockEmpty->getItemsJson()); @@ -71,6 +89,8 @@ class MassactionTest extends \PHPUnit_Framework_TestCase public function testGetJavaScript() { + $this->loadLayout(); + $javascript = $this->_block->getJavaScript(); $expectedItemFirst = '#"option_id1":{"label":"Option One",' . @@ -86,6 +106,8 @@ class MassactionTest extends \PHPUnit_Framework_TestCase public function testGetJavaScriptWithAddedItem() { + $this->loadLayout(); + $input = [ 'id' => 'option_id3', 'label' => 'Option Three', @@ -100,20 +122,49 @@ class MassactionTest extends \PHPUnit_Framework_TestCase $this->assertRegExp($expected, $this->_block->getJavaScript()); } - public function testGetCount() + /** + * @param string $mageMode + * @param int $expectedCount + * @dataProvider getCountDataProvider + */ + public function testGetCount($mageMode, $expectedCount) { - $this->assertEquals(2, $this->_block->getCount()); + $this->loadLayout($mageMode); + $this->assertEquals($expectedCount, $this->_block->getCount()); + } + + /** + * @return array + */ + public function getCountDataProvider() + { + return [ + [ + 'mageMode' => State::MODE_DEVELOPER, + 'expectedCount' => 3, + ], + [ + 'mageMode' => State::MODE_DEFAULT, + 'expectedCount' => 3, + ], + [ + 'mageMode' => State::MODE_PRODUCTION, + 'expectedCount' => 2, + ], + ]; } /** - * @param $itemId - * @param $expectedItem + * @param string $itemId + * @param array $expectedItem * @dataProvider getItemsDataProvider */ public function testGetItems($itemId, $expectedItem) { + $this->loadLayout(); + $items = $this->_block->getItems(); - $this->assertCount(2, $items); + $this->assertCount(3, $items); $this->assertArrayHasKey($itemId, $items); $actualItem = $items[$itemId]; @@ -149,19 +200,29 @@ class MassactionTest extends \PHPUnit_Framework_TestCase 'selected' => false, 'blockname' => '' ] + ], + [ + 'option_id3', + [ + 'id' => 'option_id3', + 'label' => 'Option Three', + 'url' => '#http:\/\/localhost\/index\.php\/(?:key\/([\w\d]+)\/)?#', + 'selected' => false, + 'blockname' => '' + ] ] ]; } public function testGridContainsMassactionColumn() { + $this->loadLayout(); $this->_layout->getBlock('admin.test.grid')->toHtml(); - $gridMassactionColumn = $this->_layout->getBlock( - 'admin.test.grid' - )->getColumnSet()->getChildBlock( - 'massaction' - ); + $gridMassactionColumn = $this->_layout->getBlock('admin.test.grid') + ->getColumnSet() + ->getChildBlock('massaction'); + $this->assertNotNull($gridMassactionColumn, 'Massaction column does not exist in the grid column set'); $this->assertInstanceOf( \Magento\Backend\Block\Widget\Grid\Column::class, diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml index 5f9a80a5a3dbda9a86915c99aefce1066074ffb6..c072532a1c27c3471602abbb2442611fa49c6a59 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml @@ -6,60 +6,68 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <block class="Magento\Backend\Block\Widget\Grid" name="admin.test.grid" Output="1"> + <block class="Magento\Backend\Block\Widget\Grid" name="admin.test.grid"> <arguments> - <dataSource type="object">Magento\Framework\Data\Collection</dataSource> + <argument name="dataSource" xsi:type="object">Magento\Framework\Data\Collection</argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="admin.test.grid.columnSet" Output="1"> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="product_name" Output="1"> + <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="admin.test.grid.columnSet"> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="product_name"> <arguments> - <header>Product name 1</header> - <index>product_name</index> - <type>text</type> + <argument name="header" xsi:type="string" translate="true">Product name 1</argument> + <argument name="id" xsi:type="string">product_name</argument> + <argument name="index" xsi:type="string">product_name</argument> + <argument name="type" xsi:type="string">text</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="description" output="1"> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="description"> <arguments> - <header>User Description</header> - <index>description</index> - <type>text</type> + <argument name="header" xsi:type="string" translate="true">User Description</argument> + <argument name="id" xsi:type="string">description</argument> + <argument name="index" xsi:type="string">description</argument> + <argument name="type" xsi:type="string">text</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="qty" output="1"> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="qty"> <arguments> - <header>Qty</header> - <index>qty</index> - <type>number</type> - <width>60px</width> + <argument name="header" xsi:type="string" translate="true">Qty</argument> + <argument name="id" xsi:type="string">qty</argument> + <argument name="index" xsi:type="string">qty</argument> + <argument name="type" xsi:type="string">number</argument> + <argument name="width" xsi:type="string">60</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="added_at" output="1"> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="added_at"> <arguments> - <header>Date Added</header> - <index>added_at</index> - <gmtoffset>1</gmtoffset> - <type>date</type> + <argument name="header" xsi:type="string" translate="true">Date Added</argument> + <argument name="id" xsi:type="string">added_at</argument> + <argument name="index" xsi:type="string">added_at</argument> + <argument name="type" xsi:type="string">date</argument> + <argument name="gmtoffset" xsi:type="string">1</argument> </arguments> </block> </block> - <block class="Magento\Backend\Block\Widget\Grid\Massaction" as="grid.massaction" name='admin.test.grid.massaction' output="1"> + <block class="Magento\Backend\Block\Widget\Grid\Massaction" as="grid.massaction" name='admin.test.grid.massaction'> <arguments> - <massaction_id_field>test_id</massaction_id_field> - <massaction_id_filter>test_id</massaction_id_filter> - <form_field_name>test</form_field_name> - <use_select_all>1</use_select_all> - <options> - <option_id1> - <label>Option One</label> - <url>*/*/option1</url> - <complete>Test</complete> - </option_id1> - <option_id2> - <label>Option Two</label> - <url>*/*/option2</url> - <confirm>Are you sure?</confirm> - </option_id2> - </options> + <argument name="massaction_id_field" xsi:type="string">test_id</argument> + <argument name="form_field_name" xsi:type="string">test_id</argument> + <argument name="use_select_all" xsi:type="string">1</argument> + <argument name="options" xsi:type="array"> + <item name="option_id1" xsi:type="array"> + <item name="label" xsi:type="string" translate="true">Option One</item> + <item name="url" xsi:type="string">*/*/option1</item> + <item name="complete" xsi:type="string">Test</item> + </item> + <item name="option_id2" xsi:type="array"> + <item name="label" xsi:type="string" translate="true">Option Two</item> + <item name="url" xsi:type="string">*/*/option2</item> + <item name="confirm" xsi:type="string">Are you sure?</item> + </item> + <item name="option_id3" xsi:type="array"> + <item name="label" xsi:type="string" translate="true">Option Three</item> + <item name="url" xsi:type="string">*/*/option3</item> + <item name="visible" xsi:type="object">Magento\Backend\Block\Cache\Grid\Massaction\ProductionModeVisibilityChecker</item> + </item> + </argument> </arguments> </block> </block> diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php index e9fbb76f513d545eb4d710423bfd58a0cbb3d03e..a1034643ae3dcd6064caea87cf13f052db967f0f 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php @@ -3,13 +3,13 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Backend\Controller\Adminhtml\Cache; use Magento\Framework\App\Cache\State; use Magento\TestFramework\Helper\Bootstrap; use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\TestFramework\App\State as AppState; class MassActionTest extends \Magento\TestFramework\TestCase\AbstractBackendController { @@ -20,6 +20,11 @@ class MassActionTest extends \Magento\TestFramework\TestCase\AbstractBackendCont */ private static $typesConfig; + /** + * @var string + */ + private $mageState; + public static function setUpBeforeClass() { /** @var \Magento\Framework\App\DeploymentConfig $config */ @@ -27,8 +32,15 @@ class MassActionTest extends \Magento\TestFramework\TestCase\AbstractBackendCont self::$typesConfig = $config->get(State::CACHE_KEY); } + protected function setUp() + { + parent::setUp(); + $this->mageState = Bootstrap::getObjectManager()->get(AppState::class)->getMode(); + } + protected function tearDown() { + Bootstrap::getObjectManager()->get(AppState::class)->setMode($this->mageState); /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */ $cacheState = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Cache\StateInterface::class); foreach (self::$typesConfig as $type => $value) { @@ -42,7 +54,7 @@ class MassActionTest extends \Magento\TestFramework\TestCase\AbstractBackendCont * @dataProvider massActionsDataProvider * @param array $typesToEnable */ - public function testMassEnableAction($typesToEnable = []) + public function testMassEnableActionDeveloperMode($typesToEnable = []) { $this->setAll(false); @@ -53,16 +65,33 @@ class MassActionTest extends \Magento\TestFramework\TestCase\AbstractBackendCont if (in_array($cacheType, $typesToEnable)) { $this->assertEquals(1, $cacheState, "Type '{$cacheType}' has not been enabled"); } else { - $this->assertEquals(0, $cacheState, "Type '{$cacheType}' has not been enabled"); + $this->assertEquals(0, $cacheState, "Type '{$cacheType}' must remain disabled"); } } } + /** + * @dataProvider massActionsDataProvider + * @param array $typesToEnable + */ + public function testMassEnableActionProductionMode($typesToEnable = []) + { + Bootstrap::getObjectManager()->get(AppState::class)->setMode(AppState::MODE_PRODUCTION); + $this->setAll(false); + + $this->getRequest()->setParams(['types' => $typesToEnable]); + $this->dispatch('backend/admin/cache/massEnable'); + + foreach ($this->getCacheStates() as $cacheType => $cacheState) { + $this->assertEquals(0, $cacheState, "Type '{$cacheType}' must remain disabled"); + } + } + /** * @dataProvider massActionsDataProvider * @param array $typesToDisable */ - public function testMassDisableAction($typesToDisable = []) + public function testMassDisableActionDeveloperMode($typesToDisable = []) { $this->setAll(true); @@ -78,6 +107,23 @@ class MassActionTest extends \Magento\TestFramework\TestCase\AbstractBackendCont } } + /** + * @dataProvider massActionsDataProvider + * @param array $typesToDisable + */ + public function testMassDisableActionProductionMode($typesToDisable = []) + { + Bootstrap::getObjectManager()->get(AppState::class)->setMode(AppState::MODE_PRODUCTION); + $this->setAll(true); + + $this->getRequest()->setParams(['types' => $typesToDisable]); + $this->dispatch('backend/admin/cache/massDisable'); + + foreach ($this->getCacheStates() as $cacheType => $cacheState) { + $this->assertEquals(1, $cacheState, "Type '{$cacheType}' must remain enabled"); + } + } + /** * Retrieve cache states (enabled/disabled) information * diff --git a/dev/tests/integration/testsuite/Magento/Config/Model/Config/Processor/EnvironmentPlaceholderTest.php b/dev/tests/integration/testsuite/Magento/Config/Model/Config/Processor/EnvironmentPlaceholderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1e2b6aacc931446cee8f42accb17d684c4bb413c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Config/Model/Config/Processor/EnvironmentPlaceholderTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Config\Model\Config\Processor; + +use Magento\Framework\ObjectManagerInterface; + +class EnvironmentPlaceholderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @var EnvironmentPlaceholder + */ + private $model; + + /** + * @var array + */ + private $env = []; + + protected function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->model = $this->objectManager->get(EnvironmentPlaceholder::class); + $this->env = $_ENV; + } + + public function testProcess() + { + $_ENV = array_merge( + $_ENV, + [ + 'CONFIG__DEFAULT__WEB__UNSECURE__BASE_URL' => 'http://expected.local', + 'CONFIG__TEST__TEST__DESIGN__HEADER__WELCOME' => 'Expected header', + 'TEST__TEST__WEB__SECURE__BASE_URL' => 'http://wrong_pattern.local', + 'CONFIG__DEFAULT__GENERAL__REGION__DISPLAY_ALL' => 1 + ] + ); + $expected = [ + 'default' => [ + 'web' => [ + 'unsecure' => [ + 'base_url' => 'http://expected.local' + ], + 'secure' => [ + 'base_url' => 'https://original.local' + ] + ], + 'general' => [ + 'region' => [ + 'display_all' => 1 + ], + ], + ], + 'test' => [ + 'test' => [ + 'design' => [ + 'header' => [ + 'welcome' => 'Expected header' + ] + ], + ], + ] + ]; + $config = [ + 'default' => [ + 'web' => [ + 'unsecure' => [ + 'base_url' => 'http://original.local', + ], + 'secure' => [ + 'base_url' => 'https://original.local' + ] + ] + ], + 'test' => [ + 'test' => [ + 'design' => [ + 'header' => [ + 'welcome' => 'Original header' + ] + ], + ], + ] + ]; + + $this->assertSame( + $expected, + $this->model->process($config) + ); + } + + protected function tearDown() + { + $_ENV = $this->env; + } +} diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php index 5db97cc36614924ae915b7b924b2c7a1f575e344..2e339e4347cf65ad13474de26ba61c3237cfafe9 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php @@ -67,4 +67,40 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->getFirstItem(); $this->assertEquals(20, $configurableProduct->getMinimalPrice()); } + + /** + * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + */ + public function testGetProductFinalPriceIfOneOfChildIsDisabledPerStore() + { + /** @var Collection $collection */ + $collection = Bootstrap::getObjectManager()->get(CollectionFactory::class) + ->create(); + $configurableProduct = $collection + ->addIdFilter([1]) + ->addMinimalPrice() + ->load() + ->getFirstItem(); + $this->assertEquals(10, $configurableProduct->getMinimalPrice()); + + $childProduct = $this->productRepository->getById(10, false, null, true); + $childProduct->setStatus(Status::STATUS_DISABLED); + + // update in default store scope + $currentStoreId = $this->storeManager->getStore()->getId(); + $defaultStore = $this->storeManager->getDefaultStoreView(); + $this->storeManager->setCurrentStore($defaultStore->getId()); + $this->productRepository->save($childProduct); + $this->storeManager->setCurrentStore($currentStoreId); + + /** @var Collection $collection */ + $collection = Bootstrap::getObjectManager()->get(CollectionFactory::class) + ->create(); + $configurableProduct = $collection + ->addIdFilter([1]) + ->addMinimalPrice() + ->load() + ->getFirstItem(); + $this->assertEquals(20, $configurableProduct->getMinimalPrice()); + } } diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php index 50787c7962412b0611edf093825563061da67119..58df9f50f7f0c10a8750c1fdf31c68561b6fdb87 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php @@ -68,6 +68,38 @@ class LowestPriceOptionProviderTest extends \PHPUnit_Framework_TestCase $this->assertEquals(20, $lowestPriceChildrenProduct->getPrice()); } + /** + * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + */ + public function testGetProductsIfOneOfChildIsDisabledPerStore() + { + $configurableProduct = $this->productRepository->getById(1, false, null, true); + $lowestPriceChildrenProducts = $this->lowestPriceOptionsProvider->getProducts($configurableProduct); + $this->assertCount(1, $lowestPriceChildrenProducts); + $lowestPriceChildrenProduct = reset($lowestPriceChildrenProducts); + $this->assertEquals(10, $lowestPriceChildrenProduct->getPrice()); + + // load full aggregation root + $lowestPriceChildProduct = $this->productRepository->get( + $lowestPriceChildrenProduct->getSku(), + false, + null, + true + ); + $lowestPriceChildProduct->setStatus(Status::STATUS_DISABLED); + // update in default store scope + $currentStoreId = $this->storeManager->getStore()->getId(); + $defaultStore = $this->storeManager->getDefaultStoreView(); + $this->storeManager->setCurrentStore($defaultStore->getId()); + $this->productRepository->save($lowestPriceChildProduct); + $this->storeManager->setCurrentStore($currentStoreId); + + $lowestPriceChildrenProducts = $this->lowestPriceOptionsProvider->getProducts($configurableProduct); + $this->assertCount(1, $lowestPriceChildrenProducts); + $lowestPriceChildrenProduct = reset($lowestPriceChildrenProducts); + $this->assertEquals(20, $lowestPriceChildrenProduct->getPrice()); + } + /** * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php */ diff --git a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php index a229b64bb7dd10ef29acd5e824dfb5a9b28bfcc8..170d186e20af812a1c40bc4937559c6d5342942a 100644 --- a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php @@ -7,7 +7,6 @@ namespace Magento\Deploy\Console\Command\App; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\App\ObjectManager; use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\ObjectManagerInterface; @@ -18,37 +17,73 @@ use Symfony\Component\Console\Output\OutputInterface; class ApplicationDumpCommandTest extends \PHPUnit_Framework_TestCase { /** - * @var ApplicationDumpCommand + * @var ObjectManagerInterface */ - private $command; + private $objectManager; /** - * @var ObjectManagerInterface + * @var DeploymentConfig\Reader */ - private $objectManager; + private $reader; public function setUp() { - $this->command = Bootstrap::getObjectManager()->get(ApplicationDumpCommand::class); $this->objectManager = Bootstrap::getObjectManager(); + $this->reader = $this->objectManager->get(DeploymentConfig\Reader::class); } + /** + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/Deploy/_files/config_data.php + */ public function testExecute() { - $inputMock = $this->getMock(InputInterface::class); + $this->objectManager->configure([ + \Magento\Config\Model\Config\Export\ExcludeList::class => [ + 'arguments' => [ + 'configs' => [ + 'web/test/test_value_1' => '', + 'web/test/test_value_2' => '', + 'web/test/test_sensitive' => '1', + ], + ], + ], + ]); + + $comment = 'The configuration file doesn\'t contain sensitive data for security reasons. ' + . 'Sensitive data can be stored in the following environment variables:' + . "\nCONFIG__DEFAULT__WEB__TEST__TEST_SENSITIVE for web/test/test_sensitive"; $outputMock = $this->getMock(OutputInterface::class); - $outputMock->expects($this->once()) + $outputMock->expects($this->at(0)) + ->method('writeln') + ->with(['system' => $comment]); + $outputMock->expects($this->at(1)) ->method('writeln') ->with('<info>Done.</info>'); - $this->assertEquals(0, $this->command->run($inputMock, $outputMock)); + + /** @var ApplicationDumpCommand command */ + $command = $this->objectManager->create(ApplicationDumpCommand::class); + $command->run($this->getMock(InputInterface::class), $outputMock); + + $config = $this->reader->loadConfigFile(ConfigFilePool::APP_CONFIG, $this->getFileName()); + + $this->assertArrayHasKey( + 'test_value_1', + $config['system']['default']['web']['test'] + ); + $this->assertArrayHasKey( + 'test_value_2', + $config['system']['default']['web']['test'] + ); + $this->assertArrayNotHasKey( + 'test_sensitive', + $config['system']['default']['web']['test'] + ); } public function tearDown() { - /** @var ConfigFilePool $configFilePool */ - $configFilePool = $this->objectManager->get(ConfigFilePool::class); - $filePool = $configFilePool->getInitialFilePools(); - $file = $filePool[ConfigFilePool::LOCAL][ConfigFilePool::APP_CONFIG]; + $file = $this->getFileName(); /** @var DirectoryList $dirList */ $dirList = $this->objectManager->get(DirectoryList::class); $path = $dirList->getPath(DirectoryList::CONFIG); @@ -61,4 +96,16 @@ class ApplicationDumpCommandTest extends \PHPUnit_Framework_TestCase $deploymentConfig = $this->objectManager->get(DeploymentConfig::class); $deploymentConfig->resetData(); } + + /** + * @return string + */ + private function getFileName() + { + /** @var ConfigFilePool $configFilePool */ + $configFilePool = $this->objectManager->get(ConfigFilePool::class); + $filePool = $configFilePool->getInitialFilePools(); + + return $filePool[ConfigFilePool::LOCAL][ConfigFilePool::APP_CONFIG]; + } } diff --git a/dev/tests/integration/testsuite/Magento/Deploy/_files/config_data.php b/dev/tests/integration/testsuite/Magento/Deploy/_files/config_data.php new file mode 100644 index 0000000000000000000000000000000000000000..bd8e69262e1e03f98b3ce41735bbf2264e234292 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Deploy/_files/config_data.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +$configData = [ + 'default' => [ + '' => [ + 'web/test/test_value_1' => 'http://local2.test/', + 'web/test/test_value_2' => 5, + 'web/test/test_sensitive' => 10, + ] + ], +]; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$configFactory = $objectManager->create(\Magento\Config\Model\Config\Factory::class); + +foreach ($configData as $scope => $data) { + foreach ($data as $scopeCode => $scopeData) { + foreach ($scopeData as $path => $value) { + $config = $configFactory->create(); + $config->setCope($scope); + + if ($scopeCode) { + $config->setScopeCode($scopeCode); + } + + $config->setDataByPath($path, $value); + $config->save(); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php index c64500fa6cfec3aed4a33cbcbc262befa1621d5c..c2bc02893e042de06cce4023d943110a693aeeca 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php @@ -34,7 +34,7 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase /** * Verify that an order placed with an existing customer can re-use the customer addresses. * - * @magentoDataFixture Magento/Paypal/_files/quote_payment_express_with_customer.php + * @magentoDataFixture Magento/Paypal/_files/quote_express_with_customer.php * @magentoAppIsolation enabled * @magentoDbIsolation enabled */ @@ -74,7 +74,7 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase /** * Verify that after placing the order, addresses are associated with the order and the quote is a guest quote. * - * @magentoDataFixture Magento/Paypal/_files/quote_payment_express.php + * @magentoDataFixture Magento/Paypal/_files/quote_express.php * @magentoAppIsolation enabled * @magentoDbIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express.php new file mode 100644 index 0000000000000000000000000000000000000000..0be18cdcaf9e42e2beb792596d0819b3c7a46182 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express.php @@ -0,0 +1,95 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Framework\App\Config\MutableScopeConfigInterface::class +)->setValue( + 'carriers/flatrate/active', + 1, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE +); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Framework\App\Config\MutableScopeConfigInterface::class +)->setValue( + 'payment/paypal_express/active', + 1, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE +); +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +/** @var $product \Magento\Catalog\Model\Product */ +$product = $objectManager->create(\Magento\Catalog\Model\Product::class); +$product->setTypeId('simple') + ->setId(1) + ->setAttributeSetId(4) + ->setName('Simple Product') + ->setSku('simple') + ->setPrice(10) + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData( + [ + 'qty' => 100, + 'is_in_stock' => 1, + ] + )->save(); +$product->load(1); + +$billingData = [ + 'firstname' => 'testname', + 'lastname' => 'lastname', + 'company' => '', + 'email' => 'test@com.com', + 'street' => [ + 0 => 'test1', + 1 => '', + ], + 'city' => 'Test', + 'region_id' => '1', + 'region' => '', + 'postcode' => '9001', + 'country_id' => 'US', + 'telephone' => '11111111', + 'fax' => '', + 'confirm_password' => '', + 'save_in_address_book' => '1', + 'use_for_shipping' => '1', +]; + +$billingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Quote\Model\Quote\Address::class, ['data' => $billingData]); +$billingAddress->setAddressType('billing'); + +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); +$shippingAddress->setShippingMethod('flatrate_flatrate'); +$shippingAddress->setCollectShippingRates(true); + +/** @var $quote \Magento\Quote\Model\Quote */ +$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); +$quote->setCustomerIsGuest( + true +)->setStoreId( + $objectManager->get( + \Magento\Store\Model\StoreManagerInterface::class + )->getStore()->getId() +)->setReservedOrderId( + '100000002' +)->setBillingAddress( + $billingAddress +)->setShippingAddress( + $shippingAddress +)->addProduct( + $product, + 10 +); +$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); +$quote->getShippingAddress()->setCollectShippingRates(true); +$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS); + +$quoteRepository = $objectManager->get(\Magento\Quote\Api\CartRepositoryInterface::class); +$quoteRepository->save($quote); +$quote = $quoteRepository->get($quote->getId()); +$quote->setCustomerEmail('admin@example.com'); diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express_with_customer.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express_with_customer.php new file mode 100644 index 0000000000000000000000000000000000000000..c319e298d1e50d56cdc886dd789d6c36941e8a4e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express_with_customer.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +require __DIR__ . '/../../Customer/_files/customer.php'; +require __DIR__ . '/../../Customer/_files/customer_two_addresses.php'; + +\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +$objectManager->get( + \Magento\Framework\App\Config\MutableScopeConfigInterface::class +)->setValue('carriers/flatrate/active', 1, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); +$objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class) + ->setValue('payment/paypal_express/active', 1, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + +/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */ +$customerRepository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); +$customer = $customerRepository->getById(1); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = $objectManager->create(\Magento\Catalog\Model\Product::class); +$product->setTypeId('simple') + ->setId(1) + ->setAttributeSetId(4) + ->setName('Simple Product') + ->setSku('simple') + ->setPrice(10) + ->setStockData([ + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 100, + ]) + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->save(); +$product->load(1); + +$customerBillingAddress = $objectManager->create(\Magento\Customer\Model\Address::class); +$customerBillingAddress->load(1); +$billingAddressDataObject = $customerBillingAddress->getDataModel(); +$billingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class); +$billingAddress->importCustomerAddressData($billingAddressDataObject); +$billingAddress->setAddressType('billing'); + +/** @var \Magento\Customer\Model\Address $customerShippingAddress */ +$customerShippingAddress = $objectManager->create(\Magento\Customer\Model\Address::class); +$customerShippingAddress->load(2); +$shippingAddressDataObject = $customerShippingAddress->getDataModel(); +$shippingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class); +$shippingAddress->importCustomerAddressData($shippingAddressDataObject); +$shippingAddress->setAddressType('shipping'); + +$shippingAddress->setShippingMethod('flatrate_flatrate'); +$shippingAddress->setCollectShippingRates(true); + +/** @var $quote \Magento\Quote\Model\Quote */ +$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); +$quote->setCustomerIsGuest(false) + ->setCustomerId($customer->getId()) + ->setCustomer($customer) + ->setStoreId($objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId()) + ->setReservedOrderId('test02') + ->setBillingAddress($billingAddress) + ->setShippingAddress($shippingAddress) + ->addProduct($product, 10); +$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); +$quote->getShippingAddress()->setCollectShippingRates(true); +$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS); + +/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class); +$quoteRepository->save($quote); +$quote = $quoteRepository->get($quote->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php index fa234cc444a0730a580d35400483c0f2ee92e416..90f1102e0ec7639910c83dd76d37d0b0e36eef25 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php @@ -3,96 +3,7 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ -\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\App\Config\MutableScopeConfigInterface::class -)->setValue( - 'carriers/flatrate/active', - 1, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE -); -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\App\Config\MutableScopeConfigInterface::class -)->setValue( - 'payment/paypal_express/active', - 1, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE -); -$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -/** @var $product \Magento\Catalog\Model\Product */ -$product = $objectManager->create(\Magento\Catalog\Model\Product::class); -$product->setTypeId('simple') - ->setId(1) - ->setAttributeSetId(4) - ->setName('Simple Product') - ->setSku('simple') - ->setPrice(10) - ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) - ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) - ->setStockData( - [ - 'qty' => 100, - 'is_in_stock' => 1, - ] - )->save(); -$product->load(1); - -$billingData = [ - 'firstname' => 'testname', - 'lastname' => 'lastname', - 'company' => '', - 'email' => 'test@com.com', - 'street' => [ - 0 => 'test1', - 1 => '', - ], - 'city' => 'Test', - 'region_id' => '1', - 'region' => '', - 'postcode' => '9001', - 'country_id' => 'US', - 'telephone' => '11111111', - 'fax' => '', - 'confirm_password' => '', - 'save_in_address_book' => '1', - 'use_for_shipping' => '1', -]; - -$billingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\Quote\Model\Quote\Address::class, ['data' => $billingData]); -$billingAddress->setAddressType('billing'); - -$shippingAddress = clone $billingAddress; -$shippingAddress->setId(null)->setAddressType('shipping'); -$shippingAddress->setShippingMethod('flatrate_flatrate'); -$shippingAddress->setCollectShippingRates(true); - -/** @var $quote \Magento\Quote\Model\Quote */ -$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); -$quote->setCustomerIsGuest( - true -)->setStoreId( - $objectManager->get( - \Magento\Store\Model\StoreManagerInterface::class - )->getStore()->getId() -)->setReservedOrderId( - '100000002' -)->setBillingAddress( - $billingAddress -)->setShippingAddress( - $shippingAddress -)->addProduct( - $product, - 10 -); -$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); -$quote->getShippingAddress()->setCollectShippingRates(true); -$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS); - -$quoteRepository = $objectManager->get(\Magento\Quote\Api\CartRepositoryInterface::class); -$quoteRepository->save($quote); -$quote = $quoteRepository->get($quote->getId()); -$quote->setCustomerEmail('admin@example.com'); +require __DIR__ . '/quote_express.php'; /** @var $service \Magento\Quote\Api\CartManagementInterface */ $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php index 1c6793f05dea95644067521332900cc647a3648e..eaf444be13367f8769d28e34245c007122b79bf1 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php @@ -3,79 +3,7 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ - -require __DIR__ . '/../../Customer/_files/customer.php'; -require __DIR__ . '/../../Customer/_files/customer_two_addresses.php'; - -\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('adminhtml'); - -$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - -$objectManager->get( - \Magento\Framework\App\Config\MutableScopeConfigInterface::class -)->setValue('carriers/flatrate/active', 1, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); -$objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class) - ->setValue('payment/paypal_express/active', 1, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); - -/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */ -$customerRepository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class); -$customer = $customerRepository->getById(1); - -/** @var $product \Magento\Catalog\Model\Product */ -$product = $objectManager->create(\Magento\Catalog\Model\Product::class); -$product->setTypeId('simple') - ->setId(1) - ->setAttributeSetId(4) - ->setName('Simple Product') - ->setSku('simple') - ->setPrice(10) - ->setStockData([ - 'use_config_manage_stock' => 1, - 'qty' => 100, - 'is_qty_decimal' => 0, - 'is_in_stock' => 100, -]) - ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) - ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) - ->save(); -$product->load(1); - -$customerBillingAddress = $objectManager->create(\Magento\Customer\Model\Address::class); -$customerBillingAddress->load(1); -$billingAddressDataObject = $customerBillingAddress->getDataModel(); -$billingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class); -$billingAddress->importCustomerAddressData($billingAddressDataObject); -$billingAddress->setAddressType('billing'); - -/** @var \Magento\Customer\Model\Address $customerShippingAddress */ -$customerShippingAddress = $objectManager->create(\Magento\Customer\Model\Address::class); -$customerShippingAddress->load(2); -$shippingAddressDataObject = $customerShippingAddress->getDataModel(); -$shippingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class); -$shippingAddress->importCustomerAddressData($shippingAddressDataObject); -$shippingAddress->setAddressType('shipping'); - -$shippingAddress->setShippingMethod('flatrate_flatrate'); -$shippingAddress->setCollectShippingRates(true); - -/** @var $quote \Magento\Quote\Model\Quote */ -$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); -$quote->setCustomerIsGuest(false) - ->setCustomerId($customer->getId()) - ->setCustomer($customer) - ->setStoreId($objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId()) - ->setReservedOrderId('test02') - ->setBillingAddress($billingAddress) - ->setShippingAddress($shippingAddress) - ->addProduct($product, 10); -$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); -$quote->getShippingAddress()->setCollectShippingRates(true); -$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS_EXPRESS); - -/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */ -$quoteRepository = $objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class); -$quoteRepository->save($quote); -$quote = $quoteRepository->get($quote->getId()); +require __DIR__ . '/quote_express_with_customer.php'; /** @var $service \Magento\Quote\Api\CartManagementInterface */ $service = $objectManager->create(\Magento\Quote\Api\CartManagementInterface::class); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php index 037069e8fd2ca551a216a1e3fe349e1793aa8768..6c4bc5f52c0c06b08f44f2a70554fd3d11c9bca7 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ObserverImplementationTest.php @@ -22,29 +22,6 @@ class ObserverImplementationTest extends \PHPUnit_Framework_TestCase */ protected static $observerClasses = []; - /** - * @var array - */ - protected static $blackList = [ - // not support of virtual types - 'SalesOrderIndexGridAsyncInsertObserver', - 'SalesInvoiceIndexGridAsyncInsertObserver', - 'SalesShipmentIndexGridAsyncInsertObserver', - 'SalesCreditmemoIndexGridAsyncInsertObserver', - 'SalesOrderIndexGridSyncInsert', - 'SalesInvoiceIndexGridSyncInsert', - 'SalesShipmentIndexGridSyncInsert', - 'SalesCreditmemoIndexGridSyncInsert', - 'SalesOrderIndexGridSyncRemove', - 'SalesInvoiceIndexGridSyncRemove', - 'SalesShipmentIndexGridSyncRemove', - 'SalesCreditmemoIndexGridSyncRemove', - 'SalesOrderSendEmailsObserver', - 'SalesOrderInvoiceSendEmailsObserver', - 'SalesOrderShipmentSendEmailsObserver', - 'SalesOrderCreditmemoSendEmailsObserver', - ]; - public static function setUpBeforeClass() { self::$observerClasses = array_merge( @@ -116,9 +93,18 @@ class ObserverImplementationTest extends \PHPUnit_Framework_TestCase } } } + + $blacklistFiles = str_replace('\\', '/', realpath(__DIR__)) . '/_files/blacklist/observers*.txt'; + $blacklistExceptions = []; + foreach (glob($blacklistFiles) as $fileName) { + $blacklistExceptions = array_merge( + $blacklistExceptions, + file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) + ); + } return array_diff( array_unique($observerClasses), - self::$blackList + $blacklistExceptions ); } } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/observers.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/observers.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e9b19322cb09773f161b0e502ed7d84e7826a7e --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/observers.txt @@ -0,0 +1,16 @@ +SalesOrderIndexGridAsyncInsertObserver +SalesInvoiceIndexGridAsyncInsertObserver +SalesShipmentIndexGridAsyncInsertObserver +SalesCreditmemoIndexGridAsyncInsertObserver +SalesOrderIndexGridSyncInsert +SalesInvoiceIndexGridSyncInsert +SalesShipmentIndexGridSyncInsert +SalesCreditmemoIndexGridSyncInsert +SalesOrderIndexGridSyncRemove +SalesInvoiceIndexGridSyncRemove +SalesShipmentIndexGridSyncRemove +SalesCreditmemoIndexGridSyncRemove +SalesOrderSendEmailsObserver +SalesOrderInvoiceSendEmailsObserver +SalesOrderShipmentSendEmailsObserver +SalesOrderCreditmemoSendEmailsObserver diff --git a/lib/internal/Magento/Framework/App/Config/CommentInterface.php b/lib/internal/Magento/Framework/App/Config/CommentInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..902d63668f368912208ed38c9d19ebb985af8b31 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Config/CommentInterface.php @@ -0,0 +1,21 @@ +<?php +/** + * Provide access to data. Each Source can be responsible for each storage, where config data can be placed + * + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config; + +/** + * Interface CommentInterface + */ +interface CommentInterface +{ + /** + * Retrieve comment for configuration data. + * + * @return string + */ + public function get(); +} diff --git a/lib/internal/Magento/Framework/App/Config/PreProcessorComposite.php b/lib/internal/Magento/Framework/App/Config/PreProcessorComposite.php new file mode 100644 index 0000000000000000000000000000000000000000..10c355d290dfc43f818fa3799ad8b46807d7e6cd --- /dev/null +++ b/lib/internal/Magento/Framework/App/Config/PreProcessorComposite.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config; + +use Magento\Framework\App\Config\Spi\PreProcessorInterface; + +/** + * Class PreProcessorComposite + */ +class PreProcessorComposite implements PreProcessorInterface +{ + /** + * @var PreProcessorInterface[] + */ + private $processors = []; + + /** + * @param PreProcessorInterface[] $processors + */ + public function __construct(array $processors = []) + { + $this->processors = $processors; + } + + /** + * @inheritdoc + */ + public function process(array $config) + { + /** @var PreProcessorInterface $processor */ + foreach ($this->processors as $processor) { + $config = $processor->process($config); + } + + return $config; + } +} diff --git a/lib/internal/Magento/Framework/App/Config/Spi/PreProcessorInterface.php b/lib/internal/Magento/Framework/App/Config/Spi/PreProcessorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..1be0783d7f7deb9ec393a40eff2e2d0df3197281 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Config/Spi/PreProcessorInterface.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Config\Spi; + +/** + * Allows to use custom callbacks and functions before applying fallback + */ +interface PreProcessorInterface +{ + /** + * Pre-processing of config + * + * @param array $config + * @return array + */ + public function process(array $config); +} diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php index a1635fc4b2670d3749adbc8ac7bb88bab31904cf..d5a224d1b50b221d0afcf7c6127325d702c5217d 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php @@ -149,7 +149,9 @@ class Reader foreach ($initialFilePools as $initialFiles) { if (isset($initialFiles[$fileKey]) && $fileDriver->isExists($path . '/' . $initialFiles[$fileKey])) { $fileBuffer = include $path . '/' . $initialFiles[$fileKey]; - $result = array_replace_recursive($result, $fileBuffer); + if (is_array($fileBuffer)) { + $result = array_replace_recursive($result, $fileBuffer); + } } } } @@ -159,6 +161,13 @@ class Reader $result = array_replace_recursive($result, $fileBuffer); } + if ($fileDriver->isExists($path . '/' . $pathConfig)) { + $configResult = include $path . '/' . $pathConfig; + if (is_array($configResult)) { + $result = array_replace_recursive($result, $configResult); + } + } + return $result; } diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php index 6cead0305a6c6ada899060a2a7debdbfe71f6f1a..2d8e7a14aaf55519d33376f1ee09f80b9b46cec6 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php @@ -94,10 +94,11 @@ class Writer * @param array $data * @param bool $override * @param string $pool + * @param array $comments * @return void * @throws FileSystemException */ - public function saveConfig(array $data, $override = false, $pool = null) + public function saveConfig(array $data, $override = false, $pool = null, array $comments = []) { foreach ($data as $fileKey => $config) { $paths = $pool ? $this->configFilePool->getPathsByPool($pool) : $this->configFilePool->getPaths(); @@ -112,7 +113,7 @@ class Writer } } - $contents = $this->formatter->format($config); + $contents = $this->formatter->format($config, $comments); try { $writeFilePath = $paths[$fileKey]; $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile($writeFilePath, $contents); diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/FormatterInterface.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/FormatterInterface.php index 24e31074501f3aae16a12bed0473ccfd43d45ac0..640bcb61d2031abd4d671e6f02de0636b252b16d 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/FormatterInterface.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/FormatterInterface.php @@ -12,7 +12,8 @@ interface FormatterInterface * Format deployment configuration * * @param array $data + * @param array $comments * @return string */ - public function format($data); + public function format($data, array $comments = []); } diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php index 1ab99358cef1adacff5dc2dabc1ea884885e5d95..91bd906e3ca4d83438188e3131ba5e9537af939c 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php @@ -12,10 +12,26 @@ namespace Magento\Framework\App\DeploymentConfig\Writer; class PhpFormatter implements FormatterInterface { /** + * Format deployment configuration. + * If $comments is present, each item will be added + * as comment to the corresponding section + * * {@inheritdoc} */ - public function format($data) + public function format($data, array $comments = []) { + if (!empty($comments) && is_array($data)) { + $elements = []; + foreach ($data as $key => $value) { + $comment = ' '; + if (!empty($comments[$key])) { + $comment = " /**\n * " . str_replace("\n", "\n * ", var_export($comments[$key], true)) . "\n */\n"; + } + $space = is_array($value) ? " \n" : ' '; + $elements[] = $comment . var_export($key, true) . ' =>' . $space . var_export($value, true); + } + return "<?php\nreturn array (\n" . implode(",\n", str_replace("\n", "\n ", $elements)) . "\n);\n"; + } return "<?php\nreturn " . var_export($data, true) . ";\n"; } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/PreProcessorCompositeTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/PreProcessorCompositeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..291bef1266134f7956919a2c831af4a7fd4715e2 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/PreProcessorCompositeTest.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\App\Test\Unit\Config; + +use Magento\Framework\App\Config\PreProcessorComposite; +use Magento\Framework\App\Config\Spi\PreProcessorInterface; + +class PreProcessorCompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PreProcessorComposite + */ + private $model; + + /** + * @var PreProcessorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $preProcessorMock; + + protected function setUp() + { + $this->preProcessorMock = $this->getMockBuilder(PreProcessorInterface::class) + ->getMockForAbstractClass(); + + $this->model = new PreProcessorComposite([$this->preProcessorMock]); + } + + public function testProcess() + { + $this->preProcessorMock->expects($this->once()) + ->method('process') + ->with(['test' => 'data']) + ->willReturn(['test' => 'data2']); + + $this->assertSame(['test' => 'data2'], $this->model->process(['test' => 'data'])); + } +} diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/Writer/PhpFormatterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/Writer/PhpFormatterTest.php index a9b5bc04a12768f8de76e5cdc514e226fb4af05b..2ab8b209272f1cc882c14fb1a2dd9a15c22605f4 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/Writer/PhpFormatterTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/Writer/PhpFormatterTest.php @@ -10,10 +10,128 @@ use \Magento\Framework\App\DeploymentConfig\Writer\PhpFormatter; class PhpFormatterTest extends \PHPUnit_Framework_TestCase { - public function testFormat() + /** + * @dataProvider formatWithCommentDataProvider + * @param string|array $data + * @param array $comments + * @param string $expectedResult + */ + public function testFormat($data, $comments, $expectedResult) { $formatter = new PhpFormatter(); - $data = 'test'; - $this->assertEquals("<?php\nreturn 'test';\n", $formatter->format($data)); + $this->assertEquals($expectedResult, $formatter->format($data, $comments)); + } + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function formatWithCommentDataProvider() + { + $array = [ + 'ns1' => [ + 's1' => [ + 's11', + 's12' + ], + 's2' => [ + 's21', + 's22' + ], + ], + 'ns2' => [ + 's1' => [ + 's11' + ], + ], + 'ns3' => 'just text', + 'ns4' => 'just text' + ]; + $comments1 = ['ns2' => 'comment for namespace 2']; + $comments2 = [ + 'ns1' => 'comment for namespace 1', + 'ns2' => "comment for namespace 2.\nNext comment for namespace 2", + 'ns3' => 'comment for namespace 3', + 'ns4' => 'comment for namespace 4', + 'ns5' => 'comment for unexisted namespace 5', + ]; + $expectedResult1 = <<<TEXT +<?php +return array ( + 'ns1' => + array ( + 's1' => + array ( + 0 => 's11', + 1 => 's12', + ), + 's2' => + array ( + 0 => 's21', + 1 => 's22', + ), + ), + /** + * 'comment for namespace 2' + */ + 'ns2' => + array ( + 's1' => + array ( + 0 => 's11', + ), + ), + 'ns3' => 'just text', + 'ns4' => 'just text' +); + +TEXT; + $expectedResult2 = <<<TEXT +<?php +return array ( + /** + * 'comment for namespace 1' + */ + 'ns1' => + array ( + 's1' => + array ( + 0 => 's11', + 1 => 's12', + ), + 's2' => + array ( + 0 => 's21', + 1 => 's22', + ), + ), + /** + * 'comment for namespace 2. + * Next comment for namespace 2' + */ + 'ns2' => + array ( + 's1' => + array ( + 0 => 's11', + ), + ), + /** + * 'comment for namespace 3' + */ + 'ns3' => 'just text', + /** + * 'comment for namespace 4' + */ + 'ns4' => 'just text' +); + +TEXT; + return [ + ['string', [], "<?php\nreturn 'string';\n"], + ['string', ['comment'], "<?php\nreturn 'string';\n"], + [$array, [], "<?php\nreturn " . var_export($array, true) . ";\n"], + [$array, $comments1, $expectedResult1], + [$array, $comments2, $expectedResult2], + ]; } } diff --git a/lib/internal/Magento/Framework/Crontab/CrontabManager.php b/lib/internal/Magento/Framework/Crontab/CrontabManager.php new file mode 100644 index 0000000000000000000000000000000000000000..2b597b8eb638fb21af887ab7b47490f5533fafae --- /dev/null +++ b/lib/internal/Magento/Framework/Crontab/CrontabManager.php @@ -0,0 +1,199 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Crontab; + +use Magento\Framework\ShellInterface; +use Magento\Framework\Phrase; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Filesystem; +use Magento\Framework\App\Filesystem\DirectoryList; + +/** + * Manager works with cron tasks + */ +class CrontabManager implements CrontabManagerInterface +{ + /** + * @var ShellInterface + */ + private $shell; + + /** + * @var Filesystem + */ + private $filesystem; + + /** + * @param ShellInterface $shell + * @param Filesystem $filesystem + */ + public function __construct( + ShellInterface $shell, + Filesystem $filesystem + ) { + $this->shell = $shell; + $this->filesystem = $filesystem; + } + + /** + * {@inheritdoc} + */ + public function getTasks() + { + $this->checkSupportedOs(); + $content = $this->getCrontabContent(); + $pattern = '!(' . self::TASKS_BLOCK_START . ')(.*?)(' . self::TASKS_BLOCK_END . ')!s'; + + if (preg_match($pattern, $content, $matches)) { + $tasks = trim($matches[2], PHP_EOL); + $tasks = explode(PHP_EOL, $tasks); + return $tasks; + } + + return []; + } + + /** + * {@inheritdoc} + */ + public function saveTasks(array $tasks) + { + $this->checkSupportedOs(); + $baseDir = $this->filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath(); + $logDir = $this->filesystem->getDirectoryRead(DirectoryList::LOG)->getAbsolutePath(); + + if (!$tasks) { + throw new LocalizedException(new Phrase('List of tasks is empty')); + } + + foreach ($tasks as $key => $task) { + if (empty($task['expression'])) { + $tasks[$key]['expression'] = '* * * * *'; + } + + if (empty($task['command'])) { + throw new LocalizedException(new Phrase('Command should not be empty')); + } + + $tasks[$key]['command'] = str_replace( + ['{magentoRoot}', '{magentoLog}'], + [$baseDir, $logDir], + $task['command'] + ); + } + + $content = $this->getCrontabContent(); + $content = $this->cleanMagentoSection($content); + $content = $this->generateSection($content, $tasks); + + $this->save($content); + } + + /** + * {@inheritdoc} + * @throws LocalizedException + */ + public function removeTasks() + { + $this->checkSupportedOs(); + $content = $this->getCrontabContent(); + $content = $this->cleanMagentoSection($content); + $this->save($content); + } + + /** + * Generate Magento Tasks Section + * + * @param string $content + * @param array $tasks + * @return string + */ + private function generateSection($content, $tasks = []) + { + if ($tasks) { + $content .= self::TASKS_BLOCK_START . PHP_EOL; + foreach ($tasks as $task) { + $content .= $task['expression'] . ' ' . PHP_BINARY . ' '. $task['command'] . PHP_EOL; + } + $content .= self::TASKS_BLOCK_END . PHP_EOL; + } + + return $content; + } + + /** + * Clean Magento Tasks Section in crontab content + * + * @param string $content + * @return string + */ + private function cleanMagentoSection($content) + { + $content = preg_replace( + '!' . preg_quote(self::TASKS_BLOCK_START) . '.*?' . preg_quote(self::TASKS_BLOCK_END . PHP_EOL) . '!s', + '', + $content + ); + + return $content; + } + + /** + * Get crontab content without Magento Tasks Section + * + * In case of some exceptions the empty content is returned + * + * @return string + */ + private function getCrontabContent() + { + try { + $content = (string)$this->shell->execute('crontab -l'); + } catch (LocalizedException $e) { + return ''; + } + + return $content; + } + + /** + * Save crontab + * + * @param string $content + * @return void + * @throws LocalizedException + */ + private function save($content) + { + $content = str_replace('%', '%%', $content); + + try { + $this->shell->execute('echo "' . $content . '" | crontab -'); + } catch (LocalizedException $e) { + throw new LocalizedException( + new Phrase('Error during saving of crontab: %1', [$e->getPrevious()->getMessage()]), + $e + ); + } + } + + /** + * Check that OS is supported + * + * If OS is not supported then no possibility to work with crontab + * + * @return void + * @throws LocalizedException + */ + private function checkSupportedOs() + { + if (stripos(PHP_OS, 'WIN') === 0) { + throw new LocalizedException( + new Phrase('Your operation system is not supported to work with this command') + ); + } + } +} diff --git a/lib/internal/Magento/Framework/Crontab/CrontabManagerInterface.php b/lib/internal/Magento/Framework/Crontab/CrontabManagerInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..c00ab41d8b873a46dc27abbb1af37a23b7e7fd86 --- /dev/null +++ b/lib/internal/Magento/Framework/Crontab/CrontabManagerInterface.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Crontab; + +use Magento\Framework\Exception\LocalizedException; + +interface CrontabManagerInterface +{ + /**#@+ + * Constants for wrapping Magento section in crontab + */ + const TASKS_BLOCK_START = '#~ MAGENTO START'; + const TASKS_BLOCK_END = '#~ MAGENTO END'; + /**#@-*/ + + /** + * Get list of Magento Tasks + * + * @return array + * @throws LocalizedException + */ + public function getTasks(); + + /** + * Save Magento Tasks to crontab + * + * @param array $tasks + * @return void + * @throws LocalizedException + */ + public function saveTasks(array $tasks); + + /** + * Remove Magento Tasks form crontab + * + * @return void + * @throws LocalizedException + */ + public function removeTasks(); +} diff --git a/lib/internal/Magento/Framework/Crontab/README.md b/lib/internal/Magento/Framework/Crontab/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bfbf194715dc8f9f359137ecb79be5a1adbd5c5e --- /dev/null +++ b/lib/internal/Magento/Framework/Crontab/README.md @@ -0,0 +1,12 @@ +Library for working with crontab + +The library has the next interfaces: +* CrontabManagerInterface +* TasksProviderInterface + +*CrontabManagerInterface* provides working with crontab: +* *getTasks* - get list of Magento cron tasks from crontab +* *saveTasks* - save Magento cron tasks to crontab +* *removeTasks* - remove Magento cron tasks from crontab + +*TasksProviderInterface* has only one method *getTasks*. This interface provides transportation the list of tasks from DI \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Crontab/TasksProvider.php b/lib/internal/Magento/Framework/Crontab/TasksProvider.php new file mode 100644 index 0000000000000000000000000000000000000000..94524fd2bbd19b4395a8ba36daaa0f43c2b6c648 --- /dev/null +++ b/lib/internal/Magento/Framework/Crontab/TasksProvider.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Crontab; + +/** + * TasksProvider collects list of tasks + */ +class TasksProvider implements TasksProviderInterface +{ + /** + * @var array + */ + private $tasks = []; + + /** + * @param array $tasks + */ + public function __construct(array $tasks = []) + { + $this->tasks = $tasks; + } + + /** + * {@inheritdoc} + */ + public function getTasks() + { + return $this->tasks; + } +} diff --git a/lib/internal/Magento/Framework/Crontab/TasksProviderInterface.php b/lib/internal/Magento/Framework/Crontab/TasksProviderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..bb02c30797be4cbf015c5858ac1c88825bde54a7 --- /dev/null +++ b/lib/internal/Magento/Framework/Crontab/TasksProviderInterface.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Crontab; + +interface TasksProviderInterface +{ + /** + * Get list of tasks + * + * @return array + */ + public function getTasks(); +} diff --git a/lib/internal/Magento/Framework/Crontab/Test/Unit/CrontabManagerTest.php b/lib/internal/Magento/Framework/Crontab/Test/Unit/CrontabManagerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7cafd386c629a4b48350d5ca4937b58fd49da4b6 --- /dev/null +++ b/lib/internal/Magento/Framework/Crontab/Test/Unit/CrontabManagerTest.php @@ -0,0 +1,333 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Crontab\Test\Unit; + +use Magento\Framework\Crontab\CrontabManager; +use Magento\Framework\Crontab\CrontabManagerInterface; +use Magento\Framework\ShellInterface; +use Magento\Framework\Phrase; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Filesystem; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem\Directory\ReadInterface; +use Magento\Framework\Filesystem\DriverPool; + +class CrontabManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ShellInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $shellMock; + + /** + * @var Filesystem|\PHPUnit_Framework_MockObject_MockObject + */ + private $filesystemMock; + + /** + * @var CrontabManager + */ + private $crontabManager; + + /** + * @return void + */ + protected function setUp() + { + $this->shellMock = $this->getMockBuilder(ShellInterface::class) + ->getMockForAbstractClass(); + $this->filesystemMock = $this->getMockBuilder(Filesystem::class) + ->disableOriginalClone() + ->disableOriginalConstructor() + ->getMock(); + + $this->crontabManager = new CrontabManager($this->shellMock, $this->filesystemMock); + } + + /** + * @return void + */ + public function testGetTasksNoCrontab() + { + $exception = new \Exception('crontab: no crontab for user'); + $localizedException = new LocalizedException(new Phrase('Some error'), $exception); + + $this->shellMock->expects($this->once()) + ->method('execute') + ->with('crontab -l', []) + ->willThrowException($localizedException); + + $this->assertEquals([], $this->crontabManager->getTasks()); + } + + /** + * @param string $content + * @param array $tasks + * @return void + * @dataProvider getTasksDataProvider + */ + public function testGetTasks($content, $tasks) + { + $this->shellMock->expects($this->once()) + ->method('execute') + ->with('crontab -l', []) + ->willReturn($content); + + $this->assertEquals($tasks, $this->crontabManager->getTasks()); + } + + /** + * @return array + */ + public function getTasksDataProvider() + { + return [ + [ + 'content' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL, + 'tasks' => ['* * * * * /bin/php /var/www/magento/bin/magento cron:run'], + ], + [ + 'content' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL + . '* * * * * /bin/php /var/www/magento/bin/magento setup:cron:run' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL, + 'tasks' => [ + '* * * * * /bin/php /var/www/magento/bin/magento cron:run', + '* * * * * /bin/php /var/www/magento/bin/magento setup:cron:run', + ], + ], + [ + 'content' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL, + 'tasks' => [], + ], + [ + 'content' => '', + 'tasks' => [], + ], + ]; + } + + /** + * @return void + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Shell error + */ + public function testRemoveTasksWithException() + { + $exception = new \Exception('Shell error'); + $localizedException = new LocalizedException(new Phrase('Some error'), $exception); + + $this->shellMock->expects($this->at(0)) + ->method('execute') + ->with('crontab -l', []) + ->willReturn(''); + + $this->shellMock->expects($this->at(1)) + ->method('execute') + ->with('echo "" | crontab -', []) + ->willThrowException($localizedException); + + $this->crontabManager->removeTasks(); + } + + /** + * @param string $contentBefore + * @param string $contentAfter + * @return void + * @dataProvider removeTasksDataProvider + */ + public function testRemoveTasks($contentBefore, $contentAfter) + { + $this->shellMock->expects($this->at(0)) + ->method('execute') + ->with('crontab -l', []) + ->willReturn($contentBefore); + + $this->shellMock->expects($this->at(1)) + ->method('execute') + ->with('echo "' . $contentAfter . '" | crontab -', []); + + $this->crontabManager->removeTasks(); + } + + /** + * @return array + */ + public function removeTasksDataProvider() + { + return [ + [ + 'contentBefore' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL, + 'contentAfter' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + ], + [ + 'contentBefore' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL + . '* * * * * /bin/php /var/www/magento/bin/magento setup:cron:run' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL, + 'contentAfter' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + ], + [ + 'contentBefore' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL, + 'contentAfter' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + ], + [ + 'contentBefore' => '', + 'contentAfter' => '' + ], + ]; + } + + /** + * @return void + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage List of tasks is empty + */ + public function testSaveTasksWithEmptyTasksList() + { + $baseDirMock = $this->getMockBuilder(ReadInterface::class) + ->getMockForAbstractClass(); + $baseDirMock->expects($this->once()) + ->method('getAbsolutePath') + ->willReturn('/var/www/magento2/'); + $logDirMock = $this->getMockBuilder(ReadInterface::class) + ->getMockForAbstractClass(); + $logDirMock->expects($this->once()) + ->method('getAbsolutePath') + ->willReturn('/var/www/magento2/var/log/'); + + $this->filesystemMock->expects($this->any()) + ->method('getDirectoryRead') + ->willReturnMap([ + [DirectoryList::ROOT, DriverPool::FILE, $baseDirMock], + [DirectoryList::LOG, DriverPool::FILE, $logDirMock], + ]); + + $this->crontabManager->saveTasks([]); + } + + /** + * @return void + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Command should not be empty + */ + public function testSaveTasksWithoutCommand() + { + $baseDirMock = $this->getMockBuilder(ReadInterface::class) + ->getMockForAbstractClass(); + $baseDirMock->expects($this->once()) + ->method('getAbsolutePath') + ->willReturn('/var/www/magento2/'); + $logDirMock = $this->getMockBuilder(ReadInterface::class) + ->getMockForAbstractClass(); + $logDirMock->expects($this->once()) + ->method('getAbsolutePath') + ->willReturn('/var/www/magento2/var/log/'); + + $this->filesystemMock->expects($this->any()) + ->method('getDirectoryRead') + ->willReturnMap([ + [DirectoryList::ROOT, DriverPool::FILE, $baseDirMock], + [DirectoryList::LOG, DriverPool::FILE, $logDirMock], + ]); + + $this->crontabManager->saveTasks([ + 'myCron' => ['expression' => '* * * * *'] + ]); + } + + /** + * @param array $tasks + * @param string $content + * @param string $contentToSave + * @return void + * @dataProvider saveTasksDataProvider + */ + public function testSaveTasks($tasks, $content, $contentToSave) + { + $baseDirMock = $this->getMockBuilder(ReadInterface::class) + ->getMockForAbstractClass(); + $baseDirMock->expects($this->once()) + ->method('getAbsolutePath') + ->willReturn('/var/www/magento2/'); + $logDirMock = $this->getMockBuilder(ReadInterface::class) + ->getMockForAbstractClass(); + $logDirMock->expects($this->once()) + ->method('getAbsolutePath') + ->willReturn('/var/www/magento2/var/log/'); + + $this->filesystemMock->expects($this->any()) + ->method('getDirectoryRead') + ->willReturnMap([ + [DirectoryList::ROOT, DriverPool::FILE, $baseDirMock], + [DirectoryList::LOG, DriverPool::FILE, $logDirMock], + ]); + + $this->shellMock->expects($this->at(0)) + ->method('execute') + ->with('crontab -l', []) + ->willReturn($content); + + $this->shellMock->expects($this->at(1)) + ->method('execute') + ->with('echo "' . $contentToSave . '" | crontab -', []); + + $this->crontabManager->saveTasks($tasks); + } + + /** + * @return array + */ + public function saveTasksDataProvider() + { + $content = '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL; + + return [ + [ + 'tasks' => [ + ['expression' => '* * * * *', 'command' => 'run.php'] + ], + 'content' => $content, + 'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '* * * * * ' . PHP_BINARY . ' run.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL, + ], + [ + 'tasks' => [ + ['expression' => '1 2 3 4 5', 'command' => 'run.php'] + ], + 'content' => $content, + 'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '1 2 3 4 5 ' . PHP_BINARY . ' run.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL, + ], + [ + 'tasks' => [ + ['command' => '{magentoRoot}run.php >> {magentoLog}cron.log'] + ], + 'content' => $content, + 'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL + . '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php >>' + . ' /var/www/magento2/var/log/cron.log' . PHP_EOL + . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL, + ], + ]; + } +} diff --git a/lib/internal/Magento/Framework/Crontab/Test/Unit/TasksProviderTest.php b/lib/internal/Magento/Framework/Crontab/Test/Unit/TasksProviderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..80be47cda5ef4973ad1999968dd636da0bd1757a --- /dev/null +++ b/lib/internal/Magento/Framework/Crontab/Test/Unit/TasksProviderTest.php @@ -0,0 +1,34 @@ +<?php + +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Crontab\Test\Unit; + +use Magento\Framework\Crontab\TasksProvider; + +class TasksProviderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @return void + */ + public function testTasksProviderEmpty() + { + /** @var $tasksProvider $tasksProvider */ + $tasksProvider = new TasksProvider(); + $this->assertSame([], $tasksProvider->getTasks()); + } + + public function testTasksProvider() + { + $tasks = [ + 'magentoCron' => ['expressin' => '* * * * *', 'command' => 'bin/magento cron:run'], + 'magentoSetup' => ['command' => 'bin/magento setup:cron:run'], + ]; + + /** @var $tasksProvider $tasksProvider */ + $tasksProvider = new TasksProvider($tasks); + $this->assertSame($tasks, $tasksProvider->getTasks()); + } +} diff --git a/lib/internal/Magento/Framework/Data/CollectionDataSourceInterface.php b/lib/internal/Magento/Framework/Data/CollectionDataSourceInterface.php index eeff60c1f61c887ef87439b680e8d73fbf6791f2..4bdf29fd1c8fc167af98cc79fd1d20c9696c7b50 100644 --- a/lib/internal/Magento/Framework/Data/CollectionDataSourceInterface.php +++ b/lib/internal/Magento/Framework/Data/CollectionDataSourceInterface.php @@ -5,9 +5,11 @@ */ namespace Magento\Framework\Data; +use Magento\Framework\View\Element\Block\ArgumentInterface; + /** * Interface CollectionDataSourceInterface */ -interface CollectionDataSourceInterface +interface CollectionDataSourceInterface extends ArgumentInterface { } diff --git a/lib/internal/Magento/Framework/View/Element/Block/ArgumentInterface.php b/lib/internal/Magento/Framework/View/Element/Block/ArgumentInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..123a75946ba775c0e1565e7689201fde8f8c9f0b --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/Block/ArgumentInterface.php @@ -0,0 +1,14 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\View\Element\Block; + +/** + * Block argument interface. + * All objects that are injected to block arguments should implement this interface. + */ +interface ArgumentInterface +{ +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php index a8f2374cc0ce11efd32b7c6e0419db5c3a799086..8de579730b154035d02b38fbdb8d07ef3315d194 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php @@ -34,16 +34,11 @@ class ObjectTest extends \PHPUnit_Framework_TestCase public function testEvaluate() { - $input = ['value' => self::EXPECTED_CLASS]; - $this->_objectManager->expects( - $this->once() - )->method( - 'create' - )->with( - self::EXPECTED_CLASS - )->will( - $this->returnValue($this) - ); + $input = ['name' => 'dataSource', 'value' => self::EXPECTED_CLASS]; + $this->_objectManager->expects($this->once()) + ->method('create') + ->with(self::EXPECTED_CLASS) + ->willReturn($this); $actual = $this->_model->evaluate($input); $this->assertSame($this, $actual); @@ -56,17 +51,18 @@ class ObjectTest extends \PHPUnit_Framework_TestCase { $this->setExpectedException($expectedException, $expectedExceptionMessage); $self = $this; - $this->_objectManager->expects($this->any())->method('create')->will( - $this->returnCallback( - function ($className) use ($self) { - return $self->getMock($className); - } - ) + $this->_objectManager->expects($this->any())->method('create')->willReturnCallback( + function ($className) use ($self) { + return $self->getMock($className); + } ); $this->_model->evaluate($input); } + /** + * @return array + */ public function evaluateWrongClassDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Module/I18n/Dictionary/Writer/Csv.php b/setup/src/Magento/Setup/Module/I18n/Dictionary/Writer/Csv.php index d28c3161903a2e6e762988709a01e0af3c1029f5..10490b6565534001a451ffc2d997ae120a420adf 100644 --- a/setup/src/Magento/Setup/Module/I18n/Dictionary/Writer/Csv.php +++ b/setup/src/Magento/Setup/Module/I18n/Dictionary/Writer/Csv.php @@ -54,9 +54,19 @@ class Csv implements WriterInterface * Close file handler * * @return void + * + * @deprecated */ public function __destructor() { fclose($this->_fileHandler); } + + /** + * Destructor for closing file handler + */ + public function __destruct() + { + fclose($this->_fileHandler); + } }