From fb31c4c94ec4a5c5bcef9b1c40937a61208aedec Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Mon, 30 Jan 2017 22:13:02 -0800 Subject: [PATCH 1/8] Update 'Continue Shopping' url. --- app/code/Magento/Checkout/view/frontend/templates/success.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/templates/success.phtml b/app/code/Magento/Checkout/view/frontend/templates/success.phtml index 5ef7e992c4e9c..659637fc60e2d 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/success.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/success.phtml @@ -22,7 +22,7 @@
- +
From 52e8f28026f82a1560d1cb1de6a9d4618965fafd Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Mon, 30 Jan 2017 22:15:58 -0800 Subject: [PATCH 2/8] Add getContinueUrl function --- app/code/Magento/Checkout/Block/Onepage/Success.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/code/Magento/Checkout/Block/Onepage/Success.php b/app/code/Magento/Checkout/Block/Onepage/Success.php index 210a1285b29fd..b017f474b562b 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Success.php +++ b/app/code/Magento/Checkout/Block/Onepage/Success.php @@ -122,4 +122,12 @@ protected function canViewOrder(Order $order) return $this->httpContext->getValue(Context::CONTEXT_AUTH) && $this->isVisible($order); } + + /** + * @return string + */ + public function getContinueUrl() + { + return $this->_storeManager->getStore()->getBaseUrl(); + } } From 7f86bc0c798ec2cec5405c56108a150a73237dcd Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Mon, 30 Jan 2017 22:23:12 -0800 Subject: [PATCH 3/8] Update SuccessTest.php --- .../Test/Unit/Block/Onepage/SuccessTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php index 09c3bff0d7dde..664d62310379b 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php @@ -27,12 +27,18 @@ class SuccessTest extends \PHPUnit_Framework_TestCase * @var \Magento\Checkout\Model\Session | \PHPUnit_Framework_MockObject_MockObject */ protected $checkoutSession; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->orderConfig = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); + $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); $this->checkoutSession = $this->getMockBuilder( \Magento\Checkout\Model\Session::class @@ -110,4 +116,13 @@ public function invisibleStatusesProvider() [['status1', 'status2'], true] ]; } + + public function testGetContinueUrl() + { + $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + $storeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('Expected Result')); + + $this->assertEquals('Expected Result', $this->block->getContinueUrl()); + } } From c6a9291e77bf2150d917afc93e40380522493515 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Tue, 31 Jan 2017 00:17:56 -0800 Subject: [PATCH 4/8] Update failing tests. --- .../Test/Unit/Block/Onepage/SuccessTest.php | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php index 664d62310379b..1cdd466b8764c 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php @@ -18,6 +18,11 @@ class SuccessTest extends \PHPUnit_Framework_TestCase */ protected $block; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $layout; + /** * @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject */ @@ -27,7 +32,7 @@ class SuccessTest extends \PHPUnit_Framework_TestCase * @var \Magento\Checkout\Model\Session | \PHPUnit_Framework_MockObject_MockObject */ protected $checkoutSession; - + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -38,17 +43,50 @@ protected function setUp() $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->orderConfig = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + + $this->layout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->checkoutSession = $this->getMockBuilder(\Magento\Checkout\Model\Session::class) + ->disableOriginalConstructor() + ->getMock(); - $this->checkoutSession = $this->getMockBuilder( - \Magento\Checkout\Model\Session::class - ) + $eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() + ->setMethods([]) ->getMock(); + $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $scopeConfig->expects($this->any()) + ->method('getValue') + ->with($this->stringContains('advanced/modules_disable_output/'), \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->will($this->returnValue(false)); + + $context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) + ->disableOriginalConstructor() + ->setMethods(['getLayout', 'getEventManager', 'getUrlBuilder', 'getScopeConfig', 'getStoreManager']) + ->getMock(); + $context->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout)); + $context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager)); + $context->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); + $context->expects($this->any())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); + $context->expects($this->any())->method('getStoreManager')->will($this->returnValue($this->storeManagerMock)); + $this->block = $objectManager->getObject( \Magento\Checkout\Block\Onepage\Success::class, [ + 'context' => $context, 'orderConfig' => $this->orderConfig, 'checkoutSession' => $this->checkoutSession ] @@ -116,7 +154,7 @@ public function invisibleStatusesProvider() [['status1', 'status2'], true] ]; } - + public function testGetContinueUrl() { $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); From fab492166512eb2c84a18a1eb67636c4bfda702e Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Tue, 31 Jan 2017 08:25:03 -0800 Subject: [PATCH 5/8] Fix Code Sniffer errors. Fix line exceeded max length issue. Use ::class syntax. --- .../Checkout/Test/Unit/Block/Onepage/SuccessTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php index 1cdd466b8764c..d64a883426d9f 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php @@ -70,7 +70,11 @@ protected function setUp() ->getMock(); $scopeConfig->expects($this->any()) ->method('getValue') - ->with($this->stringContains('advanced/modules_disable_output/'), \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->with( + $this->stringContains( + 'advanced/modules_disable_output/'), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) ->will($this->returnValue(false)); $context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) @@ -157,7 +161,7 @@ public function invisibleStatusesProvider() public function testGetContinueUrl() { - $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('Expected Result')); From d8eaa8f9ee236c7b8516927a683e180c0fe011f9 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Tue, 31 Jan 2017 10:15:39 -0800 Subject: [PATCH 6/8] Remove whitespace. Move parenthesis to new line --- .../Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php index d64a883426d9f..18f3c262c5c2a 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php @@ -72,8 +72,9 @@ protected function setUp() ->method('getValue') ->with( $this->stringContains( - 'advanced/modules_disable_output/'), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + 'advanced/modules_disable_output/' + ), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) ->will($this->returnValue(false)); From 6c0e8964602028ff30a756d126f4425a6a133d9f Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Tue, 31 Jan 2017 10:37:20 -0800 Subject: [PATCH 7/8] Suppress CouplingBetweenObjects warning for test class --- .../Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php index 18f3c262c5c2a..e22fe32dbbf7c 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php @@ -10,6 +10,7 @@ /** * Class SuccessTest * @package Magento\Checkout\Block\Onepage + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SuccessTest extends \PHPUnit_Framework_TestCase { From 8d007b15fcf68f93e831bd8f3c9ac8a292a6e99d Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Tue, 31 Jan 2017 13:27:20 -0800 Subject: [PATCH 8/8] Remove whitespace at end of line. --- app/code/Magento/Checkout/Block/Onepage/Success.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Block/Onepage/Success.php b/app/code/Magento/Checkout/Block/Onepage/Success.php index b017f474b562b..bfff407a902a2 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Success.php +++ b/app/code/Magento/Checkout/Block/Onepage/Success.php @@ -122,7 +122,7 @@ protected function canViewOrder(Order $order) return $this->httpContext->getValue(Context::CONTEXT_AUTH) && $this->isVisible($order); } - + /** * @return string */