-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #518 from magento-dragons/MAGETWO-40002
[DRAGONS] Functional tests&Bugfixes
- Loading branch information
Showing
29 changed files
with
567 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...gento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
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 | ||
*/ | ||
class NameTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name | ||
*/ | ||
protected $block; | ||
|
||
/** | ||
* @var \Magento\Downloadable\Model\Link\PurchasedFactory|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $purchasedFactory; | ||
|
||
/** | ||
* @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $itemsFactory; | ||
|
||
public function setUp() | ||
{ | ||
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$contextMock = $this->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()); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
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 | ||
*/ | ||
class DownloadableTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable | ||
*/ | ||
protected $block; | ||
|
||
/** | ||
* @var \Magento\Downloadable\Model\Link\PurchasedFactory|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $purchasedFactory; | ||
|
||
/** | ||
* @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $itemsFactory; | ||
|
||
public function setUp() | ||
{ | ||
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$contextMock = $this->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()); | ||
} | ||
} |
Oops, something went wrong.