diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml
index ca8a35ee7a363..ceed14e76fb4b 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml
@@ -42,9 +42,13 @@
-
-
-
+
+
+
+
+
+
+
@@ -64,9 +68,11 @@
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml
index 79d85c6ced957..228c1d3cf1def 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml
@@ -109,9 +109,11 @@
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSelectAttributeSetOnEditProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSelectAttributeSetOnEditProductPageActionGroup.xml
new file mode 100644
index 0000000000000..31a4521331664
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSelectAttributeSetOnEditProductPageActionGroup.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ Selects the specified value from the Attribute Set dropdown on the opened product edit page.
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontHoverProductOnCategoryPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontHoverProductOnCategoryPageActionGroup.xml
new file mode 100644
index 0000000000000..10d85a91a02c6
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontHoverProductOnCategoryPageActionGroup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ Hover product on the Category page
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml
index 92be79fdfe720..995fa4c7e5977 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml
@@ -20,7 +20,7 @@
-
+
@@ -30,6 +30,7 @@
+
@@ -37,74 +38,92 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ($grabTextFromSuccessMessage)
- You added product $$product.name$$ to the comparison list.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ($grabTextFromSuccessMessage)
- You added product $$product.name$$ to the comparison list.
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml
index 3b8c2cb736721..e7d4241500bfb 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml
@@ -60,9 +60,11 @@
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml
index 9fef5e4203167..8d3fbbaa34355 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml
@@ -64,9 +64,11 @@
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml
index d2278f3ddae1d..d1110f593545d 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml
@@ -62,9 +62,11 @@
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php
index be0afdb4a043b..c5832f64547c1 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php
@@ -6,8 +6,9 @@
namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo;
use Magento\Backend\App\Action;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
-class View extends \Magento\Backend\App\Action
+class View extends \Magento\Backend\App\Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
@@ -75,9 +76,9 @@ public function execute()
}
return $resultPage;
} else {
- $resultForward = $this->resultForwardFactory->create();
- $resultForward->forward('noroute');
- return $resultForward;
+ $resultRedirect = $this->resultRedirectFactory->create();
+ $resultRedirect->setPath('sales/creditmemo');
+ return $resultRedirect;
}
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php
index 0c5864e954a4f..c1e79b95af038 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php
@@ -8,12 +8,12 @@
use Magento\Framework\DataObject;
use Magento\Sales\Api\CreditmemoRepositoryInterface;
-use \Magento\Sales\Model\Order\CreditmemoFactory;
+use Magento\Sales\Model\Order;
+use Magento\Sales\Model\Order\CreditmemoFactory;
/**
- * Class CreditmemoLoader
+ * Loader for creditmemo
*
- * @package Magento\Sales\Controller\Adminhtml\Order
* @method CreditmemoLoader setCreditmemoId($id)
* @method CreditmemoLoader setCreditmemo($creditMemo)
* @method CreditmemoLoader setInvoiceId($id)
@@ -22,6 +22,7 @@
* @method string getCreditmemo()
* @method int getInvoiceId()
* @method int getOrderId()
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class CreditmemoLoader extends DataObject
{
@@ -129,7 +130,8 @@ protected function _getItemData()
/**
* Check if creditmeno can be created for order
- * @param \Magento\Sales\Model\Order $order
+ *
+ * @param Order $order
* @return bool
*/
protected function _canCreditmemo($order)
@@ -153,7 +155,9 @@ protected function _canCreditmemo($order)
}
/**
- * @param \Magento\Sales\Model\Order $order
+ * Inits invoice
+ *
+ * @param Order $order
* @return $this|bool
*/
protected function _initInvoice($order)
@@ -181,7 +185,12 @@ public function load()
$creditmemoId = $this->getCreditmemoId();
$orderId = $this->getOrderId();
if ($creditmemoId) {
- $creditmemo = $this->creditmemoRepository->get($creditmemoId);
+ try {
+ $creditmemo = $this->creditmemoRepository->get($creditmemoId);
+ } catch (\Exception $e) {
+ $this->messageManager->addErrorMessage(__('This creditmemo no longer exists.'));
+ return false;
+ }
} elseif ($orderId) {
$data = $this->getCreditmemo();
$order = $this->orderFactory->create()->load($orderId);
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php
index da700aae2f78a..b0e860d7f2e2d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php
@@ -44,9 +44,10 @@ public function execute()
{
$invoice = $this->getInvoice();
if (!$invoice) {
- /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
- $resultForward = $this->resultForwardFactory->create();
- return $resultForward->forward('noroute');
+ /** @var \Magento\Framework\Controller\Result\RedirectFactory $resultRedirect */
+ $resultRedirect = $this->resultRedirectFactory->create();
+ $resultRedirect->setPath('sales/invoice');
+ return $resultRedirect;
}
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminGoToCreditmemoViewActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminGoToCreditmemoViewActionGroup.xml
new file mode 100644
index 0000000000000..08d02fe2b7bb1
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminGoToCreditmemoViewActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Goes to the Order Creditmemo View Page.
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml b/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml
index 2e61424b29a56..2a3bc814364ae 100644
--- a/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminOpenCreditmemoViewPageWithWrongCreditmemoIdTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminOpenCreditmemoViewPageWithWrongCreditmemoIdTest.xml
new file mode 100644
index 0000000000000..38b85828c3421
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminOpenCreditmemoViewPageWithWrongCreditmemoIdTest.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php
index 46c3113c8edc2..b7249e2af295c 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php
@@ -13,6 +13,8 @@
use Magento\Backend\Model\View\Result\Forward;
use Magento\Backend\Model\View\Result\ForwardFactory;
use Magento\Backend\Model\View\Result\Page;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
use Magento\Framework\App\ActionFlag;
use Magento\Framework\App\Request\Http;
use Magento\Framework\Message\Manager;
@@ -105,6 +107,17 @@ class ViewTest extends TestCase
*/
protected $pageTitleMock;
+ /**
+ * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\View
+ * @var RedirectFactory|MockObject
+ */
+ protected $resultRedirectFactoryMock;
+
+ /**
+ * @var Redirect|MockObject
+ */
+ protected $resultRedirectMock;
+
/**
* @var PageFactory|MockObject
*/
@@ -130,9 +143,6 @@ class ViewTest extends TestCase
*/
protected function setUp(): void
{
- $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class)
- ->disableOriginalConstructor()
- ->getMock();
$this->invoiceMock = $this->getMockBuilder(Invoice::class)
->disableOriginalConstructor()
->getMock();
@@ -203,7 +213,13 @@ protected function setUp(): void
$this->resultForwardMock = $this->getMockBuilder(Forward::class)
->disableOriginalConstructor()
->getMock();
-
+ $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+ $this->resultRedirectMock = $this->getMockBuilder(Redirect::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$this->contextMock->expects($this->any())
->method('getSession')
->willReturn($this->sessionMock);
@@ -219,9 +235,6 @@ protected function setUp(): void
$this->contextMock->expects($this->any())
->method('getObjectManager')
->willReturn($this->objectManagerMock);
- $this->contextMock->expects($this->any())
- ->method('getTitle')
- ->willReturn($titleMock);
$this->contextMock->expects($this->any())
->method('getMessageManager')
->willReturn($this->messageManagerMock);
@@ -239,7 +252,8 @@ protected function setUp(): void
'context' => $this->contextMock,
'creditmemoLoader' => $this->loaderMock,
'resultPageFactory' => $this->resultPageFactoryMock,
- 'resultForwardFactory' => $this->resultForwardFactoryMock
+ 'resultForwardFactory' => $this->resultForwardFactoryMock,
+ 'resultRedirectFactory' => $this->resultRedirectFactoryMock
]
);
}
@@ -252,16 +266,11 @@ public function testExecuteNoCreditMemo()
$this->loaderMock->expects($this->once())
->method('load')
->willReturn(false);
- $this->resultForwardFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->resultForwardMock);
- $this->resultForwardMock->expects($this->once())
- ->method('forward')
- ->with('noroute')
- ->willReturnSelf();
+ $this->prepareRedirect();
+ $this->setPath('sales/creditmemo');
$this->assertInstanceOf(
- Forward::class,
+ Redirect::class,
$this->controller->execute()
);
}
@@ -322,4 +331,25 @@ public function executeDataProvider()
[$this->invoiceMock]
];
}
+
+ /**
+ * prepareRedirect
+ */
+ protected function prepareRedirect()
+ {
+ $this->resultRedirectFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->resultRedirectMock);
+ }
+
+ /**
+ * @param string $path
+ * @param array $params
+ */
+ protected function setPath($path, $params = [])
+ {
+ $this->resultRedirectMock->expects($this->once())
+ ->method('setPath')
+ ->with($path, $params);
+ }
}
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php
index c8376ab379b6f..3429b3df85b8a 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php
@@ -13,6 +13,8 @@
use Magento\Backend\Model\View\Result\Forward;
use Magento\Backend\Model\View\Result\ForwardFactory;
use Magento\Backend\Model\View\Result\Page;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
use Magento\Framework\App\ActionFlag;
use Magento\Framework\App\Request\Http;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
@@ -29,6 +31,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD.TooManyFields)
*/
class ViewTest extends TestCase
{
@@ -82,6 +85,17 @@ class ViewTest extends TestCase
*/
protected $pageTitleMock;
+ /**
+ * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\View
+ * @var RedirectFactory|MockObject
+ */
+ protected $resultRedirectFactoryMock;
+
+ /**
+ * @var Redirect|MockObject
+ */
+ protected $resultRedirectMock;
+
/**
* @var View
*/
@@ -114,10 +128,6 @@ protected function setUp(): void
->disableOriginalConstructor()
->setMethods([])
->getMock();
- $this->titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class)
- ->disableOriginalConstructor()
- ->setMethods([])
- ->getMock();
$this->viewMock = $this->getMockBuilder(\Magento\Framework\App\View::class)
->disableOriginalConstructor()
->setMethods([])
@@ -163,9 +173,6 @@ protected function setUp(): void
$contextMock->expects($this->any())
->method('getResponse')
->willReturn($this->responseMock);
- $contextMock->expects($this->any())
- ->method('getTitle')
- ->willReturn($this->titleMock);
$contextMock->expects($this->any())
->method('getView')
->willReturn($this->viewMock);
@@ -194,6 +201,13 @@ protected function setUp(): void
)->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
+ $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+ $this->resultRedirectMock = $this->getMockBuilder(Redirect::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -203,7 +217,8 @@ protected function setUp(): void
[
'context' => $contextMock,
'resultPageFactory' => $this->resultPageFactoryMock,
- 'resultForwardFactory' => $this->resultForwardFactoryMock
+ 'resultForwardFactory' => $this->resultForwardFactoryMock,
+ 'resultRedirectFactory' => $this->resultRedirectFactoryMock
]
);
@@ -287,16 +302,32 @@ public function testExecuteNoInvoice()
->method('get')
->willReturn(null);
- $resultForward = $this->getMockBuilder(Forward::class)
- ->disableOriginalConstructor()
- ->setMethods([])
- ->getMock();
- $resultForward->expects($this->once())->method('forward')->with(('noroute'))->willReturnSelf();
+ $this->prepareRedirect();
+ $this->setPath('sales/invoice');
+ $this->assertInstanceOf(
+ Redirect::class,
+ $this->controller->execute()
+ );
+ }
- $this->resultForwardFactoryMock->expects($this->once())
+ /**
+ * prepareRedirect
+ */
+ protected function prepareRedirect()
+ {
+ $this->resultRedirectFactoryMock->expects($this->once())
->method('create')
- ->willReturn($resultForward);
+ ->willReturn($this->resultRedirectMock);
+ }
- $this->assertSame($resultForward, $this->controller->execute());
+ /**
+ * @param string $path
+ * @param array $params
+ */
+ protected function setPath($path, $params = [])
+ {
+ $this->resultRedirectMock->expects($this->once())
+ ->method('setPath')
+ ->with($path, $params);
}
}
diff --git a/app/code/Magento/Sales/i18n/en_US.csv b/app/code/Magento/Sales/i18n/en_US.csv
index 13afa0832086e..ce8cbcb181dcd 100644
--- a/app/code/Magento/Sales/i18n/en_US.csv
+++ b/app/code/Magento/Sales/i18n/en_US.csv
@@ -804,4 +804,5 @@ If set YES Email field will be required during Admin order creation for new Cust
"Please enter a coupon code!","Please enter a coupon code!"
"Reorder is not available.","Reorder is not available."
"The coupon code has been removed.","The coupon code has been removed."
+"This creditmemo no longer exists.","This creditmemo no longer exists."
"Add to address book","Add to address book"
diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php
index d8fda0bfe781b..d903a1a7d5889 100644
--- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php
+++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php
@@ -7,8 +7,9 @@
namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment;
use Magento\Backend\App\Action;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
-class View extends \Magento\Backend\App\Action
+class View extends \Magento\Backend\App\Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
@@ -71,9 +72,9 @@ public function execute()
$resultPage->getConfig()->getTitle()->prepend("#" . $shipment->getIncrementId());
return $resultPage;
} else {
- $resultForward = $this->resultForwardFactory->create();
- $resultForward->forward('noroute');
- return $resultForward;
+ $resultRedirect = $this->resultRedirectFactory->create();
+ $resultRedirect->setPath('sales/shipment');
+ return $resultRedirect;
}
}
}
diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php
index c4094a63ec527..5f0a2fb24c96f 100644
--- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php
+++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php
@@ -18,9 +18,8 @@
use Magento\Sales\Api\Data\ShipmentItemCreationInterface;
/**
- * Class ShipmentLoader
+ * Loader for shipment
*
- * @package Magento\Shipping\Controller\Adminhtml\Order
* @method ShipmentLoader setOrderId($id)
* @method ShipmentLoader setShipmentId($id)
* @method ShipmentLoader setShipment($shipment)
@@ -110,7 +109,12 @@ public function load()
$orderId = $this->getOrderId();
$shipmentId = $this->getShipmentId();
if ($shipmentId) {
- $shipment = $this->shipmentRepository->get($shipmentId);
+ try {
+ $shipment = $this->shipmentRepository->get($shipmentId);
+ } catch (\Exception $e) {
+ $this->messageManager->addErrorMessage(__('This shipment no longer exists.'));
+ return false;
+ }
} elseif ($orderId) {
$order = $this->orderRepository->get($orderId);
diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminGoToShipmentViewActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminGoToShipmentViewActionGroup.xml
new file mode 100644
index 0000000000000..14587e17f75ba
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminGoToShipmentViewActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Goes to the Order Shipment View Page.
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentViewPage.xml b/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentViewPage.xml
new file mode 100644
index 0000000000000..e78a4d5b2701c
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentViewPage.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminOpenShipmentViewPageWithWrongShipmentIdTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminOpenShipmentViewPageWithWrongShipmentIdTest.xml
new file mode 100644
index 0000000000000..d60dca08e6813
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminOpenShipmentViewPageWithWrongShipmentIdTest.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php
index 04b357eeaefca..aa983aa5c86ce 100644
--- a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php
+++ b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php
@@ -11,6 +11,8 @@
use Magento\Backend\Model\View\Result\Forward;
use Magento\Backend\Model\View\Result\ForwardFactory;
use Magento\Backend\Model\View\Result\Page;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
@@ -21,6 +23,7 @@
use Magento\Sales\Model\Order\Shipment;
use Magento\Shipping\Block\Adminhtml\View;
use Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader;
+use Magento\Shipping\Controller\Adminhtml\Order\Shipment\View as OrderShipmentView;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -86,6 +89,17 @@ class ViewTest extends TestCase
/**
* @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\View
+ * @var RedirectFactory|MockObject
+ */
+ protected $resultRedirectFactoryMock;
+
+ /**
+ * @var Redirect|MockObject
+ */
+ protected $resultRedirectMock;
+
+ /**
+ * @var OrderShipmentView
*/
protected $controller;
@@ -130,16 +144,25 @@ protected function setUp(): void
['updateBackButtonUrl']
);
+ $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+ $this->resultRedirectMock = $this->getMockBuilder(Redirect::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$objectManager = new ObjectManager($this);
$context = $objectManager->getObject(
Context::class,
[
'request' => $this->requestMock,
- 'objectManager' => $this->objectManagerMock
+ 'objectManager' => $this->objectManagerMock,
+ 'resultRedirectFactory' => $this->resultRedirectFactoryMock
]
);
$this->controller = $objectManager->getObject(
- \Magento\Shipping\Controller\Adminhtml\Order\Shipment\View::class,
+ OrderShipmentView::class,
[
'context' => $context,
'shipmentLoader' => $this->shipmentLoaderMock,
@@ -216,15 +239,12 @@ public function testExecuteNoShipment()
$tracking = [];
$this->loadShipment($orderId, $shipmentId, $shipment, $tracking, null, false);
- $this->resultForwardFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->resultForwardMock);
- $this->resultForwardMock->expects($this->once())
- ->method('forward')
- ->with('noroute')
- ->willReturnSelf();
-
- $this->assertEquals($this->resultForwardMock, $this->controller->execute());
+ $this->prepareRedirect();
+ $this->setPath('sales/shipment');
+ $this->assertInstanceOf(
+ Redirect::class,
+ $this->controller->execute()
+ );
}
/**
@@ -255,4 +275,25 @@ protected function loadShipment($orderId, $shipmentId, $shipment, $tracking, $co
->method('load')
->willReturn($returnShipment);
}
+
+ /**
+ * prepareRedirect
+ */
+ protected function prepareRedirect()
+ {
+ $this->resultRedirectFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->resultRedirectMock);
+ }
+
+ /**
+ * @param string $path
+ * @param array $params
+ */
+ protected function setPath($path, $params = [])
+ {
+ $this->resultRedirectMock->expects($this->once())
+ ->method('setPath')
+ ->with($path, $params);
+ }
}
diff --git a/app/code/Magento/Shipping/i18n/en_US.csv b/app/code/Magento/Shipping/i18n/en_US.csv
index f777e64ef98c9..0989f1bab4a3d 100644
--- a/app/code/Magento/Shipping/i18n/en_US.csv
+++ b/app/code/Magento/Shipping/i18n/en_US.csv
@@ -177,3 +177,4 @@ City,City
"Shipping Methods","Shipping Methods"
"Track your order","Track your order"
"Track All Shipments","Track All Shipments"
+"This shipment no longer exists.","This shipment no longer exists."