‪TYPO3CMS  9.5
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 
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪DebugUtilityTest extends UnitTestCase
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>',
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;',
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 => public 42 (integer)' . PHP_EOL
102  . ' bar => public 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 }
‪TYPO3\CMS\Core\Utility\DebugUtility\debug
‪static debug($var='', $header='Debug', $group='Debug')
Definition: DebugUtility.php:42
‪TYPO3\CMS\Core\Utility\DebugUtility\usePlainTextOutput
‪static usePlainTextOutput($plainTextOutput)
Definition: DebugUtility.php:237
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Tests\Unit\Utility\DebugUtilityTest\convertVariableToStringReturnsVariableContent
‪convertVariableToStringReturnsVariableContent($variable, $expected)
Definition: DebugUtilityTest.php:114
‪TYPO3\CMS\Core\Tests\Unit\Utility\DebugUtilityTest\convertVariableToStringReturnsVariableContentDataProvider
‪array convertVariableToStringReturnsVariableContentDataProvider()
Definition: DebugUtilityTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Utility\DebugUtilityTest
Definition: DebugUtilityTest.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\DebugUtilityTest\debugEncodesHtmlInputIfNoPlainText
‪debugEncodesHtmlInputIfNoPlainText()
Definition: DebugUtilityTest.php:54
‪TYPO3\CMS\Core\Tests\Unit\Utility\DebugUtilityTest\debugNotEncodesHtmlInputIfPlainText
‪debugNotEncodesHtmlInputIfPlainText()
Definition: DebugUtilityTest.php:35
‪TYPO3\CMS\Core\Utility\DebugUtility
Definition: DebugUtility.php:24
‪TYPO3\CMS\Core\Utility\DebugUtility\useAnsiColor
‪static useAnsiColor($ansiColorUsage)
Definition: DebugUtility.php:252
‪$output
‪$output
Definition: annotationChecker.php:113
‪TYPO3\CMS\Core\Tests\Unit\Utility\DebugUtilityTest\tearDown
‪tearDown()
Definition: DebugUtilityTest.php:25
‪TYPO3\CMS\Core\Utility\DebugUtility\convertVariableToString
‪static string convertVariableToString($variable)
Definition: DebugUtility.php:80