Test Setup Failed
Push — test ( 68133a...6f6dc7 )
by Jonathan
03:00
created

IntegrationTest::testPlugins()   A

Complexity

Conditions 2
Paths 5

Size

Total Lines 51
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 34
nc 5
nop 0
dl 0
loc 51
rs 9.4109
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
        -Kint::dump(1234);
165
        $this->assertSame(0, ob_get_level());
166
167
        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...
168
            ob_start();
169
        }
170
        $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...
171
    }
172
173
    /**
174
     * @covers \Kint::dump
175
     */
176
    public function testExpandModifier()
177
    {
178
        Kint::$return = true;
179
        Kint::$cli_detection = false;
180
        Kint::$display_called_from = false;
181
        Kint::$enabled_mode = Kint::MODE_RICH;
182
183
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
184
185
        $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...
186
187
        Kint::$return = false;
188
        ob_start();
189
        !Kint::dump($value);
190
        $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...
191
192
        $this->assertNotEquals($d1, $d2);
193
194
        $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...
195
        $this->assertEquals($d1, $d3);
196
    }
197
198
    /**
199
     * @covers \Kint::dump
200
     */
201
    public function testTextModifier()
202
    {
203
        Kint::$return = false;
204
        Kint::$cli_detection = false;
205
        Kint::$display_called_from = false;
206
        Kint::$enabled_mode = Kint::MODE_RICH;
207
208
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
209
210
        ob_start();
211
        ~Kint::dump($value);
212
        $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...
213
214
        Kint::$enabled_mode = Kint::MODE_TEXT;
215
        Kint::$return = true;
216
        $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...
217
218
        $this->assertEquals($d1, $d2);
219
    }
220
221
    /**
222
     * @covers \Kint::dump
223
     */
224
    public function testDeepModifier()
225
    {
226
        Kint::$return = false;
227
        Kint::$cli_detection = false;
228
        Kint::$display_called_from = false;
229
        Kint::$max_depth = 1;
230
        Kint::$enabled_mode = Kint::MODE_TEXT;
231
232
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
233
234
        ob_start();
235
        +Kint::dump($value);
236
        $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...
237
238
        Kint::$return = true;
239
        $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...
240
241
        $this->assertNotEquals($d1, $d2);
242
243
        Kint::$max_depth = 0;
244
        $d2 = Kint::dump($value);
245
246
        $this->assertEquals($d1, $d2);
247
    }
248
249
    /**
250
     * @covers \Kint::dump
251
     */
252
    public function testReturnModifier()
253
    {
254
        Kint::$return = false;
255
        Kint::$cli_detection = false;
256
        Kint::$display_called_from = false;
257
        Kint::$enabled_mode = Kint::MODE_TEXT;
258
259
        $value = array('a' => array(1, 2, 3), 'b' => 'c');
260
261
        ob_start();
262
        $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...
263
        $out = ob_get_clean();
264
265
        Kint::$return = true;
266
        $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...
267
268
        $this->assertEquals($d1, $d2);
269
        $this->assertEmpty($out);
270
    }
271
272
    /**
273
     * @covers \Kint::dump
274
     * @covers \Kint::trace
275
     */
276
    public function testTrace()
277
    {
278
        Kint::$return = true;
279
        Kint::$cli_detection = false;
280
        Kint::$display_called_from = false;
281
        Kint::$enabled_mode = Kint::MODE_TEXT;
282
        Kint::$max_depth = 3;
283
        TextRenderer::$decorations = false;
284
285
        $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...
286
        $biggerbt = $bt;
287
        array_unshift($biggerbt, array(
288
            'class' => 'Kint',
289
            'file' => __FILE__,
290
        ));
291
292
        $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...
293
        $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...
294
295
        $this->assertEquals($d1, $d2);
296
297
        $d2 = Kint::dump(1);
298
        $biggerbt[0]['line'] = __LINE__ - 1;
299
        $biggerbt[0]['function'] = 'dump';
300
        $d1 = preg_replace('/^\$biggerbt/', 'Kint::dump(1)', Kint::dump($biggerbt));
301
302
        $this->assertEquals($d1, $d2);
303
304
        $d2 = Kint::trace();
305
        $biggerbt[0]['line'] = __LINE__ - 1;
306
        $biggerbt[0]['function'] = 'trace';
307
        $d1 = preg_replace('/^\$biggerbt/', 'Kint::trace()', Kint::dump($biggerbt));
308
309
        $this->assertEquals($d1, $d2);
310
    }
311
312
    /**
313
     * @covers \Kint::dump
314
     * @covers \Kint::trace
315
     */
316
    public function testToplevelTrace()
317
    {
318
        Kint::$return = true;
319
        Kint::$cli_detection = false;
320
        Kint::$display_called_from = false;
321
        Kint::$enabled_mode = Kint::MODE_TEXT;
322
        TextRenderer::$decorations = false;
323
324
        $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...
325
        $firstframe = end($bt);
326
327
        Kint::$aliases[] = array($firstframe['class'], $firstframe['function']);
328
329
        $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...
330
        $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...
331
332
        $d1 = explode("\n", $d1);
333
        array_shift($d1);
334
        $d1 = implode("\n", $d1);
335
336
        $d2 = explode("\n", $d2);
337
        array_shift($d2);
338
        $d2 = implode("\n", $d2);
339
340
        $this->assertEquals($d1, $d2);
341
342
        $this->assertLike(
343
            array(
344
                'Debug Backtrace (1):',
345
                Kint::shortenPath($firstframe['file']).':'.$firstframe['line'],
346
            ),
347
            $d1
348
        );
349
    }
350
351
    /**
352
     * @covers \Kint::dump
353
     */
354
    public function testDumpNothing()
355
    {
356
        Kint::$return = true;
357
        Kint::$cli_detection = false;
358
        Kint::$display_called_from = false;
359
        Kint::$enabled_mode = Kint::MODE_TEXT;
360
        TextRenderer::$decorations = false;
361
362
        $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...
363
        $this->assertSame("No argument\n", $d);
364
    }
365
366
    /**
367
     * @covers \Kint::dump
368
     */
369
    public function testNoParamNames()
370
    {
371
        Kint::$return = true;
372
        Kint::$cli_detection = false;
373
        Kint::$display_called_from = false;
374
        Kint::$enabled_mode = Kint::MODE_RICH;
375
        TextRenderer::$decorations = false;
376
377
        $values = array(array(1), array(2), array(3));
378
379
        $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...
380
        $this->assertLike(
381
            array(
382
                '$0[0]',
383
                '$1[0]',
384
                '$2[0]',
385
            ),
386
            $d
387
        );
388
    }
389
390
    /**
391
     * @covers \Kint::dumpArray
392
     */
393
    public function testDumpArray()
394
    {
395
        Kint::$return = true;
396
        Kint::$cli_detection = false;
397
        Kint::$display_called_from = false;
398
        Kint::$enabled_mode = Kint::MODE_TEXT;
399
        TextRenderer::$decorations = false;
400
401
        $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...
402
        $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...
403
        $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...
404
405
        $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...
406
        $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...
407
            array(1, 2, 3),
408
            array(
409
                BasicObject::blank('$a'),
410
                BasicObject::blank('$b'),
411
                BasicObject::blank('$c'),
412
            )
413
        );
414
415
        $this->assertEquals($d1, $d2);
416
    }
417
418
    /**
419
     * @covers \Kint::dump
420
     */
421
    public function testPlugins()
422
    {
423
        Kint::$return = true;
424
        Kint::$cli_detection = false;
425
        Kint::$display_called_from = false;
426
        Kint::$enabled_mode = Kint::MODE_TEXT;
427
        TextRenderer::$decorations = false;
428
429
        $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...
430
        $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...
431
            array('resource'),
432
            Parser::TRIGGER_SUCCESS,
433
            function () use (&$p1_triggered) {
434
                $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...
435
            }
436
        );
437
438
        $value = fopen(__FILE__, 'r');
439
440
        try {
441
            Kint::$plugins = array();
442
            $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...
443
444
            Kint::$plugins = array(
445
                $p1,
446
                'Kint\\Parser\\StreamPlugin',
447
            );
448
            TextRenderer::$parser_plugin_whitelist = array('Kint\\Parser\\Plugin');
449
450
            $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...
451
452
            $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...
453
454
            fclose($value);
455
        } catch (Exception $e) {
456
            fclose($value);
457
458
            throw $e;
459
        }
460
461
        $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...
462
        $this->assertLike(
463
            array(
464
                '$value',
465
                'stream resource',
466
                Kint::shortenPath(__FILE__),
467
            ),
468
            $d2
469
        );
470
        $this->assertNotSame($d1, $d2);
471
    }
472
473
    /**
474
     * Test this test suite's restore after test.
475
     *
476
     * @covers \Kint\Test\KintTestCase::setUp
477
     * @covers \Kint\Test\KintTestCase::tearDown
478
     */
479
    public function testStore()
480
    {
481
        Kint::$file_link_format = 'test_store';
482
        $this->assertEquals('test_store', Kint::$file_link_format);
483
        BlobObject::$char_encodings[] = 'this_is_not_a_real_encoding';
484
        $this->assertContains('this_is_not_a_real_encoding', BlobObject::$char_encodings);
485
    }
486
487
    /**
488
     * @covers \Kint\Test\KintTestCase::setUp
489
     * @covers \Kint\Test\KintTestCase::tearDown
490
     */
491
    public function testRestore()
492
    {
493
        $this->assertNotEquals('test_store', Kint::$file_link_format);
494
        $this->assertNotContains('this_is_not_a_real_encoding', BlobObject::$char_encodings);
495
    }
496
497
    /**
498
     * @covers \Kint\Test\KintTestCase::assertLike
499
     */
500
    public function testLike()
501
    {
502
        $this->assertLike(array('a', 'b', 'c'), 'foo a bar baz c buzz');
503
    }
504
505
    /**
506
     * @covers \Kint\Test\KintTestCase::assertLike
507
     */
508
    public function testNotLike()
509
    {
510
        try {
511
            $this->assertLike(array('a', 'b', 'c', 'o'), 'foo a bar baz c buzz');
512
        } catch (PHPUnit_Framework_AssertionFailedError $e) {
513
            return;
514
        }
515
516
        self::fail('Failed to mismatch');
517
    }
518
519
    /**
520
     * @covers \Kint\Test\KintTestCase::assertLike
521
     */
522
    public function testLikeNonString()
523
    {
524
        try {
525
            $this->assertLike(array('a', 'b', 'c'), array('a', 'b', 'c'));
526
        } catch (PHPUnit_Framework_Exception $e) {
527
            return;
528
        }
529
530
        self::fail('Failed to throw');
531
    }
532
}
533