Completed
Push — next ( 3fc9f0...5d2fc6 )
by Jonathan
9s
created

IntegrationTest::testBasicDumps()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 106
Code Lines 75

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 75
nc 1
nop 0
dl 0
loc 106
rs 8.2857
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Kint\Test;
4
5
use Exception;
6
use Kint;
7
use Kint\Object\BasicObject;
8
use Kint\Object\BlobObject;
9
use Kint\Parser\Parser;
10
use Kint\Parser\ProxyPlugin;
11
use Kint\Renderer\TextRenderer;
12
use PHPUnit_Framework_AssertionFailedError;
13
use PHPUnit_Framework_Exception;
14
15
class IntegrationTest extends KintTestCase
16
{
17
    /**
18
     * @covers \d
19
     * @covers \s
20
     * @covers \Kint::dump
21
     */
22
    public function testBasicDumps()
23
    {
24
        $testdata = array(
25
            1234,
26
            (object) array('abc' => 'def'),
27
            1234.5678,
28
            'Good news everyone! I\'ve got some bad news!',
29
            null,
30
        );
31
32
        $testdata[] = &$testdata;
33
34
        $array_structure = array(
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
35
            '0', 'integer', '1234',
36
            '1', 'stdClass', '1',
37
            'public', 'abc', 'string', '3', 'def',
38
            '2', 'double', '1234.5678',
39
            '3', 'string', '43', 'Good news everyone! I\'ve got some bad news!',
40
            '4', 'null',
41
        );
42
43
        Kint::$return = true;
44
        Kint::$cli_detection = false;
45
        Kint::$display_called_from = false;
46
47
        Kint::$enabled_mode = Kint::MODE_RICH;
48
        $richbase = d($testdata);
49
50
        $this->assertLike(
51
            array_merge(
52
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
53
                array('&amp;array', '6'),
54
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
55
                array('&amp;array', 'Recursion')
56
            ),
57
            $richbase
58
        );
59
60
        Kint::$enabled_mode = true;
61
        $this->assertSame($richbase, d($testdata));
62
        $this->assertSame($richbase, Kint::dump($testdata));
63
64
        Kint::$enabled_mode = Kint::MODE_PLAIN;
65
        $plainbase = d($testdata);
66
67
        $this->assertLike(
68
            array_merge(
69
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
70
                array('&amp;array', '6'),
71
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
72
                array('&amp;array', 'RECURSION')
73
            ),
74
            $plainbase
75
        );
76
77
        $this->assertSame($plainbase, Kint::dump($testdata));
78
79
        Kint::$enabled_mode = true;
80
        $this->assertSame($plainbase, s($testdata));
81
82
        Kint::$enabled_mode = Kint::MODE_CLI;
83
        $clibase = d($testdata);
84
85
        $this->assertLike(
86
            array_merge(
87
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
88
                array('&array', '6'),
89
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
90
                array('&array', 'RECURSION')
91
            ),
92
            $clibase
93
        );
94
95
        $this->assertSame($clibase, Kint::dump($testdata));
96
97
        Kint::$enabled_mode = true;
98
        Kint::$cli_detection = true;
99
        $this->assertSame($clibase, d($testdata));
100
        $this->assertSame($clibase, s($testdata));
101
        Kint::$cli_detection = false;
102
103
        Kint::$enabled_mode = Kint::MODE_TEXT;
104
        $textbase = d($testdata);
105
106
        $this->assertLike(
107
            array_merge(
108
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
109
                array('&array', '6'),
110
                $array_structure,
0 ignored issues
show
Coding Style introduced by
$array_structure does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
111
                array('&array', 'RECURSION')
112
            ),
113
            $textbase
114
        );
115
116
        $this->assertSame($textbase, Kint::dump($testdata));
117
118
        Kint::$return = false;
119
        Kint::$enabled_mode = true;
120
        ob_start();
121
        ~d($testdata);
122
        $this->assertSame($textbase, ob_get_clean());
123
124
        Kint::$enabled_mode = false;
125
        $this->assertSame(0, d($testdata));
126
        $this->assertSame(0, s($testdata));
127
    }
128
129
    /**
130
     * @covers \Kint::dump
131
     */
132
    public function testDumpBadMode()
133
    {
134
        Kint::$return = true;
135
        Kint::$cli_detection = false;
136
        Kint::$display_called_from = false;
137
        Kint::$enabled_mode = Kint::MODE_PLAIN;
138
        TextRenderer::$decorations = false;
139
140
        $d1 = Kint::dump(1234);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
141
142
        Kint::$enabled_mode = 'This is not a real mode';
143
        $d2 = Kint::dump(1234);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
144
145
        $this->assertEquals($d1, $d2);
146
    }
147
148
    /**
149
     * @covers \Kint::dump
150
     */
151
    public function testFlushModifier()
152
    {
153
        Kint::$return = true;
154
        Kint::$cli_detection = false;
155
        Kint::$display_called_from = false;
156
        Kint::$enabled_mode = Kint::MODE_TEXT;
157
        TextRenderer::$decorations = false;
158
159
        $base_level = ob_get_level();
0 ignored issues
show
Coding Style introduced by
$base_level does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
160
        ob_start();
161
        $this->assertSame($base_level + 1, ob_get_level());
0 ignored issues
show
Coding Style introduced by
$base_level does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
162
        Kint::dump(1234);
163
        $this->assertSame($base_level + 1, ob_get_level());
0 ignored issues
show
Coding Style introduced by
$base_level does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
164
        // Please leave the ! modifier in place, to prevent errors using unary - on a returned string
165
        -!Kint::dump(1234);
166
        $this->assertSame(0, ob_get_level());
167
168
        while ($base_level > ob_get_level()) {
0 ignored issues
show
Coding Style introduced by
$base_level does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
169
            ob_start();
170
        }
171
        $this->assertSame($base_level, ob_get_level());
0 ignored issues
show
Coding Style introduced by
$base_level does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
172
    }
173
174
    /**
175
     * @covers \Kint::dump
176
     */
177
    public function testExpandModifier()
178
    {
179
        Kint::$return = true;
180
        Kint::$cli_detection = false;
181
        Kint::$display_called_from = false;
182
        Kint::$enabled_mode = Kint::MODE_RICH;
183
184
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
185
186
        $d1 = Kint::dump($value);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
187
188
        Kint::$return = false;
189
        ob_start();
190
        !Kint::dump($value);
191
        $d2 = ob_get_clean();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
192
193
        $this->assertNotEquals($d1, $d2);
194
195
        $d3 = str_replace(' kint-show', '', $d2);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d3. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
196
        $this->assertEquals($d1, $d3);
197
    }
198
199
    /**
200
     * @covers \Kint::dump
201
     */
202
    public function testTextModifier()
203
    {
204
        Kint::$return = false;
205
        Kint::$cli_detection = false;
206
        Kint::$display_called_from = false;
207
        Kint::$enabled_mode = Kint::MODE_RICH;
208
209
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
210
211
        ob_start();
212
        ~Kint::dump($value);
213
        $d1 = ob_get_clean();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
214
215
        Kint::$enabled_mode = Kint::MODE_TEXT;
216
        Kint::$return = true;
217
        $d2 = Kint::dump($value);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
218
219
        $this->assertEquals($d1, $d2);
220
    }
221
222
    /**
223
     * @covers \Kint::dump
224
     */
225
    public function testDeepModifier()
226
    {
227
        Kint::$return = false;
228
        Kint::$cli_detection = false;
229
        Kint::$display_called_from = false;
230
        Kint::$max_depth = 1;
231
        Kint::$enabled_mode = Kint::MODE_TEXT;
232
233
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
234
235
        ob_start();
236
        +Kint::dump($value);
237
        $d1 = ob_get_clean();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
238
239
        Kint::$return = true;
240
        $d2 = Kint::dump($value);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
241
242
        $this->assertNotEquals($d1, $d2);
243
244
        Kint::$max_depth = 0;
245
        $d2 = Kint::dump($value);
246
247
        $this->assertEquals($d1, $d2);
248
    }
249
250
    /**
251
     * @covers \Kint::dump
252
     */
253
    public function testReturnModifier()
254
    {
255
        Kint::$return = false;
256
        Kint::$cli_detection = false;
257
        Kint::$display_called_from = false;
258
        Kint::$enabled_mode = Kint::MODE_TEXT;
259
260
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
261
262
        ob_start();
263
        $d1 = @Kint::dump($value);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
264
        $out = ob_get_clean();
265
266
        Kint::$return = true;
267
        $d2 = Kint::dump($value);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
268
269
        $this->assertEquals($d1, $d2);
270
        $this->assertEmpty($out);
271
    }
272
273
    /**
274
     * @covers \Kint::dump
275
     * @covers \Kint::trace
276
     */
277
    public function testTrace()
278
    {
279
        Kint::$return = true;
280
        Kint::$cli_detection = false;
281
        Kint::$display_called_from = false;
282
        Kint::$enabled_mode = Kint::MODE_TEXT;
283
        Kint::$max_depth = 3;
284
        TextRenderer::$decorations = false;
285
286
        $bt = debug_backtrace(true);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $bt. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
287
        $biggerbt = $bt;
288
        array_unshift($biggerbt, array(
289
            'class' => 'Kint',
290
            'file' => __FILE__,
291
        ));
292
293
        $d1 = Kint::dump($bt);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
294
        $d2 = Kint::trace($bt);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
295
296
        $this->assertEquals($d1, $d2);
297
298
        $d2 = Kint::dump(1);
299
        $biggerbt[0]['line'] = __LINE__ - 1;
300
        $biggerbt[0]['function'] = 'dump';
301
        $d1 = preg_replace('/^\$biggerbt/', 'Kint::dump(1)', Kint::dump($biggerbt));
302
303
        $this->assertEquals($d1, $d2);
304
305
        $d2 = Kint::trace();
306
        $biggerbt[0]['line'] = __LINE__ - 1;
307
        $biggerbt[0]['function'] = 'trace';
308
        $d1 = preg_replace('/^\$biggerbt/', 'Kint::trace()', Kint::dump($biggerbt));
309
310
        $this->assertEquals($d1, $d2);
311
    }
312
313
    /**
314
     * @covers \Kint::dump
315
     * @covers \Kint::trace
316
     */
317
    public function testToplevelTrace()
318
    {
319
        Kint::$return = true;
320
        Kint::$cli_detection = false;
321
        Kint::$display_called_from = false;
322
        Kint::$enabled_mode = Kint::MODE_TEXT;
323
        TextRenderer::$decorations = false;
324
325
        $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $bt. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
326
        $firstframe = end($bt);
327
328
        if (isset($firstframe['class'])) {
329
            Kint::$aliases[] = array($firstframe['class'], $firstframe['function']);
330
        } else {
331
            Kint::$aliases[] = $firstframe['function'];
332
        }
333
334
        $d1 = Kint::dump(1);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
335
        $d2 = Kint::trace();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
336
337
        $d1 = explode("\n", $d1);
338
        array_shift($d1);
339
        $d1 = implode("\n", $d1);
340
341
        $d2 = explode("\n", $d2);
342
        array_shift($d2);
343
        $d2 = implode("\n", $d2);
344
345
        $this->assertEquals($d1, $d2);
346
347
        $this->assertLike(
348
            array(
349
                'Debug Backtrace (1):',
350
                Kint::shortenPath($firstframe['file']).':'.$firstframe['line'],
351
            ),
352
            $d1
353
        );
354
    }
355
356
    /**
357
     * @covers \Kint::dump
358
     */
359
    public function testDumpNothing()
360
    {
361
        Kint::$return = true;
362
        Kint::$cli_detection = false;
363
        Kint::$display_called_from = false;
364
        Kint::$enabled_mode = Kint::MODE_TEXT;
365
        TextRenderer::$decorations = false;
366
367
        $d = Kint::dump();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
368
        $this->assertSame("No argument\n", $d);
369
    }
370
371
    /**
372
     * @covers \Kint::dump
373
     */
374
    public function testNoParamNames()
375
    {
376
        Kint::$return = true;
377
        Kint::$cli_detection = false;
378
        Kint::$display_called_from = false;
379
        Kint::$enabled_mode = Kint::MODE_RICH;
380
        TextRenderer::$decorations = false;
381
382
        $values = array(array(1), array(2), array(3));
383
384
        $d = call_user_func_array('Kint::dump', $values);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
385
        $this->assertLike(
386
            array(
387
                '$0[0]',
388
                '$1[0]',
389
                '$2[0]',
390
            ),
391
            $d
392
        );
393
    }
394
395
    /**
396
     * @covers \Kint::dumpArray
397
     */
398
    public function testDumpArray()
399
    {
400
        Kint::$return = true;
401
        Kint::$cli_detection = false;
402
        Kint::$display_called_from = false;
403
        Kint::$enabled_mode = Kint::MODE_TEXT;
404
        TextRenderer::$decorations = false;
405
406
        $a = 1;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
407
        $b = 2;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
408
        $c = 3;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $c. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
409
410
        $d1 = Kint::dump($a, $b, $c);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
411
        $d2 = Kint::dumpArray(
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
412
            array(1, 2, 3),
413
            array(
414
                BasicObject::blank('$a'),
415
                BasicObject::blank('$b'),
416
                BasicObject::blank('$c'),
417
            )
418
        );
419
420
        $this->assertEquals($d1, $d2);
421
    }
422
423
    /**
424
     * @covers \Kint::dump
425
     */
426
    public function testPlugins()
427
    {
428
        Kint::$return = true;
429
        Kint::$cli_detection = false;
430
        Kint::$display_called_from = false;
431
        Kint::$enabled_mode = Kint::MODE_TEXT;
432
        TextRenderer::$decorations = false;
433
434
        $p1_triggered = false;
0 ignored issues
show
Coding Style introduced by
$p1_triggered does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
435
        $p1 = new ProxyPlugin(
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $p1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
436
            array('resource'),
437
            Parser::TRIGGER_SUCCESS,
438
            function () use (&$p1_triggered) {
439
                $p1_triggered = true;
0 ignored issues
show
Coding Style introduced by
$p1_triggered does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
440
            }
441
        );
442
443
        $value = fopen(__FILE__, 'r');
444
445
        try {
446
            Kint::$plugins = array();
447
            $d1 = Kint::dump($value);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d1. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
448
449
            Kint::$plugins = array(
450
                $p1,
451
                'Kint\\Parser\\StreamPlugin',
452
            );
453
            TextRenderer::$parser_plugin_whitelist = array('Kint\\Parser\\Plugin');
454
455
            $this->assertFalse($p1_triggered);
0 ignored issues
show
Coding Style introduced by
$p1_triggered does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
456
457
            $d2 = Kint::dump($value);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $d2. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
458
459
            fclose($value);
460
        } catch (Exception $e) {
461
            fclose($value);
462
463
            throw $e;
464
        }
465
466
        $this->assertTrue($p1_triggered);
0 ignored issues
show
Coding Style introduced by
$p1_triggered does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
467
        $this->assertLike(
468
            array(
469
                '$value',
470
                'stream resource',
471
                Kint::shortenPath(__FILE__),
472
            ),
473
            $d2
474
        );
475
        $this->assertNotSame($d1, $d2);
476
    }
477
478
    /**
479
     * Test this test suite's restore after test.
480
     *
481
     * @covers \Kint\Test\KintTestCase::setUp
482
     * @covers \Kint\Test\KintTestCase::tearDown
483
     */
484
    public function testStore()
485
    {
486
        Kint::$file_link_format = 'test_store';
487
        $this->assertEquals('test_store', Kint::$file_link_format);
488
        BlobObject::$char_encodings[] = 'this_is_not_a_real_encoding';
489
        $this->assertContains('this_is_not_a_real_encoding', BlobObject::$char_encodings);
490
    }
491
492
    /**
493
     * @covers \Kint\Test\KintTestCase::setUp
494
     * @covers \Kint\Test\KintTestCase::tearDown
495
     */
496
    public function testRestore()
497
    {
498
        $this->assertNotEquals('test_store', Kint::$file_link_format);
499
        $this->assertNotContains('this_is_not_a_real_encoding', BlobObject::$char_encodings);
500
    }
501
502
    /**
503
     * @covers \Kint\Test\KintTestCase::assertLike
504
     */
505
    public function testLike()
506
    {
507
        $this->assertLike(array('a', 'b', 'c'), 'foo a bar baz c buzz');
508
    }
509
510
    /**
511
     * @covers \Kint\Test\KintTestCase::assertLike
512
     */
513
    public function testNotLike()
514
    {
515
        try {
516
            $this->assertLike(array('a', 'b', 'c', 'o'), 'foo a bar baz c buzz');
517
        } catch (PHPUnit_Framework_AssertionFailedError $e) {
518
            return;
519
        }
520
521
        self::fail('Failed to mismatch');
522
    }
523
524
    /**
525
     * @covers \Kint\Test\KintTestCase::assertLike
526
     */
527
    public function testLikeNonString()
528
    {
529
        try {
530
            $this->assertLike(array('a', 'b', 'c'), array('a', 'b', 'c'));
531
        } catch (PHPUnit_Framework_Exception $e) {
532
            return;
533
        }
534
535
        self::fail('Failed to throw');
536
    }
537
}
538