request = $objectManager->get(RequestInterface::class); $this->frontController = $objectManager->get( FrontController::class ); $this->formKeyValidator = $objectManager->get(FormKeyValidator::class); } /** * @magentoAppArea frontend */ public function testTakenFromCookie() { if (!Bootstrap::canTestHeaders()) { $this->markTestSkipped( 'Can\'t test dispatch process without sending headers' ); } $_SERVER['HTTP_HOST'] = 'localhost'; $formKey = 'customFormKey'; $_COOKIE['form_key'] = $formKey; $this->request->setMethod(HttpRequest::METHOD_POST); $this->request->setParam('form_key', $formKey); $this->request->setRequestUri('core/index/index'); $this->frontController->dispatch($this->request); $this->assertTrue($this->formKeyValidator->validate($this->request)); } }