BUGFIX] Wrong renaming of DBAL dbPostgresqlTest
[Packages/TYPO3.CMS.git] / tests / Unit / t3lib / error / class.t3lib_error_productionexceptionhandlerTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Oliver Klee <typo3-coding@oliverklee.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24 /**
25 * testcase for the t3lib_error_ProductionExceptionHandler class.
26 *
27 * @author Oliver Klee <typo3-coding@oliverklee.de>
28 * @package TYPO3
29 * @subpackage t3lib_error
30 */
31 class t3lib_error_ProductionExceptionHandlerTest extends Tx_Phpunit_TestCase {
32
33 /**
34 * @var t3lib_error_ProductionExceptionHandler|PHPUnit_Framework_MockObject_MockObject
35 */
36 private $fixture = NULL;
37
38 /**
39 * Sets up this test case.
40 */
41 protected function setUp() {
42 $this->fixture = $this->getMock('TYPO3\\CMS\\Core\\Error\\ProductionExceptionHandler', array('discloseExceptionInformation', 'sendStatusHeaders', 'writeLogEntries'), array(), '', FALSE);
43 $this->fixture->expects($this->any())->method('discloseExceptionInformation')->will($this->returnValue(TRUE));
44 }
45
46 /**
47 * Tears down this test case.
48 */
49 protected function tearDown() {
50 unset($this->fixture);
51 }
52
53 /**
54 * @test
55 */
56 public function echoExceptionWebEscapesExceptionMessage() {
57 $message = '<b>b</b><script>alert(1);</script>';
58 $exception = new Exception($message);
59 ob_start();
60 $this->fixture->echoExceptionWeb($exception);
61 $output = ob_get_contents();
62 ob_end_clean();
63 $this->assertContains(htmlspecialchars($message), $output);
64 $this->assertNotContains($message, $output);
65 }
66
67 /**
68 * @test
69 */
70 public function echoExceptionWebEscapesExceptionTitle() {
71 $title = '<b>b</b><script>alert(1);</script>';
72 /** @var $exception Exception|PHPUnit_Framework_MockObject_MockObject */
73 $exception = $this->getMock('Exception', array('getTitle'), array('some message'));
74 $exception->expects($this->any())->method('getTitle')->will($this->returnValue($title));
75 ob_start();
76 $this->fixture->echoExceptionWeb($exception);
77 $output = ob_get_contents();
78 ob_end_clean();
79 $this->assertContains(htmlspecialchars($title), $output);
80 $this->assertNotContains($title, $output);
81 }
82
83 }
84
85 ?>