public function prepareMocksForTestExecute() { $postData = [1 => ['title' => '404 Not Found', 'identifier' => 'no-route', 'custom_theme' => '1', 'custom_root_template' => '2']]; $this->request->expects($this->any())->method('getParam')->willReturnMap([['isAjax', null, true], ['items', [], $postData]]); $this->pageRepository->expects($this->once())->method('getById')->with(1)->willReturn($this->cmsPage); $this->dataProcessor->expects($this->once())->method('filter')->with($postData[1])->willReturnArgument(0); $this->dataProcessor->expects($this->once())->method('validate')->with($postData[1])->willReturn(false); $this->messageManager->expects($this->once())->method('getMessages')->with(true)->willReturn($this->messageCollection); $this->messageCollection->expects($this->once())->method('getItems')->willReturn([$this->message]); $this->message->expects($this->once())->method('getText')->willReturn('Error message'); $this->cmsPage->expects($this->atLeastOnce())->method('getId')->willReturn('1'); $this->cmsPage->expects($this->atLeastOnce())->method('getData')->willReturn(['layout' => '1column', 'identifier' => 'test-identifier']); $this->cmsPage->expects($this->once())->method('setData')->with(['layout' => '1column', 'title' => '404 Not Found', 'identifier' => 'no-route', 'custom_theme' => '1', 'custom_root_template' => '2']); $this->jsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson); }
protected function prepareMocksForErrorMessagesProcessing() { $this->messageManager->expects($this->atLeastOnce())->method('getMessages')->willReturn($this->messageCollection); $this->messageCollection->expects($this->once())->method('getItems')->willReturn([$this->message]); $this->messageCollection->expects($this->once())->method('getCount')->willReturn(1); $this->message->expects($this->once())->method('getText')->willReturn('Error text'); $this->resultJson->expects($this->once())->method('setData')->with(['messages' => ['Error text'], 'error' => true])->willReturnSelf(); }