cookieManager = $this->_objectManager->get(CookieManagerInterface::class); $this->orderFactory = $this->_objectManager->get(OrderInterfaceFactory::class); $this->orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class); } /** * Check that controller applied GET requests. * * @return void */ public function testExecuteWithGetRequest(): void { $this->getRequest()->setMethod(Request::METHOD_GET); $this->dispatch('sales/guest/view/'); $this->assertRedirect($this->stringContains('sales/guest/form')); } /** * @magentoDataFixture Magento/Sales/_files/order.php * * @return void */ public function testExecuteWithWrongCookie(): void { $order = $this->orderFactory->create()->loadByIncrementId('100000001'); $order->setProtectCode('0e6640'); $this->orderRepository->save($order); $cookieValue = base64_encode('0' . ':' . $order->getIncrementId()); $this->cookieManager->setPublicCookie(Guest::COOKIE_NAME, $cookieValue); $this->getRequest()->setMethod(Request::METHOD_GET); $this->dispatch('sales/guest/view/'); $this->assertRedirect($this->stringContains('sales/guest/form/')); $this->assertSessionMessages( $this->containsEqual((string)__('You entered incorrect data. Please try again.')) ); } }