TYPO3 CMS  TYPO3_7-6
DebugUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
25  protected function tearDown()
26  {
27  parent::tearDown();
30  }
31 
36  {
39 
40  ob_start();
41  DebugUtility::debug('<script>alert(\'Hello world!\')</script>');
42  $output = ob_get_contents();
43  ob_end_clean();
44 
45  $this->assertContains(
46  '<script>alert(\'Hello world!\')</script>',
47  $output
48  );
49  }
50 
55  {
58 
59  ob_start();
60  DebugUtility::debug('<script>alert(\'Hello world!\')</script>');
61  $output = ob_get_contents();
62  ob_end_clean();
63 
64  $this->assertContains(
65  '&lt;script&gt;alert(\'Hello world!\')&lt;/script&gt;',
66  $output
67  );
68  }
69 
74  {
75  $object = new \stdClass();
76  $object->foo = 42;
77  $object->bar = ['baz'];
78 
79  return [
80  'Debug string' => [
81  'Hello world!',
82  '"Hello world!" (12 chars)',
83  ],
84  'Debug array' => [
85  [
86  'foo',
87  'bar',
88  'baz' => [
89  42,
90  ],
91  ],
92  'array(3 items)' . PHP_EOL
93 . ' 0 => "foo" (3 chars)' . PHP_EOL
94 . ' 1 => "bar" (3 chars)' . PHP_EOL
95 . ' baz => array(1 item)' . PHP_EOL
96 . ' 0 => 42 (integer)',
97  ],
98  'Debug object' => [
99  $object,
100  'stdClass prototype object' . PHP_EOL
101 . ' foo => 42 (integer)' . PHP_EOL
102 . ' bar => array(1 item)' . PHP_EOL
103 . ' 0 => "baz" (3 chars)'
104  ],
105  ];
106  }
107 
114  public function convertVariableToStringReturnsVariableContent($variable, $expected)
115  {
116  $this->assertSame($expected, DebugUtility::convertVariableToString($variable));
117  }
118 }
static debug($var='', $header='', $group='Debug')
static useAnsiColor($ansiColorUsage)
static convertVariableToString($variable)
static usePlainTextOutput($plainTextOutput)