diff --git a/app/code/Magento/Checkout/Block/Onepage/Success.php b/app/code/Magento/Checkout/Block/Onepage/Success.php index 210a1285b29fd..bfff407a902a2 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(); + } } 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..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 { @@ -18,6 +19,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 */ @@ -28,21 +34,65 @@ class SuccessTest extends \PHPUnit_Framework_TestCase */ 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::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 ] @@ -110,4 +160,13 @@ public function invisibleStatusesProvider() [['status1', 'status2'], true] ]; } + + public function testGetContinueUrl() + { + $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')); + + $this->assertEquals('Expected Result', $this->block->getContinueUrl()); + } } 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 @@