/**
  * @test
  */
 public function handleErrorReturnsTrueIfPageIsFound()
 {
     $expected = 'Error 404';
     /** @var \R3H6\Error404page\Domain\Model\Error $errorFixture */
     $errorFixture = new Error();
     /** @var \R3H6\Error404page\Domain\Model\Error $pageMock */
     $pageMock = $this->getPageMock(404, 'test');
     $this->pageRepositoryMock->expects($this->once())->method('find404PageForError')->with($errorFixture)->will($this->returnValue($pageMock));
     $this->httpServiceMock->expects($this->once())->method('readUrl')->with($this->equalTo('test'))->will($this->returnValue($expected));
     $this->assertTrue($this->subject->handleError($errorFixture));
     $this->assertSame($expected, $this->subject->getCachingData());
     $this->assertContains('pageId_404', $this->subject->getCacheTags());
 }
 public function handleErrorFindsLoginPageWhenConfigurationIsAuto()
 {
     $expected = 'http://www.typo3.org/login/';
     /** @var \R3H6\Error404page\Domain\Model\Error $errorFixture */
     $errorFixture = $this->getErrorFixture();
     /** @var \R3H6\Error404page\Domain\Model\Error $pageFixture */
     $pageFixture = new Page(array('uid' => 123, 'pid' => 1));
     $this->mockPageTsConfig($errorFixture, 'auto');
     $this->pageRepositoryMock->expects($this->once())->method('findLoginPageForError')->with($errorFixture)->will($this->returnValue(null));
     $this->frontendControllerMock->expects($this->once())->method('typoLink')->with($this->equalTo(array('parameter' => '123', 'forceAbsoluteUrl' => true)))->will($this->returnValue($expected));
     $return = $this->subject->handleError($errorFixture);
     $this->assertStringStartsWith($expected, $this->subject->getCachingData());
     $this->assertStringEndsWith('?redirect_url=' . $errorFixture->getUrl(), $this->subject->getCachingData());
     $this->assertContains('pageId_123', $this->subject->getCacheTags(), 'Invalid cache tags');
     $this->assertTrue($return, 'Error handler shoudl return true');
 }