This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace KochTest\Debug; |
||
4 | |||
5 | use Koch\Debug\Debug; |
||
6 | |||
7 | class DebugTest extends \PHPUnit_Framework_TestCase |
||
8 | { |
||
9 | /** |
||
10 | * @var Debug |
||
11 | */ |
||
12 | protected $object; |
||
13 | |||
14 | /** |
||
15 | * Sets up the fixture, for example, opens a network connection. |
||
16 | * This method is called before a test is executed. |
||
17 | */ |
||
18 | public function setUp() |
||
19 | { |
||
20 | $this->object = new Debug(); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Tears down the fixture, for example, closes a network connection. |
||
25 | * This method is called after a test is executed. |
||
26 | */ |
||
27 | public function tearDown() |
||
28 | { |
||
29 | unset($this->object); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @covers Koch\Debug\Debug::printR |
||
34 | */ |
||
35 | public function testPrintR() |
||
36 | { |
||
37 | |||
38 | // NOTE: this is NOWDOC instead of HEREDOC |
||
39 | // so its without parsing, because of the inlined $var |
||
40 | $expectedOutput = <<<'EOD' |
||
41 | <pre><b>Debugging <font color=red>DebugTest.php</font> on line <font color=red>64</font></b>: |
||
42 | <div style='background: #f5f5f5; padding: 0.2em 0em;'> \Koch\Debug\Debug::printR($var, $var2, $string); |
||
43 | </div> |
||
44 | <b>Type</b>: array |
||
45 | <b>Length</b>: 1 |
||
46 | <b>Value</b>: Array |
||
47 | ( |
||
48 | [Key] => Value |
||
49 | ) |
||
50 | <b>Length</b>: 1 |
||
51 | <b>Value</b>: Array |
||
52 | ( |
||
53 | [Key2] => Value2 |
||
54 | ) |
||
55 | <b>Length</b>: 13 |
||
56 | <b>Value</b>: Just a string</pre> |
||
57 | EOD; |
||
58 | |||
59 | $this->expectOutputString($expectedOutput); |
||
60 | |||
61 | $var = ['Key' => 'Value']; |
||
62 | $var2 = ['Key2' => 'Value2']; |
||
63 | $string = 'Just a string'; |
||
64 | \Koch\Debug\Debug::printR($var, $var2, $string); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @covers Koch\Debug\Debug::dump |
||
69 | */ |
||
70 | public function testDump() |
||
71 | { |
||
72 | /* |
||
73 | * finally after 18 or something years, someone decided to add <pre> tags to var_dump() |
||
74 | * in PHP 5.5.0alpha1! thats utterly impressive! |
||
75 | * are you fucking serious? Come get some! |
||
76 | */ |
||
77 | |||
78 | // NOTE: this is NOWDOC instead of HEREDOC |
||
79 | // so its without parsing, because of the inlined $var |
||
80 | $expectedOutput = <<<'EOD' |
||
81 | Debugging DebugTest.php on line 92: \Koch\Debug\Debug::dump($var); |
||
82 | array(1) { |
||
83 | 'Key' => |
||
84 | string(5) "Value" |
||
85 | } |
||
86 | |||
87 | EOD; |
||
88 | |||
89 | $this->expectOutputString($expectedOutput); |
||
90 | |||
91 | $var = ['Key' => 'Value']; |
||
92 | \Koch\Debug\Debug::dump($var); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @covers Koch\Debug\Debug::getOriginOfDebugCall |
||
97 | */ |
||
98 | public function testGetOriginOfDebugCall() |
||
0 ignored issues
–
show
|
|||
99 | { |
||
100 | // NOTE: this is NOWDOC instead of HEREDOC |
||
101 | // so its without parsing, because of the inlined $var |
||
102 | $expectedOutput = <<<'EOD' |
||
103 | Debugging DebugTest.php on line 109: \Koch\Debug\Debug::getOriginOfDebugCall(0); |
||
104 | |||
105 | EOD; |
||
106 | $this->expectOutputString($expectedOutput); |
||
107 | |||
108 | $_SERVER['REMOTE_ADDR'] = null; |
||
109 | \Koch\Debug\Debug::getOriginOfDebugCall(0); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @covers Koch\Debug\Debug::getIncludedFiles |
||
114 | */ |
||
115 | public function testGetIncludedFiles() |
||
116 | { |
||
117 | $returnArray = true; |
||
118 | $array = \Koch\Debug\Debug::getIncludedFiles($returnArray); |
||
119 | |||
120 | $this->assertTrue(is_array($array)); |
||
121 | $this->assertArrayHasKey('count', $array); |
||
122 | $this->assertArrayHasKey('size', $array); |
||
123 | $this->assertArrayHasKey('files', $array); |
||
124 | |||
125 | $this->assertTrue(is_array($array['files'])); |
||
126 | $this->assertTrue(is_array($array['files'][0])); |
||
127 | $this->assertArrayHasKey('name', $array['files'][0]); |
||
128 | $this->assertArrayHasKey('size', $array['files'][0]); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @covers Koch\Debug\Debug::getApplicationConstants |
||
133 | */ |
||
134 | public function testGetApplicationConstants() |
||
135 | { |
||
136 | $returnArray = true; |
||
137 | $array = \Koch\Debug\Debug::getApplicationConstants($returnArray); |
||
138 | |||
139 | $this->assertTrue(is_array($array)); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @covers Koch\Debug\Debug::getBacktrace |
||
144 | */ |
||
145 | public function testGetBacktrace() |
||
146 | { |
||
147 | $returnArray = true; |
||
148 | $limit = 1; |
||
149 | $array = \Koch\Debug\Debug::getBacktrace($limit, $returnArray); |
||
150 | |||
151 | $this->assertTrue(is_array($array)); |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @covers Koch\Debug\Debug::getInterfaces |
||
156 | */ |
||
157 | public function testGetInterfaces() |
||
158 | { |
||
159 | $returnArray = true; |
||
160 | $array = \Koch\Debug\Debug::getInterfaces($returnArray); |
||
161 | |||
162 | $this->assertTrue(is_array($array)); |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * @covers Koch\Debug\Debug::getClasses |
||
167 | */ |
||
168 | public function testGetClasses() |
||
169 | { |
||
170 | $returnArray = true; |
||
171 | $array = \Koch\Debug\Debug::getClasses($returnArray); |
||
172 | |||
173 | $this->assertTrue(is_array($array)); |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * @covers Koch\Debug\Debug::getFunctions |
||
178 | */ |
||
179 | public function testGetFunctions() |
||
180 | { |
||
181 | $returnArray = true; |
||
182 | $array = \Koch\Debug\Debug::getFunctions($returnArray); |
||
183 | |||
184 | $this->assertTrue(is_array($array)); |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * @covers Koch\Debug\Debug::getExtensions |
||
189 | */ |
||
190 | public function testGetExtensions() |
||
191 | { |
||
192 | $returnArray = true; |
||
193 | $array = \Koch\Debug\Debug::getExtensions($returnArray); |
||
194 | |||
195 | $this->assertTrue(is_array($array)); |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * @covers Koch\Debug\Debug::getPhpIni |
||
200 | */ |
||
201 | public function testGetPhpIni() |
||
202 | { |
||
203 | $returnArray = true; |
||
204 | $array = \Koch\Debug\Debug::getPhpIni($returnArray); |
||
205 | |||
206 | $this->assertTrue(is_array($array)); |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * @covers Koch\Debug\Debug::getWrappers |
||
211 | */ |
||
212 | public function testGetWrappers() |
||
213 | { |
||
214 | $returnArray = true; |
||
215 | $array = \Koch\Debug\Debug::getWrappers($returnArray); |
||
216 | |||
217 | $this->assertTrue(is_array($array)); |
||
218 | $this->assertArrayHasKey('openssl', $array); |
||
219 | $this->assertArrayHasKey('http', $array); |
||
220 | $this->assertArrayHasKey('https', $array); |
||
221 | $this->assertArrayHasKey('all', $array); |
||
222 | } |
||
223 | } |
||
224 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: