Skip to content

Commit 74f5e76

Browse files
committed
Merge remote-tracking branch 'origin/MC-16967' into 2.1.18-develop-pr76
2 parents 87accb7 + bfd7965 commit 74f5e76

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

app/code/Magento/Sales/Controller/Guest/View.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ public function __construct(
4949

5050
/**
5151
* @return \Magento\Framework\Controller\ResultInterface
52-
* @throws \Magento\Framework\Exception\NotFoundException
5352
*/
5453
public function execute()
5554
{
56-
if (!$this->getRequest()->isPost()) {
57-
throw new \Magento\Framework\Exception\NotFoundException(__('Page not found.'));
58-
}
59-
if (!$this->formKeyValidator->validate($this->getRequest())) {
60-
return $this->resultRedirectFactory->create()->setPath('*/*/form/');
55+
if ($this->getRequest()->isPost()) {
56+
if (!$this->formKeyValidator->validate($this->getRequest())) {
57+
return $this->resultRedirectFactory->create()->setPath('*/*/form/');
58+
}
6159
}
6260

6361
$result = $this->guestHelper->loadValidOrder($this->getRequest());

app/code/Magento/Sales/Test/Unit/Controller/Guest/ViewTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,15 @@ public function testExecuteOrderNotFound()
145145

146146
/**
147147
* @return void
148-
* @expectedException \Magento\Framework\Exception\NotFoundException
149-
* @expectedExceptionMessage Page not found.
150148
*/
151149
public function testExecuteWithNonPostRequest()
152150
{
153151
$this->requestMock->expects($this->once())->method('isPost')->willReturn(false);
154152

153+
$this->resultPageFactoryMock->expects($this->once())
154+
->method('create')
155+
->willReturn($this->resultPageMock);
156+
155157
$this->viewController->execute();
156158
}
157159

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Controller\Guest;
8+
9+
use Magento\TestFramework\Request;
10+
use Magento\TestFramework\TestCase\AbstractController;
11+
12+
/**
13+
* Test for \Magento\Sales\Controller\Guest\View class.
14+
*/
15+
class ViewTest extends AbstractController
16+
{
17+
/**
18+
* Check that controller applied GET requests.
19+
*/
20+
public function testExecuteWithGetRequest()
21+
{
22+
$this->getRequest()->setMethod(Request::METHOD_GET);
23+
$this->dispatch('sales/guest/view/');
24+
25+
$this->assertRedirect($this->stringContains('sales/guest/form'));
26+
}
27+
}

0 commit comments

Comments
 (0)