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