Esempio n. 1
0
 /**
  * Test Page Check Controller with Existing Page
  *
  * @return void
  *
  * @covers \Rcm\Controller\PageCheckController
  */
 public function testPageCheckControllerGetMethodWithExistingPage()
 {
     $this->mockPageValidator->expects($this->any())->method('isValid')->will($this->returnValue(false));
     $this->mockPageValidator->expects($this->any())->method('getMessages')->will($this->returnValue(["pageExists" => 'Page Exists']));
     $this->routeMatch->setParam('pageId', 'page-exists');
     /** @var \Zend\View\Model\JsonModel $result */
     $result = $this->controller->dispatch($this->request);
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $result);
     $response = $this->controller->getResponse();
     $this->assertEquals(409, $response->getStatusCode());
     $result = $result->getVariables();
     $expected = ['valid' => false, 'error' => ['pageExists' => 'Page Exists']];
     $this->assertEquals($expected, $result);
 }
Esempio n. 2
0
 /**
  * Test the index controller with Layout Template override
  *
  * @return null
  * @covers Rcm\Controller\IndexController
  */
 public function testIndexActionWithLayoutOverride()
 {
     $this->layoutOverride = 'newLayout';
     $this->pageData = $this->getPageData(42, 'my-test', 443, 'z', false, $this->layoutOverride);
     $this->routeMatch->setParam('action', 'index');
     $this->routeMatch->setParam('page', 'my-test');
     $this->routeMatch->setParam('pageType', 'z');
     $this->routeMatch->setParam('revision', 443);
     $this->mockUserServicePlugin->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $this->mockShouldShowRevisions->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $this->mockIsPageAllowed->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $result = $this->controller->dispatch($this->request);
     /** @var \Zend\Http\Response $response */
     $response = $this->controller->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('my-test', $this->controller->pageName);
     $this->assertEquals('z', $this->controller->pageType);
     $this->assertEquals(443, $this->controller->pageRevisionId);
     $this->assertEquals('layout/' . $this->layoutOverride, $this->controller->layout()->getTemplate());
 }