Skip to content

Commit 64d2c6f

Browse files
committed
MAGETWO-37089: Unit test coverage
1 parent 2a1d955 commit 64d2c6f

File tree

1 file changed

+2
-49
lines changed
  • app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order

1 file changed

+2
-49
lines changed

app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
*/
1212
class GridTest extends \PHPUnit_Framework_TestCase
1313
{
14-
/**
15-
* @var \PHPUnit_Framework_MockObject_MockObject
16-
*/
17-
protected $componentFactory;
18-
1914
/**
2015
* @var \Magento\Sales\Block\Adminhtml\Order\Grid
2116
*/
@@ -33,9 +28,6 @@ class GridTest extends \PHPUnit_Framework_TestCase
3328

3429
protected function setUp()
3530
{
36-
$this->componentFactory = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentFactory')
37-
->disableOriginalConstructor()
38-
->getMock();
3931
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
4032
->disableOriginalConstructor()
4133
->setMethods(['has'])
@@ -47,7 +39,6 @@ protected function setUp()
4739
->method('getRequest')
4840
->willReturn($this->requestMock);
4941
$arguments = [
50-
'componentFactory' => $this->componentFactory,
5142
'context' => $this->contextMock
5243
];
5344
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -57,45 +48,9 @@ protected function setUp()
5748

5849
public function testPrepareCollection()
5950
{
60-
$contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface')
61-
->disableOriginalConstructor()
62-
->getMock();
6351
$collectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Grid\Collection')
6452
->disableOriginalConstructor()
6553
->getMock();
66-
$providerName = 'Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider';
67-
$dataProviderMock = $this->getMockBuilder($providerName)
68-
->disableOriginalConstructor()
69-
->getMock();
70-
$componentMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface')
71-
->disableOriginalConstructor()
72-
->getMock();
73-
$childComponentMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface')
74-
->disableOriginalConstructor()
75-
->getMock();
76-
$this->componentFactory->expects($this->once())
77-
->method('create')
78-
->with('sales_order_grid')
79-
->willReturn($componentMock);
80-
$componentMock->expects($this->once())
81-
->method('getChildComponents')
82-
->willReturn([$childComponentMock]);
83-
$childComponentMock->expects($this->once())
84-
->method('getChildComponents')
85-
->willReturn([]);
86-
$childComponentMock->expects($this->once())
87-
->method('prepare');
88-
$componentMock->expects($this->once())
89-
->method('render');
90-
$componentMock->expects($this->once())
91-
->method('getContext')
92-
->willReturn($contextMock);
93-
$contextMock->expects($this->once())
94-
->method('getDataProvider')
95-
->willReturn($dataProviderMock);
96-
$dataProviderMock->expects($this->once())
97-
->method('getCollection')
98-
->willReturn($collectionMock);
9954
$this->requestMock->expects($this->any())
10055
->method('has')
10156
->withAnyParameters()
@@ -120,9 +75,7 @@ public function testPrepareCollection()
12075
->willReturn($blockMock);
12176
$this->block->setData('id', 1);
12277
$this->block->setLayout($layoutMock);
123-
$this->assertInstanceOf(
124-
'Magento\Sales\Model\Resource\Order\Grid\Collection',
125-
$this->block->getPreparedCollection()
126-
);
78+
$this->block->setCollection($collectionMock);
79+
$this->assertEquals($collectionMock, $this->block->getPreparedCollection());
12780
}
12881
}

0 commit comments

Comments
 (0)