Skip to content

Commit 3b0e30e

Browse files
author
Yu Tang
committed
MAGETWO-44491: [TD] ActionInterface has Method dispatch() Instead of execute()
- Fix unit test failures
1 parent fded3fc commit 3b0e30e

File tree

26 files changed

+128
-105
lines changed

26 files changed

+128
-105
lines changed

app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
9696
*/
9797
protected $helperMock;
9898

99+
/**
100+
* @var Redirect|\PHPUnit_Framework_MockObject_MockObject
101+
*/
102+
protected $controller;
103+
99104
protected function setUp()
100105
{
101106
$this->directpostSessionMock = $this->getMockBuilder('Magento\Authorizenet\Model\Directpost\Session')
@@ -196,7 +201,7 @@ protected function setUp()
196201
);
197202
}
198203

199-
public function testExecuteErrorMsgWithoutCancelOrder()
204+
public function testExecuteInternalErrorMsgWithoutCancelOrder()
200205
{
201206
$params = ['success' => 0, 'error_msg' => 'Error message'];
202207
$incrementId = 1;
@@ -238,10 +243,10 @@ public function testExecuteErrorMsgWithoutCancelOrder()
238243
->method('register')
239244
->with(Iframe::REGISTRY_KEY);
240245

241-
$this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->execute());
246+
$this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->executeInternal());
242247
}
243248

244-
public function testExecuteErrorMsgWithCancelOrder()
249+
public function testExecuteInternalErrorMsgWithCancelOrder()
245250
{
246251
$params = ['success' => 0, 'error_msg' => 'Error message', 'x_invoice_num' => 1];
247252
$incrementId = 1;
@@ -273,10 +278,10 @@ public function testExecuteErrorMsgWithCancelOrder()
273278
->method('register')
274279
->with(Iframe::REGISTRY_KEY);
275280

276-
$this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->execute());
281+
$this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->executeInternal());
277282
}
278283

279-
public function testExecuteSuccess()
284+
public function testExecuteInternalSuccess()
280285
{
281286
$params = ['success' => 1, 'controller_action_name' => 'action', 'x_invoice_num' => 1];
282287
$this->requestMock->expects($this->once())
@@ -307,6 +312,6 @@ public function testExecuteSuccess()
307312
->method('register')
308313
->with(Iframe::REGISTRY_KEY);
309314

310-
$this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->execute());
315+
$this->assertInstanceOf('\Magento\Framework\View\Result\Layout', $this->controller->executeInternal());
311316
}
312317
}

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class CleanMediaTest extends \PHPUnit_Framework_TestCase
1212
{
13-
public function testExecute()
13+
public function testExecuteInternal()
1414
{
1515
// Wire object with mocks
1616
$response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
@@ -62,6 +62,7 @@ public function testExecute()
6262
$context->expects($this->once())->method('getMessageManager')->willReturn($messageManager);
6363
$context->expects($this->once())->method('getResultFactory')->willReturn($resultFactory);
6464

65+
/** @var \Magento\Backend\Controller\Adminhtml\Cache\CleanMedia $controller */
6566
$controller = $helper->getObject(
6667
'Magento\Backend\Controller\Adminhtml\Cache\CleanMedia',
6768
[
@@ -90,6 +91,6 @@ public function testExecute()
9091
->willReturnSelf();
9192

9293
// Run
93-
$controller->execute();
94+
$controller->executeInternal();
9495
}
9596
}

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/AbstractTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AbstractTestCase extends \PHPUnit_Framework_TestCase
1919
* @param $controllerName
2020
* @param $blockName
2121
*/
22-
protected function assertExecute($controllerName, $blockName)
22+
protected function assertExecuteInternal($controllerName, $blockName)
2323
{
2424
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
2525
$outPut = "data";
@@ -47,7 +47,7 @@ protected function assertExecute($controllerName, $blockName)
4747
'layoutFactory' => $layoutFactoryMock
4848
]
4949
);
50-
$result = $controller->execute();
50+
$result = $controller->executeInternal();
5151
$this->assertInstanceOf('Magento\Framework\Controller\Result\Raw', $result);
5252
}
5353
}

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/CustomersMostTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CustomersMostTest extends AbstractTestCase
1515
{
1616
public function testExecute()
1717
{
18-
$this->assertExecute(
18+
$this->assertExecuteInternal(
1919
'Magento\Backend\Controller\Adminhtml\Dashboard\CustomersMost',
2020
'Magento\Backend\Block\Dashboard\Tab\Customers\Most'
2121
);

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/CustomersNewestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CustomersNewestTest extends AbstractTestCase
1515
{
1616
public function testExecute()
1717
{
18-
$this->assertExecute(
18+
$this->assertExecuteInternal(
1919
'Magento\Backend\Controller\Adminhtml\Dashboard\CustomersNewest',
2020
'Magento\Backend\Block\Dashboard\Tab\Customers\Newest'
2121
);

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/ProductsViewedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ProductsViewedTest extends AbstractTestCase
1515
{
1616
public function testExecute()
1717
{
18-
$this->assertExecute(
18+
$this->assertExecuteInternal(
1919
'Magento\Backend\Controller\Adminhtml\Dashboard\ProductsViewed',
2020
'Magento\Backend\Block\Dashboard\Tab\Products\Viewed'
2121
);

app/code/Magento/Braintree/Test/Unit/Controller/Creditcard/AjaxSaveTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public function testExecute()
8888
->method('addSuccess')
8989
->with($phrase);
9090

91-
92-
$notification = $objectManager->getObject(
91+
/** @var \Magento\Braintree\Controller\Creditcard\AjaxSave $controller */
92+
$controller = $objectManager->getObject(
9393
'Magento\Braintree\Controller\Creditcard\AjaxSave',
9494
[
9595
'request' => $this->request,
@@ -98,7 +98,7 @@ public function testExecute()
9898
]
9999
);
100100

101-
$this->assertSame($this->resultJson, $notification->execute());
101+
$this->assertSame($this->resultJson, $controller->executeInternal());
102102
}
103103

104104
/**
@@ -124,7 +124,8 @@ public function testExecuteLocalizedException()
124124
->method('addError')
125125
->with($phrase);
126126

127-
$notification = $objectManager->getObject(
127+
/** @var \Magento\Braintree\Controller\Creditcard\AjaxSave $controller */
128+
$controller = $objectManager->getObject(
128129
'Magento\Braintree\Controller\Creditcard\AjaxSave',
129130
[
130131
'request' => $this->request,
@@ -134,6 +135,6 @@ public function testExecuteLocalizedException()
134135
]
135136
);
136137

137-
$this->assertSame($this->resultJson, $notification->execute());
138+
$this->assertSame($this->resultJson, $controller->executeInternal());
138139
}
139140
}

app/code/Magento/Braintree/Test/Unit/Controller/Creditcard/DeleteConfirmTest.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function setUp()
6666
/**
6767
* Executes the controller action and asserts successfully deleted
6868
*/
69-
public function testExecute()
69+
public function testExecuteInternal()
7070
{
7171
$objectManager = new ObjectManagerHelper($this);
7272
$phrase = new \Magento\Framework\Phrase('Credit card successfully deleted');
@@ -93,7 +93,8 @@ public function testExecute()
9393
->method('addSuccess')
9494
->with($phrase);
9595

96-
$notification = $objectManager->getObject(
96+
/** @var \Magento\Braintree\Controller\Creditcard\DeleteConfirm $controller */
97+
$controller = $objectManager->getObject(
9798
'Magento\Braintree\Controller\Creditcard\DeleteConfirm',
9899
[
99100
'request' => $this->request,
@@ -103,13 +104,13 @@ public function testExecute()
103104
]
104105
);
105106

106-
$this->assertSame($this->resultRedirect, $notification->execute());
107+
$this->assertSame($this->resultRedirect, $controller->executeInternal());
107108
}
108109

109110
/**
110111
* Executes the controller action and asserts with redirect for non valid token param
111112
*/
112-
public function testExecuteNoTokenRedirect()
113+
public function testExecuteInternalNoTokenRedirect()
113114
{
114115
$objectManager = new ObjectManagerHelper($this);
115116

@@ -128,7 +129,8 @@ public function testExecuteNoTokenRedirect()
128129
->method('setPath')
129130
->willReturnSelf();
130131

131-
$notification = $objectManager->getObject(
132+
/** @var \Magento\Braintree\Controller\Creditcard\Edit $controller */
133+
$controller = $objectManager->getObject(
132134
'Magento\Braintree\Controller\Creditcard\Edit',
133135
[
134136
'request' => $this->request,
@@ -137,13 +139,13 @@ public function testExecuteNoTokenRedirect()
137139
]
138140
);
139141

140-
$this->assertSame($this->resultRedirect, $notification->execute());
142+
$this->assertSame($this->resultRedirect, $controller->executeInternal());
141143
}
142144

143145
/**
144146
* Executes the controller action and asserts with redirects for can't delete card logic
145147
*/
146-
public function testExecuteNonExistingTokenRedirect()
148+
public function testExecuteInternalNonExistingTokenRedirect()
147149
{
148150
$objectManager = new ObjectManagerHelper($this);
149151
$phrase = new \Magento\Framework\Phrase('a,b,c');
@@ -172,7 +174,8 @@ public function testExecuteNonExistingTokenRedirect()
172174
->method('addError')
173175
->with($phrase);
174176

175-
$notification = $objectManager->getObject(
177+
/** @var \Magento\Braintree\Controller\Creditcard\DeleteConfirm $controller */
178+
$controller = $objectManager->getObject(
176179
'Magento\Braintree\Controller\Creditcard\DeleteConfirm',
177180
[
178181
'request' => $this->request,
@@ -182,13 +185,13 @@ public function testExecuteNonExistingTokenRedirect()
182185
]
183186
);
184187

185-
$this->assertSame($this->resultRedirect, $notification->execute());
188+
$this->assertSame($this->resultRedirect, $controller->executeInternal());
186189
}
187190

188191
/**
189192
* Executes the controller action and asserts failed deletion
190193
*/
191-
public function testExecuteSaveFail()
194+
public function testExecuteInternalSaveFail()
192195
{
193196
$objectManager = new ObjectManagerHelper($this);
194197
$phrase = new \Magento\Framework\Phrase('There was error deleting the credit card');
@@ -214,7 +217,8 @@ public function testExecuteSaveFail()
214217
->method('addError')
215218
->with($phrase);
216219

217-
$notification = $objectManager->getObject(
220+
/** @var \Magento\Braintree\Controller\Creditcard\DeleteConfirm $controller */
221+
$controller = $objectManager->getObject(
218222
'Magento\Braintree\Controller\Creditcard\DeleteConfirm',
219223
[
220224
'request' => $this->request,
@@ -224,6 +228,6 @@ public function testExecuteSaveFail()
224228
]
225229
);
226230

227-
$this->assertSame($this->resultRedirect, $notification->execute());
231+
$this->assertSame($this->resultRedirect, $controller->executeInternal());
228232
}
229233
}

app/code/Magento/Braintree/Test/Unit/Controller/Creditcard/DeleteTest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function setUp()
106106
/**
107107
* Executes the controller action and asserts non exception logic
108108
*/
109-
public function testExecute()
109+
public function testExecuteInternal()
110110
{
111111
$objectManager = new ObjectManagerHelper($this);
112112

@@ -138,8 +138,8 @@ public function testExecute()
138138
->method('getConfig')
139139
->willReturn($this->pageConfig);
140140

141-
142-
$notification = $objectManager->getObject(
141+
/** @var \Magento\Braintree\Controller\Creditcard\Delete $controller */
142+
$controller = $objectManager->getObject(
143143
'Magento\Braintree\Controller\Creditcard\Delete',
144144
[
145145
'request' => $this->request,
@@ -148,13 +148,13 @@ public function testExecute()
148148
]
149149
);
150150

151-
$this->assertSame($this->resultPage, $notification->execute());
151+
$this->assertSame($this->resultPage, $controller->executeInternal());
152152
}
153153

154154
/**
155155
* Executes the controller action and asserts with redirect for non valid token param
156156
*/
157-
public function testExecuteNoTokenRedirect()
157+
public function testExecuteInternalNoTokenRedirect()
158158
{
159159
$objectManager = new ObjectManagerHelper($this);
160160

@@ -176,7 +176,8 @@ public function testExecuteNoTokenRedirect()
176176
->method('setPath')
177177
->willReturnSelf();
178178

179-
$notification = $objectManager->getObject(
179+
/** @var \Magento\Braintree\Controller\Creditcard\Delete $controller */
180+
$controller = $objectManager->getObject(
180181
'Magento\Braintree\Controller\Creditcard\Delete',
181182
[
182183
'request' => $this->request,
@@ -186,13 +187,13 @@ public function testExecuteNoTokenRedirect()
186187
]
187188
);
188189

189-
$this->assertSame($this->resultRedirect, $notification->execute());
190+
$this->assertSame($this->resultRedirect, $controller->executeInternal());
190191
}
191192

192193
/**
193194
* Executes the controller action and asserts with redirects for non existing logic
194195
*/
195-
public function testExecuteNonExistingTokenRedirect()
196+
public function testExecuteInternalNonExistingTokenRedirect()
196197
{
197198
$objectManager = new ObjectManagerHelper($this);
198199
$phrase = new \Magento\Framework\Phrase('Credit card does not exist');
@@ -224,8 +225,8 @@ public function testExecuteNonExistingTokenRedirect()
224225
->method('addError')
225226
->with($phrase);
226227

227-
228-
$notification = $objectManager->getObject(
228+
/** @var \Magento\Braintree\Controller\Creditcard\Delete $controller */
229+
$controller = $objectManager->getObject(
229230
'Magento\Braintree\Controller\Creditcard\Delete',
230231
[
231232
'request' => $this->request,
@@ -236,6 +237,6 @@ public function testExecuteNonExistingTokenRedirect()
236237
]
237238
);
238239

239-
$this->assertSame($this->resultRedirect, $notification->execute());
240+
$this->assertSame($this->resultRedirect, $controller->executeInternal());
240241
}
241242
}

0 commit comments

Comments
 (0)