@@ -16,9 +16,6 @@ class SaveTest extends \PHPUnit_Framework_TestCase
16
16
/** @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject */
17
17
private $ redirect ;
18
18
19
- /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
20
- private $ objectManager ;
21
-
22
19
/** @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
23
20
private $ messageManager ;
24
21
@@ -65,17 +62,17 @@ protected function setUp()
65
62
->method ('getRequest ' )
66
63
->willReturn ($ this ->request );
67
64
68
- $ this -> objectManager = $ this ->getMockBuilder ('\Magento\Framework\ObjectManagerInterface ' )
65
+ $ objectManager = $ this ->getMockBuilder ('\Magento\Framework\ObjectManagerInterface ' )
69
66
->disableOriginalConstructor ()
70
67
->setMethods (['create ' ])
71
68
->getMockForAbstractClass ();
72
69
$ this ->context ->expects ($ this ->any ())
73
70
->method ('getObjectManager ' )
74
- ->willReturn ($ this -> objectManager );
71
+ ->willReturn ($ objectManager );
75
72
76
73
$ this ->messageManager = $ this ->getMockBuilder ('\Magento\Framework\Message\ManagerInterface ' )
77
74
->disableOriginalConstructor ()
78
- ->setMethods (['addSuccess ' , 'addError ' , 'addException ' ])
75
+ ->setMethods (['addSuccess ' , 'addError ' , 'addException ' ])
79
76
->getMockForAbstractClass ();
80
77
$ this ->context ->expects ($ this ->any ())
81
78
->method ('getMessageManager ' )
@@ -98,12 +95,20 @@ protected function setUp()
98
95
->disableOriginalConstructor ()
99
96
->setMethods (['getId ' , 'load ' , 'addData ' , 'setIsProcessed ' , 'save ' , 'loadByQueryText ' , 'setStoreId ' ])
100
97
->getMock ();
98
+ $ queryFactory = $ this ->getMockBuilder ('Magento\Search\Model\QueryFactory ' )
99
+ ->setMethods (['create ' ])
100
+ ->disableOriginalConstructor ()
101
+ ->getMock ();
102
+ $ queryFactory ->expects ($ this ->any ())
103
+ ->method ('create ' )
104
+ ->will ($ this ->returnValue ($ this ->query ));
101
105
102
106
$ this ->controller = $ objectManagerHelper ->getObject (
103
107
'Magento\Search\Controller\Adminhtml\Term\Save ' ,
104
108
[
105
109
'context ' => $ this ->context ,
106
110
'resultPageFactory ' => $ pageFactory ,
111
+ 'queryFactory ' => $ queryFactory ,
107
112
]
108
113
);
109
114
}
@@ -138,7 +143,6 @@ public function testExecuteLoadQueryQueryId()
138
143
$ queryText = '' ;
139
144
$ this ->mockGetRequestData ($ queryText , $ queryId );
140
145
141
- $ this ->objectManager ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->query );
142
146
$ this ->query ->expects ($ this ->once ())->method ('getId ' )->willReturn (false );
143
147
$ this ->query ->expects ($ this ->once ())->method ('load ' )->with ($ queryId );
144
148
@@ -154,7 +158,6 @@ public function testExecuteLoadQueryQueryIdQueryText()
154
158
$ queryText = 'search ' ;
155
159
$ this ->mockGetRequestData ($ queryText , $ queryId );
156
160
157
- $ this ->objectManager ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->query );
158
161
$ this ->request ->expects ($ this ->at (4 ))->method ('getPost ' )->with ('store_id ' , false )->willReturn (1 );
159
162
160
163
$ this ->query ->expects ($ this ->once ())->method ('setStoreId ' );
@@ -173,7 +176,6 @@ public function testExecuteLoadQueryQueryIdQueryText2()
173
176
$ queryText = 'search ' ;
174
177
$ this ->mockGetRequestData ($ queryText , $ queryId );
175
178
176
- $ this ->objectManager ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->query );
177
179
$ this ->request ->expects ($ this ->at (4 ))->method ('getPost ' )->with ('store_id ' , false )->willReturn (1 );
178
180
179
181
$ this ->query ->expects ($ this ->once ())->method ('setStoreId ' );
@@ -194,7 +196,6 @@ public function testExecuteLoadQueryQueryIdQueryTextException()
194
196
$ queryText = 'search ' ;
195
197
$ this ->mockGetRequestData ($ queryText , $ queryId );
196
198
197
- $ this ->objectManager ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->query );
198
199
$ this ->request ->expects ($ this ->at (4 ))->method ('getPost ' )->with ('store_id ' , false )->willReturn (1 );
199
200
200
201
$ this ->query ->expects ($ this ->once ())->method ('setStoreId ' );
@@ -213,7 +214,6 @@ public function testExecuteException()
213
214
$ queryText = 'search ' ;
214
215
$ this ->mockGetRequestData ($ queryText , $ queryId );
215
216
216
- $ this ->objectManager ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->query );
217
217
$ this ->request ->expects ($ this ->at (4 ))->method ('getPost ' )->with ('store_id ' , false )->willReturn (1 );
218
218
219
219
$ this ->query ->expects ($ this ->once ())->method ('setStoreId ' );
0 commit comments