From 5d0681ddfd1b9f1c800b539eac32d95c4f4fbb1d Mon Sep 17 00:00:00 2001 From: Maksym Iakusha Date: Mon, 3 Aug 2015 17:05:34 +0300 Subject: [PATCH 01/12] MAGETWO-31445: Problem with "title" when ordering multiple downloadable products --- .../Sales/Items/Column/Downloadable/Name.php | 14 ++++++++------ .../Sales/Order/Email/Items/Downloadable.php | 16 +++++++++------- .../Order/Email/Items/Order/Downloadable.php | 14 ++++++++------ .../Sales/Order/Item/Renderer/Downloadable.php | 14 ++++++++------ 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php b/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php index f2724cdfbd8c6..5b2edf12c8f4b 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php @@ -8,7 +8,9 @@ namespace Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable; +use Magento\Downloadable\Model\Link; use Magento\Downloadable\Model\Link\Purchased; +use Magento\Store\Model\ScopeInterface; /** * Sales Order downloadable items name column renderer @@ -61,8 +63,8 @@ public function __construct( public function getLinks() { $this->_purchased = $this->_purchasedFactory->create()->load( - $this->getItem()->getOrder()->getId(), - 'order_id' + $this->getItem()->getId(), + 'order_item_id' ); $purchasedItem = $this->_itemsFactory->create()->addFieldToFilter('order_item_id', $this->getItem()->getId()); $this->_purchased->setPurchasedItems($purchasedItem); @@ -74,9 +76,9 @@ public function getLinks() */ public function getLinksTitle() { - if ($this->_purchased && $this->_purchased->getLinkSectionTitle()) { - return $this->_purchased->getLinkSectionTitle(); - } - return $this->_scopeConfig->getValue(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->getLinks()->getLinkSectionTitle() ?: $this->_scopeConfig->getValue( + Link::XML_PATH_LINKS_TITLE, + ScopeInterface::SCOPE_STORE + ); } } diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php index 80c7998839e1f..8084494aeddfc 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php @@ -8,8 +8,10 @@ namespace Magento\Downloadable\Block\Sales\Order\Email\Items; +use Magento\Downloadable\Model\Link; use Magento\Downloadable\Model\Link\Purchased; use Magento\Downloadable\Model\Link\Purchased\Item; +use Magento\Store\Model\ScopeInterface; /** * Downlaodable Sales Order Email items renderer @@ -63,12 +65,12 @@ public function __construct( public function getLinks() { $this->_purchased = $this->_purchasedFactory->create()->load( - $this->getItem()->getOrder()->getId(), - 'order_id' + $this->getItem()->getId(), + 'order_item_id' ); $purchasedLinks = $this->_itemsFactory->create()->addFieldToFilter( 'order_item_id', - $this->getItem()->getOrderItem()->getId() + $this->getItem()->getId() ); $this->_purchased->setPurchasedItems($purchasedLinks); @@ -80,10 +82,10 @@ public function getLinks() */ public function getLinksTitle() { - if ($this->_purchased->getLinkSectionTitle()) { - return $this->_purchased->getLinkSectionTitle(); - } - return $this->_scopeConfig->getValue(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->getLinks()->getLinkSectionTitle() ?: $this->_scopeConfig->getValue( + Link::XML_PATH_LINKS_TITLE, + ScopeInterface::SCOPE_STORE + ); } /** diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php index 2def86d9c63e0..03f6daf5856c0 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php @@ -8,7 +8,9 @@ namespace Magento\Downloadable\Block\Sales\Order\Email\Items\Order; +use Magento\Downloadable\Model\Link; use Magento\Downloadable\Model\Link\Purchased\Item; +use Magento\Store\Model\ScopeInterface; /** * Downloadable Sales Order Email items renderer @@ -57,8 +59,8 @@ public function __construct( public function getLinks() { $this->_purchased = $this->_purchasedFactory->create()->load( - $this->getItem()->getOrder()->getId(), - 'order_id' + $this->getItem()->getId(), + 'order_item_id' ); $purchasedLinks = $this->_itemsFactory->create()->addFieldToFilter('order_item_id', $this->getItem()->getId()); $this->_purchased->setPurchasedItems($purchasedLinks); @@ -71,10 +73,10 @@ public function getLinks() */ public function getLinksTitle() { - if ($this->_purchased->getLinkSectionTitle()) { - return $this->_purchased->getLinkSectionTitle(); - } - return $this->_scopeConfig->getValue(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->getLinks()->getLinkSectionTitle() ?: $this->_scopeConfig->getValue( + Link::XML_PATH_LINKS_TITLE, + ScopeInterface::SCOPE_STORE + ); } /** diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php index 7176465cae443..591acd3196059 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php @@ -8,7 +8,9 @@ namespace Magento\Downloadable\Block\Sales\Order\Item\Renderer; +use Magento\Downloadable\Model\Link; use Magento\Downloadable\Model\Link\Purchased; +use Magento\Store\Model\ScopeInterface; /** * Downloadable order item render block @@ -57,8 +59,8 @@ public function __construct( public function getLinks() { $this->_purchasedLinks = $this->_purchasedFactory->create()->load( - $this->getOrderItem()->getOrder()->getId(), - 'order_id' + $this->getOrderItem()->getId(), + 'order_item_id' ); $purchasedItems = $this->_itemsFactory->create()->addFieldToFilter( 'order_item_id', @@ -74,9 +76,9 @@ public function getLinks() */ public function getLinksTitle() { - if ($this->_purchasedLinks->getLinkSectionTitle()) { - return $this->_purchasedLinks->getLinkSectionTitle(); - } - return $this->_scopeConfig->getValue(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->getLinks()->getLinkSectionTitle() ?: $this->_scopeConfig->getValue( + Link::XML_PATH_LINKS_TITLE, + ScopeInterface::SCOPE_STORE + ); } } From ef5a4fe41b0c50fe1e342c7b777adb13953b8748 Mon Sep 17 00:00:00 2001 From: Maksym Iakusha Date: Mon, 3 Aug 2015 18:23:58 +0300 Subject: [PATCH 02/12] MAGETWO-31445: Problem with "title" when ordering multiple downloadable products --- .../Items/Column/Downloadable/NameTest.php | 93 +++++++++++++++++++ .../Order/Email/Items/DownloadableTest.php | 83 +++++++++++++++++ .../Email/Items/Order/DownloadableTest.php | 83 +++++++++++++++++ .../Order/Item/Renderer/DownloadableTest.php | 83 +++++++++++++++++ 4 files changed, 342 insertions(+) create mode 100644 app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php create mode 100644 app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php create mode 100644 app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php create mode 100644 app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php new file mode 100644 index 0000000000000..7496cc5ee1b64 --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php @@ -0,0 +1,93 @@ +getMockBuilder('Magento\Backend\Block\Template\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->purchasedFactory = $this->getMockBuilder('Magento\Downloadable\Model\Link\PurchasedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->itemsFactory = $this->getMockBuilder( + 'Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory' + ) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->block = $objectManager->getObject( + 'Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name', + [ + 'context' => $contextMock, + 'purchasedFactory' => $this->purchasedFactory, + 'itemsFactory' => $this->itemsFactory + ] + ); + } + + public function testGetLinks() + { + $item = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + $linkPurchased = $this->getMockBuilder('Magento\Downloadable\Model\Link\Purchased') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $itemCollection = $this->getMockBuilder('Magento\Downloadable\Model\Resource\Link\Purchased\Item\Collection') + ->disableOriginalConstructor() + ->setMethods(['addFieldToFilter']) + ->getMock(); + + $this->block->setData('item', $item); + $this->purchasedFactory->expects($this->once())->method('create')->willReturn($linkPurchased); + $linkPurchased->expects($this->once())->method('load')->with('itemId', 'order_item_id')->willReturnSelf(); + $item->expects($this->any())->method('getId')->willReturn('itemId'); + $this->itemsFactory->expects($this->once())->method('create')->willReturn($itemCollection); + $itemCollection->expects($this->once()) + ->method('addFieldToFilter') + ->with('order_item_id', 'itemId') + ->willReturnSelf(); + + $this->assertEquals($linkPurchased, $this->block->getLinks()); + } +} diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php new file mode 100644 index 0000000000000..5e0f7ae7507ec --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php @@ -0,0 +1,83 @@ +getMockBuilder('Magento\Backend\Block\Template\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->purchasedFactory = $this->getMockBuilder('Magento\Downloadable\Model\Link\PurchasedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->itemsFactory = $this->getMockBuilder( + 'Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory' + ) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->block = $objectManager->getObject( + 'Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable', + [ + 'context' => $contextMock, + 'purchasedFactory' => $this->purchasedFactory, + 'itemsFactory' => $this->itemsFactory + ] + ); + } + + public function testGetLinks() + { + $item = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + $linkPurchased = $this->getMockBuilder('Magento\Downloadable\Model\Link\Purchased') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $itemCollection = $this->getMockBuilder('Magento\Downloadable\Model\Resource\Link\Purchased\Item\Collection') + ->disableOriginalConstructor() + ->setMethods(['addFieldToFilter']) + ->getMock(); + + $this->block->setData('item', $item); + $this->purchasedFactory->expects($this->once())->method('create')->willReturn($linkPurchased); + $linkPurchased->expects($this->once())->method('load')->with('itemId', 'order_item_id')->willReturnSelf(); + $item->expects($this->any())->method('getId')->willReturn('itemId'); + $this->itemsFactory->expects($this->once())->method('create')->willReturn($itemCollection); + $itemCollection->expects($this->once()) + ->method('addFieldToFilter') + ->with('order_item_id', 'itemId') + ->willReturnSelf(); + + $this->assertEquals($linkPurchased, $this->block->getLinks()); + } +} diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php new file mode 100644 index 0000000000000..e48dda83ea68a --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php @@ -0,0 +1,83 @@ +getMockBuilder('Magento\Backend\Block\Template\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->purchasedFactory = $this->getMockBuilder('Magento\Downloadable\Model\Link\PurchasedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->itemsFactory = $this->getMockBuilder( + 'Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory' + ) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->block = $objectManager->getObject( + 'Magento\Downloadable\Block\Sales\Order\Email\Items\Order\Downloadable', + [ + 'context' => $contextMock, + 'purchasedFactory' => $this->purchasedFactory, + 'itemsFactory' => $this->itemsFactory + ] + ); + } + + public function testGetLinks() + { + $item = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + $linkPurchased = $this->getMockBuilder('Magento\Downloadable\Model\Link\Purchased') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $itemCollection = $this->getMockBuilder('Magento\Downloadable\Model\Resource\Link\Purchased\Item\Collection') + ->disableOriginalConstructor() + ->setMethods(['addFieldToFilter']) + ->getMock(); + + $this->block->setData('item', $item); + $this->purchasedFactory->expects($this->once())->method('create')->willReturn($linkPurchased); + $linkPurchased->expects($this->once())->method('load')->with('itemId', 'order_item_id')->willReturnSelf(); + $item->expects($this->any())->method('getId')->willReturn('itemId'); + $this->itemsFactory->expects($this->once())->method('create')->willReturn($itemCollection); + $itemCollection->expects($this->once()) + ->method('addFieldToFilter') + ->with('order_item_id', 'itemId') + ->willReturnSelf(); + + $this->assertEquals($linkPurchased, $this->block->getLinks()); + } +} diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php new file mode 100644 index 0000000000000..f2d13113a81b4 --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php @@ -0,0 +1,83 @@ +getMockBuilder('Magento\Backend\Block\Template\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->purchasedFactory = $this->getMockBuilder('Magento\Downloadable\Model\Link\PurchasedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->itemsFactory = $this->getMockBuilder( + 'Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory' + ) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->block = $objectManager->getObject( + 'Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable', + [ + 'context' => $contextMock, + 'purchasedFactory' => $this->purchasedFactory, + 'itemsFactory' => $this->itemsFactory + ] + ); + } + + public function testGetLinks() + { + $item = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + $linkPurchased = $this->getMockBuilder('Magento\Downloadable\Model\Link\Purchased') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $itemCollection = $this->getMockBuilder('Magento\Downloadable\Model\Resource\Link\Purchased\Item\Collection') + ->disableOriginalConstructor() + ->setMethods(['addFieldToFilter']) + ->getMock(); + + $this->block->setData('item', $item); + $this->purchasedFactory->expects($this->once())->method('create')->willReturn($linkPurchased); + $linkPurchased->expects($this->once())->method('load')->with('itemId', 'order_item_id')->willReturnSelf(); + $item->expects($this->any())->method('getId')->willReturn('itemId'); + $this->itemsFactory->expects($this->once())->method('create')->willReturn($itemCollection); + $itemCollection->expects($this->once()) + ->method('addFieldToFilter') + ->with('order_item_id', 'itemId') + ->willReturnSelf(); + + $this->assertEquals($linkPurchased, $this->block->getLinks()); + } +} From a61ff28eea5a4793acf5c92276082429db060c5c Mon Sep 17 00:00:00 2001 From: Maksym Iakusha Date: Mon, 3 Aug 2015 18:25:40 +0300 Subject: [PATCH 03/12] MAGETWO-31445: Problem with "title" when ordering multiple downloadable products --- .../Sales/Items/Column/Downloadable/NameTest.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php index 7496cc5ee1b64..2e81086d765cb 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php @@ -25,16 +25,6 @@ class NameTest extends \PHPUnit_Framework_TestCase * @var \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $itemsFactory; -// -// /** -// * @var \Magento\Framework\View\LayoutInterface | \PHPUnit_Framework_MockObject_MockObject -// */ -// protected $layout; -// -// /** -// * @var \Magento\Framework\Json\EncoderInterface | \PHPUnit_Framework_MockObject_MockObject -// */ -// protected $jsonEncoder; public function setUp() { From 0511a1367c63dfc00ca783d218debe81f77d44c3 Mon Sep 17 00:00:00 2001 From: Maksym Iakusha Date: Mon, 3 Aug 2015 18:33:48 +0300 Subject: [PATCH 04/12] MAGETWO-31445: Problem with "title" when ordering multiple downloadable products --- .../Adminhtml/Sales/Items/Column/Downloadable/NameTest.php | 4 +++- .../Unit/Block/Sales/Order/Email/Items/DownloadableTest.php | 4 +++- .../Block/Sales/Order/Email/Items/Order/DownloadableTest.php | 4 +++- .../Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php index 2e81086d765cb..c5641d1dd9669 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php @@ -6,6 +6,8 @@ namespace Magento\Downloadable\Test\Unit\Block\Adminhtml\Sales\Items\Column\Downloadable; +use Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory; + /** * Tests Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name */ @@ -22,7 +24,7 @@ class NameTest extends \PHPUnit_Framework_TestCase protected $purchasedFactory; /** - * @var \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $itemsFactory; diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php index 5e0f7ae7507ec..d5826f3ab8620 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php @@ -6,6 +6,8 @@ namespace Magento\Downloadable\Test\Unit\Block\Sales\Order\Email\Items; +use Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory; + /** * Tests Magento\Downloadable\Test\Unit\Block\Sales\Order\Email\Items\Downloadable */ @@ -22,7 +24,7 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected $purchasedFactory; /** - * @var \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $itemsFactory; diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php index e48dda83ea68a..ca5a5aebe9ca1 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php @@ -6,6 +6,8 @@ namespace Magento\Downloadable\Test\Unit\Block\Sales\Order\Email\Items\Order; +use Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory; + /** * Tests Magento\Downloadable\Test\Unit\Block\Sales\Order\Email\Items\Order\Downloadable */ @@ -22,7 +24,7 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected $purchasedFactory; /** - * @var \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $itemsFactory; diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php index f2d13113a81b4..557ece057d31d 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php @@ -6,6 +6,8 @@ namespace Magento\Downloadable\Test\Unit\Block\Sales\Order\Item\Renderer; +use Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory; + /** * Tests Magento\Downloadable\Test\Unit\Block\Sales\Order\Item\Renderer\Downloadable */ @@ -22,7 +24,7 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected $purchasedFactory; /** - * @var \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $itemsFactory; From 7cead358d4f5ff374d53602d758701fc67e845ce Mon Sep 17 00:00:00 2001 From: Maksym Iakusha Date: Tue, 4 Aug 2015 14:10:27 +0300 Subject: [PATCH 05/12] MAGETWO-40617: Configurable product APIs should not requires authorized access --- app/code/Magento/ConfigurableProduct/etc/webapi.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/etc/webapi.xml b/app/code/Magento/ConfigurableProduct/etc/webapi.xml index 158db3c3c5fa8..6c0d76b6140c0 100644 --- a/app/code/Magento/ConfigurableProduct/etc/webapi.xml +++ b/app/code/Magento/ConfigurableProduct/etc/webapi.xml @@ -10,7 +10,7 @@ - + @@ -34,13 +34,13 @@ - + - + From 2aa5c0bbc9a204105e0d5666d20f40fc27bea2e5 Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Thu, 6 Aug 2015 21:26:16 +0300 Subject: [PATCH 06/12] MAGETWO-40002: [TD] Adopt \Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest functional test to new UX --- .../Product/Edit/Tab/Super/Config.php | 1 - .../Edit/Tab/Super/Config/Attribute.php | 29 ++++++++++-- .../Product/Edit/Tab/Super/Config/Matrix.php | 14 ++---- .../Product/Edit/Tab/Super/Config/Matrix.xml | 3 ++ .../Product/View/ConfigurableOptions.php | 39 +++++++++++++++- .../AssertConfigurableProductForm.php | 25 ++-------- .../AssertConfigurableProductInCategory.php | 46 +++++++++++++++++++ .../AssertConfigurableProductPage.php | 19 ++++++++ .../Test/Fixture/ConfigurableProduct.xml | 2 +- .../ConfigurableAttributesData.php | 5 +- .../ConfigurableProduct/CheckoutData.xml | 2 +- .../ConfigurableAttributesData.xml | 18 -------- .../Repository/ConfigurableProduct/Price.xml | 18 ++++++++ .../CreateConfigurableProductEntityTest.php | 1 - .../CreateConfigurableProductEntityTest.xml | 8 ++-- 15 files changed, 165 insertions(+), 65 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php index c67426e90d572..d80392b106e2f 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php @@ -194,7 +194,6 @@ public function getDataFormTab($fields = null, SimpleElement $element = null) $data = []; $this->showContent(); - $data['attributes_data'] = $this->getAttributeBlock()->getAttributesData(); $data['matrix'] = $this->getVariationsBlock()->getVariationsData(); return ['configurable_attributes_data' => $data]; diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php index 86e2b13a2da46..aac3b838dd777 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php @@ -80,12 +80,14 @@ class Attribute extends Form */ protected $attributeOptionByName = '[data-attribute-option-title="%s"]'; + // @codingStandardsIgnoreStart /** * Selector for attribute block * * @var string */ - protected $attributeBlock = '//div[@id="configurable-attributes-container"]/div[contains(@class,"entry-edit")][%d]'; + protected $attributeBlock = '//div[@data-role="configurable-attributes-container"]/div[@data-role="attribute-info"][%d]'; + // @codingStandardsIgnoreEnd /** * Selector for "Create New Value" button @@ -143,6 +145,13 @@ class Attribute extends Form */ protected $configContent = '#super_config-content'; + /** + * Backend abstract block. + * + * @var string + */ + protected $templateBlock = './ancestor::body'; + /** * Fill attributes * @@ -164,6 +173,7 @@ public function fillAttributes(array $attributes) } $this->browser->find($this->nextButton)->click(); + $this->getTemplateBlock()->waitLoader(); $this->browser->find($this->nextButton)->click(); } @@ -194,6 +204,7 @@ protected function createNewVariationSet(array $attribute) $this->browser->find($this->createNewVariationSet)->click(); $this->getEditAttributeForm()->fill($attributeFixture); $this->getEditAttributeForm()->saveAttributeForm(); + $this->waitBlock($this->newAttributeFrame); } /** @@ -228,7 +239,6 @@ protected function fillOptions(array $attribute) ); $count = 0; - $this->showAttributeContent($attributeBlock); if (isset($attribute['label'])) { $attributeBlock->find($this->attributeLabel)->setValue($attribute['label']); } @@ -320,6 +330,7 @@ public function getAttributeSelector() /** * Get attributes data * + * @deprecated * @return array */ public function getAttributesData() @@ -331,7 +342,6 @@ public function getAttributesData() /** @var SimpleElement $attributeBlock */ $attributeBlock = $this->_rootElement->find(sprintf($this->attributeBlock, $count), Locator::SELECTOR_XPATH); while ($attributeBlock->isVisible()) { - $this->showAttributeContent($attributeBlock); $attribute = [ 'frontend_label' => $attributeBlock->find($this->attributeTitle)->getText(), 'label' => $attributeBlock->find($this->attributeLabel)->getValue(), @@ -411,4 +421,17 @@ protected function getOptionalFields(SimpleElement $context, array $fields = []) return $data; } + + /** + * Get backend abstract block. + * + * @return \Magento\Backend\Test\Block\Template + */ + protected function getTemplateBlock() + { + return $this->blockFactory->create( + 'Magento\Backend\Test\Block\Template', + ['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php index 49957a1509f63..74a8c720c7b1d 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php @@ -28,7 +28,11 @@ class Matrix extends Form 'strategy' => Locator::SELECTOR_CSS, ], 'sku' => [ - 'selector' => 'td[data-column="sku"] > span', + 'selector' => 'td[data-column="sku"]', + 'strategy' => Locator::SELECTOR_CSS, + ], + 'price' => [ + 'selector' => 'td[data-column="price"]', 'strategy' => Locator::SELECTOR_CSS, ], 'quantity_and_stock_status' => [ @@ -76,13 +80,6 @@ class Matrix extends Form protected $selectAssociatedProduct = '//ancestor::div[*[@id="associated-products-container"]]//td[@data-column="entity_id" and (contains(text(),"%s"))]'; // @codingStandardsIgnoreEnd - /** - * Title of variation matrix css selector. - * - * @var string - */ - protected $matrixTitle = 'h3.title'; - /** * Selector for template block. * @@ -98,7 +95,6 @@ class Matrix extends Form */ public function fillVariations(array $matrix) { - $this->_rootElement->find($this->matrixTitle)->click(); $count = 1; foreach ($matrix as $variation) { $variationRow = $this->_rootElement->find( diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml index d5950b09c42ee..9abd6e5166066 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml @@ -17,6 +17,9 @@ [name$="[sku]"] + + [name$="[price]"] + [name$="[quantity_and_stock_status][qty]"] diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php index 88493e7896719..ab93e338ba5bc 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php @@ -27,6 +27,13 @@ class ConfigurableOptions extends CustomOptions */ protected $optionSelector = '//*[./label[contains(.,"%s")]]//select'; + /** + * Selector for price block. + * + * @var string + */ + protected $priceBlock = '//*[@class="product-info-main"]//*[contains(@class,"price-box")]'; + /** * Get configurable product options * @@ -61,11 +68,39 @@ public function getOptions(FixtureInterface $product) ? 'Yes' : 'No'; + foreach ($optionData['options'] as $key => $value) { + $optionData['options'][$key]['price'] = $this->getOptionPrice($title, $value['title']); + } $result[$title] = $optionData; - $this->_rootElement->find(sprintf($this->optionSelector, $title), Locator::SELECTOR_XPATH, 'select') - ->setValue($optionData['options'][0]['title']); } return $result; } + + /** + * Get option price + * + * @param $attributeTitle + * @param $optionTitle + * @return null|string + */ + protected function getOptionPrice($attributeTitle, $optionTitle) + { + $this->_rootElement->find(sprintf($this->optionSelector, $attributeTitle), Locator::SELECTOR_XPATH, 'select') + ->setValue($optionTitle); + return $this->getPriceBlock()->getPrice(); + } + + /** + * Get block price. + * + * @return \Magento\Catalog\Test\Block\Product\Price + */ + protected function getPriceBlock() + { + return $this->blockFactory->create( + 'Magento\Catalog\Test\Block\Product\Price', + ['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php index 55306ebfe5aa4..eb733915bc22e 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php @@ -32,6 +32,7 @@ class AssertConfigurableProductForm extends AssertProductForm */ protected $skippedAttributeFields = [ 'frontend_input', + 'frontend_label', 'attribute_code', 'attribute_id', 'is_required', @@ -66,24 +67,12 @@ class AssertConfigurableProductForm extends AssertProductForm */ protected function prepareFixtureData(array $data, array $sortFields = []) { - // filter values and reset keys in attributes data - $attributeData = $data['configurable_attributes_data']['attributes_data']; - foreach ($attributeData as $attributeKey => $attribute) { - foreach ($attribute['options'] as $optionKey => $option) { - if (isset($option['admin'])) { - $option['label'] = $option['admin']; - } - $attribute['options'][$optionKey] = array_diff_key($option, array_flip($this->skippedOptionFields)); - } - $attribute['options'] = $this->sortDataByPath($attribute['options'], '::label'); - $attributeData[$attributeKey] = array_diff_key($attribute, array_flip($this->skippedAttributeFields)); - } - $data['configurable_attributes_data']['attributes_data'] = $this->sortDataByPath($attributeData, '::label'); + // Attribute is no longer displayed on product page + unset($data['configurable_attributes_data']['attributes_data']); // prepare and filter values, reset keys in variation matrix $variationsMatrix = $data['configurable_attributes_data']['matrix']; foreach ($variationsMatrix as $key => $variationMatrix) { - $variationMatrix['display'] = isset($variationMatrix['display']) ? $variationMatrix['display'] : 'Yes'; $variationsMatrix[$key] = array_diff_key($variationMatrix, array_flip($this->skippedVariationMatrixFields)); } $data['configurable_attributes_data']['matrix'] = array_values($variationsMatrix); @@ -100,14 +89,6 @@ protected function prepareFixtureData(array $data, array $sortFields = []) */ protected function prepareFormData(array $data, array $sortFields = []) { - // prepare attributes data - $attributeData = $data['configurable_attributes_data']['attributes_data']; - foreach ($attributeData as $attributeKey => $attribute) { - $attribute['options'] = $this->sortDataByPath($attribute['options'], '::label'); - $attributeData[$attributeKey] = $attribute; - } - $data['configurable_attributes_data']['attributes_data'] = $this->sortDataByPath($attributeData, '::label'); - // filter values and reset keys in variation matrix $variationsMatrix = $data['configurable_attributes_data']['matrix']; foreach ($variationsMatrix as $key => $variationMatrix) { diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php new file mode 100644 index 0000000000000..31db1ded79be7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php @@ -0,0 +1,46 @@ +getListProductBlock()->getProductItem($product)->getPriceBlock(); + $priceData = $product->getDataFieldConfig('price')['source']->getPriceData(); + $price = isset($priceData['category_price']) ?: $product->getPrice(); + \PHPUnit_Framework_Assert::assertEquals( + number_format($price, 2, '.', ''), + $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(), + 'Product regular price on category page is not correct.' + ); + + if ($product->hasData('special_price')) { + \PHPUnit_Framework_Assert::assertEquals( + number_format($product->getSpecialPrice(), 2, '.', ''), + $priceBlock->getSpecialPrice(), + 'Product special price on category page is not correct.' + ); + } + } + +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php index 6d59379b299ec..246f73bb739ee 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php @@ -33,6 +33,25 @@ protected function verify() return array_filter($errors); } + /** + * Verify displayed product price on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifyPrice() + { + $priceBlock = $this->productView->getPriceBlock(); + $formPrice = $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(); + $priceData = $this->product->getDataFieldConfig('price')['source']->getPriceData(); + $fixturePrice = number_format($priceData['category_price'], 2, '.', ''); + + if ($fixturePrice != $formPrice) { + return "Displayed product price on product page(front-end) not equals passed from fixture. " + . "Actual: {$fixturePrice}, expected: {$formPrice}."; + } + return null; + } + /** * Verify displayed product attributes on product page(front-end) equals passed from fixture * diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml index 64d4c230aaf72..96623e3492dae 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml @@ -54,7 +54,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct/ConfigurableAttributesData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct/ConfigurableAttributesData.php index 79ed15ba3836a..7e3522fccf242 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct/ConfigurableAttributesData.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct/ConfigurableAttributesData.php @@ -290,9 +290,6 @@ protected function prepareVariationsMatrix(array $data) ); } - if (!isset($this->variationsMatrix[$key]['display'])) { - $this->variationsMatrix[$key]['display'] = 'Yes'; - } } } @@ -329,6 +326,7 @@ protected function addVariationMatrix(array $variationsMatrix, array $attribute, $compositeKey = "{$attributeKey}:{$optionKey}"; $row['name'] .= ' ' . $index; $row['sku'] .= '_' . $index; + $row['price'] = $option['pricing_value']; $newRowKey = $rowKey ? "{$rowKey} {$compositeKey}" : $compositeKey; $result[$newRowKey] = $row; $index++; @@ -363,7 +361,6 @@ protected function prepareData() ]; $variationMatrixFields = [ 'configurable_attribute', - 'display', 'name', 'sku', 'price', diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml index 29c03b0ccc65c..92cc6415ea638 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml @@ -59,7 +59,7 @@ - 100 + 1 diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml index 6c84fb72b0149..52c0de0499871 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml @@ -127,7 +127,6 @@ - Yes 10 @@ -153,7 +152,6 @@ - Yes 10 @@ -186,14 +184,12 @@ - Yes 10 1 - Yes 20 @@ -226,14 +222,12 @@ - Yes 10 1 - Yes 20 @@ -267,14 +261,12 @@ - Yes 10 1 - Yes 20 @@ -312,14 +304,12 @@ - Yes 100 1 - Yes 100 @@ -392,14 +382,12 @@ - Yes 10 1 - Yes 20 @@ -598,14 +586,12 @@ - Yes 100 1 - Yes 200 @@ -638,14 +624,12 @@ - Yes 100 1 - Yes 200 @@ -682,14 +666,12 @@ - Yes 100 1 - Yes 200 diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml new file mode 100644 index 0000000000000..bb21df71fdc48 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml @@ -0,0 +1,18 @@ + + + + + + 1 + + + + 11 + + + diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php index 3ecad231f851d..8a5829715c15c 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php @@ -79,7 +79,6 @@ public function __inject(CatalogProductIndex $productIndex, CatalogProductNew $p */ public function test(ConfigurableProduct $product) { - $this->markTestIncomplete('MAGETWO-40002'); // Steps $this->productIndex->open(); $this->productIndex->getGridPageActionBlock()->addProduct('configurable'); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml index 18308b2a1c04e..a08e880bd7431 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml @@ -15,6 +15,7 @@ Configurable Product %isolation% configurable_sku_%isolation% 100 + default default_subcategory Configurable short description Configurable Product description %isolation% @@ -25,7 +26,7 @@ - + @@ -103,12 +104,13 @@ configurable_sku_%isolation% Taxable Goods 10 + MAGETWO-12620 default_subcategory 1 custom_attribute_set_%isolation% - + @@ -123,7 +125,7 @@ test_type:acceptance_test - + From 558eaa31e3019bd47339eeb9df106d72d350a90d Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Thu, 6 Aug 2015 21:36:49 +0300 Subject: [PATCH 07/12] MAGETWO-40002: [TD] Adopt \Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest functional test to new UX --- .../Test/Constraint/AssertConfigurableProductInCategory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php index 31db1ded79be7..df9a1f1b7f160 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php @@ -42,5 +42,4 @@ protected function assertPrice(FixtureInterface $product, CatalogCategoryView $c ); } } - } From c65ce3a2f7fa53392d24ba9b36a990b5ef47b3ff Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Fri, 7 Aug 2015 13:03:15 +0300 Subject: [PATCH 08/12] MAGETWO-40002: [TD] Adopt \Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest functional test to new UX --- .../Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php | 2 +- .../Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php | 3 ++- .../Test/TestCase/CreateConfigurableProductEntityTest.xml | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php index d80392b106e2f..75aff573bcf49 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php @@ -39,7 +39,7 @@ class Config extends Tab * * @var string */ - protected $generateVariations = '[data-role=step-wizard-next]'; + protected $generateVariations = '[data-role=step-wizard-next] button'; /** * Selector for variations matrix. diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php index aac3b838dd777..55e176e342403 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php @@ -101,7 +101,7 @@ class Attribute extends Form * * @var string */ - protected $nextButton = '[data-role=step-wizard-next]'; + protected $nextButton = '[data-role=step-wizard-next] button'; /** * Selector for option container @@ -167,6 +167,7 @@ public function fillAttributes(array $attributes) $this->getAttributesGrid()->searchAndSelect(['frontend_label' => $attribute['frontend_label']]); } $this->browser->find($this->nextButton)->click(); + $this->getTemplateBlock()->waitLoader(); foreach ($attributes as $attribute) { $this->updateOptions($attribute); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml index a08e880bd7431..16b2a2306b594 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml @@ -117,7 +117,9 @@ MAGETWO-13361: Create Configurable Product with Creating New Category and New Attribute (Required Fields Only) two_searchable_options Configurable Product %isolation% + configurable_sku_%isolation% 100 + default no default_subcategory configurable-product-%isolation% From 9aa126d57cd8e7a858aaea93ef289e34aa215dba Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Fri, 7 Aug 2015 14:17:17 +0300 Subject: [PATCH 09/12] MAGETWO-40002: [TD] Adopt \Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest functional test to new UX --- .../ConfigurableProduct/ConfigurableAttributesData.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml index 52c0de0499871..f208e620909e4 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml @@ -204,13 +204,13 @@ option_key_1_%isolation% - 0 + 10 Yes No option_key_2_%isolation% - 0 + 10 Yes No From e40e97b6cef7159925cb05db7a0fd8ce0ad1d64f Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Fri, 7 Aug 2015 14:58:56 +0300 Subject: [PATCH 10/12] MAGETWO-40002: [TD] Adopt \Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest functional test to new UX --- .../Test/Constraint/AssertConfigurableProductInCategory.php | 2 +- .../Msrp/Test/Constraint/AssertMsrpInShoppingCart.php | 5 +++-- .../Msrp/Test/Constraint/AssertMsrpOnCategoryPage.php | 4 +++- .../Magento/Msrp/Test/Constraint/AssertMsrpOnProductView.php | 4 +++- .../app/Magento/Msrp/Test/Repository/ConfigurableProduct.xml | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php index df9a1f1b7f160..246b7e536b4ca 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCategory.php @@ -27,7 +27,7 @@ protected function assertPrice(FixtureInterface $product, CatalogCategoryView $c { $priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock(); $priceData = $product->getDataFieldConfig('price')['source']->getPriceData(); - $price = isset($priceData['category_price']) ?: $product->getPrice(); + $price = isset($priceData['category_price']) ? $priceData['category_price'] : $product->getPrice(); \PHPUnit_Framework_Assert::assertEquals( number_format($price, 2, '.', ''), $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(), diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpInShoppingCart.php index 112d3d9b4e405..820762908a670 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpInShoppingCart.php @@ -50,8 +50,9 @@ public function processAssert( $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); - // TODO: adopt fixture - price is moved to child product from attributes options. - $productPrice = $product->getPrice(); + + $priceData = $product->getDataFieldConfig('price')['source']->getPriceData(); + $productPrice = isset($priceData['category_price']) ? $priceData['category_price'] : $product->getPrice(); $unitPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); \PHPUnit_Framework_Assert::assertEquals($productPrice, $unitPrice, 'Incorrect unit price is displayed in Cart'); } diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnCategoryPage.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnCategoryPage.php index 69e80bd07f82d..911c94b4a6a51 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnCategoryPage.php @@ -58,8 +58,10 @@ public function processAssert( $mapBlock->getOldPrice(), 'Displayed on Category page MAP is incorrect.' ); + $priceData = $product->getDataFieldConfig('price')['source']->getPriceData(); + $price = isset($priceData['category_price']) ? $priceData['category_price'] : $product->getPrice(); \PHPUnit_Framework_Assert::assertEquals( - $product->getPrice(), + $price, $mapBlock->getActualPrice(), 'Displayed on Category page price is incorrect.' ); diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnProductView.php b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnProductView.php index ca8f89531e346..50446d2aae8ef 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnProductView.php +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnProductView.php @@ -57,8 +57,10 @@ public function processAssert( $mapBlock->getOldPrice(), 'Displayed on Product view page MAP is incorrect.' ); + $priceData = $product->getDataFieldConfig('price')['source']->getPriceData(); + $price = isset($priceData['category_price']) ? $priceData['category_price'] : $product->getPrice(); \PHPUnit_Framework_Assert::assertEquals( - $product->getPrice(), + $price, $mapBlock->getActualPrice(), 'Displayed on Product view page price is incorrect.' ); diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/ConfigurableProduct.xml index 32e6d1cf28fce..6d1c426bd8798 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/ConfigurableProduct.xml @@ -12,6 +12,7 @@ sku_test_configurable_product_%isolation% 10 + default 30 From ee01b69d75cdad91cc186094abd62fc9b6d0d8c2 Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Fri, 7 Aug 2015 16:30:05 +0300 Subject: [PATCH 11/12] MAGETWO-40002: [TD] Adopt \Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest functional test to new UX --- .../app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml index 5fd3348a6ff24..ce8c852c77d61 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml @@ -121,7 +121,7 @@ Flat Rate Fixed - 31.65 + 21.91 checkmo test_type:acceptance_test From cc82454b9552f5c3865d0b92e4f896f87b193701 Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Fri, 7 Aug 2015 17:48:39 +0300 Subject: [PATCH 12/12] MAGETWO-40002: [TD] Adopt \Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest functional test to new UX --- .../app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml index d19c824656bc9..c6a9fa03bb5c0 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml @@ -138,7 +138,7 @@ Flat Rate Fixed - 31.65 + 21.91 checkmo