TYPO3 CMS  TYPO3_6-2
ProductionExceptionHandlerTest.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $fixture = NULL;
28 
32  protected function setUp() {
33  $this->fixture = $this->getMock('TYPO3\\CMS\\Core\\Error\\ProductionExceptionHandler', array('discloseExceptionInformation', 'sendStatusHeaders', 'writeLogEntries'), array(), '', FALSE);
34  $this->fixture->expects($this->any())->method('discloseExceptionInformation')->will($this->returnValue(TRUE));
35  }
36 
41  $message = '<b>b</b><script>alert(1);</script>';
42  $exception = new \Exception($message);
43  ob_start();
44  $this->fixture->echoExceptionWeb($exception);
45  $output = ob_get_contents();
46  ob_end_clean();
47  $this->assertContains(htmlspecialchars($message), $output);
48  $this->assertNotContains($message, $output);
49  }
50 
54  public function echoExceptionWebEscapesExceptionTitle() {
55  $title = '<b>b</b><script>alert(1);</script>';
57  $exception = $this->getMock('Exception', array('getTitle'), array('some message'));
58  $exception->expects($this->any())->method('getTitle')->will($this->returnValue($title));
59  ob_start();
60  $this->fixture->echoExceptionWeb($exception);
61  $output = ob_get_contents();
62  ob_end_clean();
63  $this->assertContains(htmlspecialchars($title), $output);
64  $this->assertNotContains($title, $output);
65  }
66 
67 }