TYPO3CMS
9.5
Main Page
Related Pages
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Files
File List
File Members
All
$
d
e
r
u
Functions
Variables
$
e
r
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Pages
DebugUtilityTest.php
Go to the documentation of this file.
1
<?php
2
namespace
TYPO3\CMS\Core\Tests\Unit\Utility
;
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
17
use
TYPO3\CMS\Core\Utility\DebugUtility
;
18
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19
23
class
DebugUtilityTest
extends
UnitTestCase
24
{
25
protected
function
tearDown
()
26
{
27
parent::tearDown();
28
DebugUtility::usePlainTextOutput
(
true
);
29
DebugUtility::useAnsiColor
(
true
);
30
}
31
35
public
function
debugNotEncodesHtmlInputIfPlainText
()
36
{
37
DebugUtility::usePlainTextOutput
(
true
);
38
DebugUtility::useAnsiColor
(
false
);
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
54
public
function
debugEncodesHtmlInputIfNoPlainText
()
55
{
56
DebugUtility::usePlainTextOutput
(
false
);
57
DebugUtility::useAnsiColor
(
false
);
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
'<script>alert(\'Hello world!\')</script>'
,
66
$output
67
);
68
}
69
73
public
function
convertVariableToStringReturnsVariableContentDataProvider
()
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
doxygen
typo3
sysext
core
Tests
Unit
Utility
DebugUtilityTest.php
Generated on Tue Oct 5 2021 01:57:26 for TYPO3CMS by
1.8.18