11
11
*/
12
12
class GridTest extends \PHPUnit_Framework_TestCase
13
13
{
14
- /**
15
- * @var \PHPUnit_Framework_MockObject_MockObject
16
- */
17
- protected $ componentFactory ;
18
-
19
14
/**
20
15
* @var \Magento\Sales\Block\Adminhtml\Order\Grid
21
16
*/
@@ -33,9 +28,6 @@ class GridTest extends \PHPUnit_Framework_TestCase
33
28
34
29
protected function setUp ()
35
30
{
36
- $ this ->componentFactory = $ this ->getMockBuilder ('Magento\Framework\View\Element\UiComponentFactory ' )
37
- ->disableOriginalConstructor ()
38
- ->getMock ();
39
31
$ this ->requestMock = $ this ->getMockBuilder ('Magento\Framework\App\RequestInterface ' )
40
32
->disableOriginalConstructor ()
41
33
->setMethods (['has ' ])
@@ -47,7 +39,6 @@ protected function setUp()
47
39
->method ('getRequest ' )
48
40
->willReturn ($ this ->requestMock );
49
41
$ arguments = [
50
- 'componentFactory ' => $ this ->componentFactory ,
51
42
'context ' => $ this ->contextMock
52
43
];
53
44
$ helper = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
@@ -57,45 +48,9 @@ protected function setUp()
57
48
58
49
public function testPrepareCollection ()
59
50
{
60
- $ contextMock = $ this ->getMockBuilder ('Magento\Framework\View\Element\UiComponent\ContextInterface ' )
61
- ->disableOriginalConstructor ()
62
- ->getMock ();
63
51
$ collectionMock = $ this ->getMockBuilder ('Magento\Sales\Model\Resource\Order\Grid\Collection ' )
64
52
->disableOriginalConstructor ()
65
53
->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 );
99
54
$ this ->requestMock ->expects ($ this ->any ())
100
55
->method ('has ' )
101
56
->withAnyParameters ()
@@ -120,9 +75,7 @@ public function testPrepareCollection()
120
75
->willReturn ($ blockMock );
121
76
$ this ->block ->setData ('id ' , 1 );
122
77
$ 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 ());
127
80
}
128
81
}
0 commit comments