Skip to content

Commit 6b712c7

Browse files
author
Yurii Torbyk
committed
MAGETWO-34993: Refactor controllers from the list (Part1)
1 parent 243e6a8 commit 6b712c7

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,30 @@ public function testIsLoggedIn()
192192
$this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $this->model->execute());
193193
}
194194

195+
public function testGetDefaultRedirect()
196+
{
197+
$testUrl = 'http://example.com';
198+
$this->urlMock->expects($this->once())
199+
->method('getUrl')
200+
->with('*/*/index', ['_secure' => true])
201+
->willReturn($testUrl);
202+
203+
$this->redirectMock->expects($this->once())
204+
->method('error')
205+
->with($testUrl)
206+
->willReturn($testUrl);
207+
208+
$this->redirectResultMock->expects($this->once())
209+
->method('setUrl')
210+
->with($testUrl)
211+
->willReturnSelf();
212+
213+
$this->model->getDefaultRedirect();
214+
}
215+
195216
/**
217+
* @expectedException \Exception
218+
* @expectedExceptionMessage Bad request.
196219
* @dataProvider getParametersDataProvider
197220
*/
198221
public function testNoCustomerIdInRequest($customerId, $key)
@@ -210,27 +233,6 @@ public function testNoCustomerIdInRequest($customerId, $key)
210233
->with($this->equalTo('key'), false)
211234
->will($this->returnValue($key));
212235

213-
$exception = new \Exception('Bad request.');
214-
$this->messageManagerMock->expects($this->once())
215-
->method('addException')
216-
->with($this->equalTo($exception), $this->equalTo('There was an error confirming the account'));
217-
218-
$testUrl = 'http://example.com';
219-
$this->urlMock->expects($this->once())
220-
->method('getUrl')
221-
->with($this->equalTo('*/*/index'), ['_secure' => true])
222-
->will($this->returnValue($testUrl));
223-
224-
$this->redirectMock->expects($this->once())
225-
->method('error')
226-
->with($this->equalTo($testUrl))
227-
->will($this->returnValue($testUrl));
228-
229-
$this->redirectResultMock->expects($this->once())
230-
->method('setUrl')
231-
->with($this->equalTo($testUrl))
232-
->willReturnSelf();
233-
234236
$this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $this->model->execute());
235237
}
236238

@@ -315,9 +317,9 @@ public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $ad
315317
public function getSuccessMessageDataProvider()
316318
{
317319
return [
318-
[1, 1, false, null, __('Thank you for registering with')],
319-
[1, 1, true, Address::TYPE_BILLING, __('enter you billing address for proper VAT calculation')],
320-
[1, 1, true, Address::TYPE_SHIPPING, __('enter you shipping address for proper VAT calculation')],
320+
[1, 1, false, null, 'Thank you for registering with'],
321+
[1, 1, true, Address::TYPE_BILLING, 'enter you billing address for proper VAT calculation'],
322+
[1, 1, true, Address::TYPE_SHIPPING, 'enter you shipping address for proper VAT calculation'],
321323
];
322324
}
323325

@@ -390,18 +392,17 @@ public function testSuccessRedirect(
390392
->with($this->equalTo('*/*/index'), ['_secure' => true])
391393
->will($this->returnValue($successUrl));
392394

393-
$this->redirectMock->expects($this->never())
395+
$this->redirectMock->expects($this->once())
394396
->method('success')
395397
->with($this->equalTo($resultUrl))
396-
->will($this->returnValue($resultUrl));
398+
->willReturn($resultUrl);
397399

398-
$this->scopeConfigMock->expects($this->never())
400+
$this->scopeConfigMock->expects($this->once())
399401
->method('isSetFlag')
400-
->with(
401-
$this->equalTo(Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD),
402-
$this->equalTo(ScopeInterface::SCOPE_STORE)
402+
->with(Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD,
403+
ScopeInterface::SCOPE_STORE
403404
)
404-
->will($this->returnValue($isSetFlag));
405+
->willReturn($isSetFlag);
405406

406407
$this->model->execute();
407408
}
@@ -419,7 +420,7 @@ public function getSuccessRedirectDataProvider()
419420
null,
420421
'http://example.com/back',
421422
true,
422-
__('Thank you for registering with'),
423+
'Thank you for registering with',
423424
],
424425
[
425426
1,
@@ -428,7 +429,7 @@ public function getSuccessRedirectDataProvider()
428429
'http://example.com/success',
429430
'http://example.com/success',
430431
true,
431-
__('Thank you for registering with'),
432+
'Thank you for registering with',
432433
],
433434
[
434435
1,
@@ -437,7 +438,7 @@ public function getSuccessRedirectDataProvider()
437438
'http://example.com/success',
438439
'http://example.com/success',
439440
false,
440-
__('Thank you for registering with'),
441+
'Thank you for registering with',
441442
],
442443
];
443444
}

0 commit comments

Comments
 (0)