Test Setup Failed
Push — test ( 546d28...089b88 )
by Jonathan
03:07
created

BasicObjectTest::testSortByAccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
3
namespace Kint\Test\Object;
4
5
use Kint\Object\BasicObject;
6
use Kint\Object\Representation\Representation;
7
8
class BasicObjectTest extends \PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @covers \Kint\Object\BasicObject::__construct
12
     * @covers \Kint\Object\BasicObject::getRepresentations
13
     * @covers \Kint\Object\BasicObject::addRepresentation
14
     */
15
    public function testAddRepresentation()
16
    {
17
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
18
19
        $this->assertSame(array(), $o->getRepresentations());
20
        $this->assertSame(null, $o->value);
21
22
        $this->assertTrue($o->addRepresentation($r1 = new Representation('Rep 1')));
23
        $this->assertSame(
24
            array(
25
                'rep_1' => $r1,
26
            ),
27
            $o->getRepresentations()
28
        );
29
        $this->assertSame(null, $o->value);
30
31
        $this->assertFalse($o->addRepresentation($r1));
32
        $this->assertSame(
33
            array(
34
                'rep_1' => $r1,
35
            ),
36
            $o->getRepresentations()
37
        );
38
39
        $this->assertTrue($o->addRepresentation($r2 = new Representation('Rep 2')));
40
        $this->assertSame(
41
            array(
42
                'rep_1' => $r1,
43
                'rep_2' => $r2,
44
            ),
45
            $o->getRepresentations()
46
        );
47
48
        $this->assertTrue($o->addRepresentation($r3 = new Representation('Rep 3'), 0));
49
        $this->assertSame(
50
            array(
51
                'rep_3' => $r3,
52
                'rep_1' => $r1,
53
                'rep_2' => $r2,
54
            ),
55
            $o->getRepresentations()
56
        );
57
58
        $this->assertTrue($o->addRepresentation($r4 = new Representation('Rep 4'), 1));
59
        $this->assertSame(
60
            array(
61
                'rep_3' => $r3,
62
                'rep_4' => $r4,
63
                'rep_1' => $r1,
64
                'rep_2' => $r2,
65
            ),
66
            $o->getRepresentations()
67
        );
68
69
        $this->assertTrue($o->addRepresentation($r5 = new Representation('Rep 5'), 100));
70
        $this->assertSame(
71
            array(
72
                'rep_3' => $r3,
73
                'rep_4' => $r4,
74
                'rep_1' => $r1,
75
                'rep_2' => $r2,
76
                'rep_5' => $r5,
77
            ),
78
            $o->getRepresentations()
79
        );
80
81
        $this->assertTrue($o->addRepresentation($r6 = new Representation('Rep 6'), -100));
82
        $this->assertSame(
83
            array(
84
                'rep_6' => $r6,
85
                'rep_3' => $r3,
86
                'rep_4' => $r4,
87
                'rep_1' => $r1,
88
                'rep_2' => $r2,
89
                'rep_5' => $r5,
90
            ),
91
            $o->getRepresentations()
92
        );
93
94
        $this->assertSame(null, $o->value);
95
    }
96
97
    /**
98
     * @covers \Kint\Object\BasicObject::replaceRepresentation
99
     */
100
    public function testReplaceRepresentation()
101
    {
102
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
103
        $o->addRepresentation($r1 = new Representation('Rep 1'));
104
        $o->addRepresentation($r2 = new Representation('Rep 2'));
105
        $o->addRepresentation($r3 = new Representation('Rep 3'));
106
107
        $this->assertSame(
108
            array(
109
                'rep_1' => $r1,
110
                'rep_2' => $r2,
111
                'rep_3' => $r3,
112
            ),
113
            $o->getRepresentations()
114
        );
115
116
        $o->replaceRepresentation($r2_2 = new Representation('Rep 2'));
0 ignored issues
show
Coding Style introduced by
$r2_2 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...
117
118
        $this->assertSame(
119
            array(
120
                'rep_1' => $r1,
121
                'rep_2' => $r2_2,
0 ignored issues
show
Coding Style introduced by
$r2_2 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...
122
                'rep_3' => $r3,
123
            ),
124
            $o->getRepresentations()
125
        );
126
127
        $o->replaceRepresentation($r2, 0);
128
129
        $this->assertSame(
130
            array(
131
                'rep_2' => $r2,
132
                'rep_1' => $r1,
133
                'rep_3' => $r3,
134
            ),
135
            $o->getRepresentations()
136
        );
137
138
        $o->replaceRepresentation($r2_2, 1);
0 ignored issues
show
Coding Style introduced by
$r2_2 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...
139
140
        $this->assertSame(
141
            array(
142
                'rep_1' => $r1,
143
                'rep_2' => $r2_2,
0 ignored issues
show
Coding Style introduced by
$r2_2 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...
144
                'rep_3' => $r3,
145
            ),
146
            $o->getRepresentations()
147
        );
148
    }
149
150
    /**
151
     * @covers \Kint\Object\BasicObject::removeRepresentation
152
     */
153
    public function testRemoveRepresentation()
154
    {
155
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
156
        $o->addRepresentation($r1 = new Representation('Rep 1'));
157
        $o->addRepresentation($r2 = new Representation('Rep 2'));
158
        $o->addRepresentation($r3 = new Representation('Rep 3'));
159
160
        $this->assertSame(
161
            array(
162
                'rep_1' => $r1,
163
                'rep_2' => $r2,
164
                'rep_3' => $r3,
165
            ),
166
            $o->getRepresentations()
167
        );
168
169
        $o->removeRepresentation('rep_2');
170
171
        $this->assertSame(
172
            array(
173
                'rep_1' => $r1,
174
                'rep_3' => $r3,
175
            ),
176
            $o->getRepresentations()
177
        );
178
179
        $o->removeRepresentation($r1);
180
        $this->assertSame(array('rep_3' => $r3), $o->getRepresentations());
181
    }
182
183
    /**
184
     * @covers \Kint\Object\BasicObject::getRepresentation
185
     */
186
    public function testGetRepresentation()
187
    {
188
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
189
        $o->addRepresentation($r1 = new Representation('Rep 1'));
190
        $o->addRepresentation($r2 = new Representation('Rep 2'));
191
        $o->addRepresentation($r3 = new Representation('Rep 3'));
192
193
        $this->assertSame($r1, $o->getRepresentation('rep_1'));
194
        $this->assertSame($r2, $o->getRepresentation('rep_2'));
195
        $this->assertSame($r3, $o->getRepresentation('rep_3'));
196
        $this->assertSame(null, $o->getRepresentation('Non-existant representation name'));
197
    }
198
199
    /**
200
     * @covers \Kint\Object\BasicObject::getRepresentations
201
     */
202
    public function testGetRepresentations()
203
    {
204
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
205
        $o->addRepresentation($r1 = new Representation('Rep 1'));
206
        $o->addRepresentation($r2 = new Representation('Rep 2'));
207
        $o->addRepresentation($r3 = new Representation('Rep 3'));
208
209
        $this->assertSame(
210
            array(
211
                'rep_1' => $r1,
212
                'rep_2' => $r2,
213
                'rep_3' => $r3,
214
            ),
215
            $o->getRepresentations()
216
        );
217
    }
218
219
    /**
220
     * @covers \Kint\Object\BasicObject::clearRepresentations
221
     */
222
    public function testClearRepresentations()
223
    {
224
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
225
        $o->addRepresentation($r1 = new Representation('Rep 1'));
226
        $o->addRepresentation(new Representation('Rep 2'));
227
        $o->addRepresentation(new Representation('Rep 3'));
228
        $o->value = $r1;
229
230
        $o->clearRepresentations();
231
232
        $this->assertSame(array(), $o->getRepresentations());
233
        $this->assertSame($r1, $o->value);
234
    }
235
236
    /**
237
     * @covers \Kint\Object\BasicObject::getType
238
     */
239
    public function testGetType()
240
    {
241
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
242
        $o->type = 'array';
243
        $this->assertEquals('array', $o->getType());
244
    }
245
246
    public function modifierProvider()
247
    {
248
        return array(
249
            'public' => array(
250
                false,
251
                false,
252
                BasicObject::ACCESS_PUBLIC,
253
                'public',
254
            ),
255
            'public const' => array(
256
                true,
257
                false,
258
                BasicObject::ACCESS_PUBLIC,
259
                'public const',
260
            ),
261
            'public static' => array(
262
                false,
263
                true,
264
                BasicObject::ACCESS_PUBLIC,
265
                'public static',
266
            ),
267
            'protected' => array(
268
                false,
269
                false,
270
                BasicObject::ACCESS_PROTECTED,
271
                'protected',
272
            ),
273
            'private' => array(
274
                false,
275
                false,
276
                BasicObject::ACCESS_PRIVATE,
277
                'private',
278
            ),
279
            'none' => array(
280
                false,
281
                false,
282
                BasicObject::ACCESS_NONE,
283
                null,
284
            ),
285
            'private static' => array(
286
                false,
287
                true,
288
                BasicObject::ACCESS_PRIVATE,
289
                'private static',
290
            ),
291
            'public const static' => array(
292
                true,
293
                true,
294
                BasicObject::ACCESS_PUBLIC,
295
                'public const static',
296
            ),
297
            'const' => array(
298
                true,
299
                false,
300
                BasicObject::ACCESS_NONE,
301
                'const',
302
            ),
303
        );
304
    }
305
306
    /**
307
     * @dataProvider modifierProvider
308
     * @covers \Kint\Object\BasicObject::getModifiers
309
     */
310
    public function testGetModifiers($const, $static, $access, $expect)
311
    {
312
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
313
        $o->const = $const;
314
        $o->static = $static;
315
        $o->access = $access;
316
        $this->assertSame($expect, $o->getModifiers());
317
    }
318
319
    /**
320
     * @covers \Kint\Object\BasicObject::getAccess
321
     */
322
    public function testGetAccess()
323
    {
324
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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
        $this->assertNull($o->getAccess());
326
        $o->access = BasicObject::ACCESS_PUBLIC;
327
        $this->assertEquals('public', $o->getAccess());
328
        $o->access = BasicObject::ACCESS_PROTECTED;
329
        $this->assertEquals('protected', $o->getAccess());
330
        $o->access = BasicObject::ACCESS_PRIVATE;
331
        $this->assertEquals('private', $o->getAccess());
332
    }
333
334
    /**
335
     * @covers \Kint\Object\BasicObject::getName
336
     */
337 View Code Duplication
    public function testGetName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
338
    {
339
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
340
        $o->name = '$var';
341
        $this->assertEquals('$var', $o->getName());
342
        $o->name = '($a + $b)';
343
        $this->assertEquals('($a + $b)', $o->getName());
344
        $o->name = 'This is just a name, nothing more, nothing less.';
345
        $this->assertEquals('This is just a name, nothing more, nothing less.', $o->getName());
346
    }
347
348
    /**
349
     * @covers \Kint\Object\BasicObject::getOperator
350
     */
351
    public function testGetOperator()
352
    {
353
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
354
        $this->assertNull($o->getOperator());
355
        $o->operator = BasicObject::OPERATOR_NONE;
356
        $this->assertNull($o->getOperator());
357
        $o->operator = BasicObject::OPERATOR_ARRAY;
358
        $this->assertEquals('=>', $o->getOperator());
359
        $o->operator = BasicObject::OPERATOR_OBJECT;
360
        $this->assertEquals('->', $o->getOperator());
361
        $o->operator = BasicObject::OPERATOR_STATIC;
362
        $this->assertEquals('::', $o->getOperator());
363
    }
364
365
    /**
366
     * @covers \Kint\Object\BasicObject::getSize
367
     */
368 View Code Duplication
    public function testGetSize()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
369
    {
370
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
371
        $this->assertNull($o->getSize());
372
        $o->size = 0;
373
        $this->assertEquals(0, $o->getSize());
374
        $o->size = 42;
375
        $this->assertEquals(42, $o->getSize());
376
    }
377
378
    /**
379
     * @covers \Kint\Object\BasicObject::getValueShort
380
     */
381
    public function testGetValueShort()
382
    {
383
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
384
        $r = new Representation('contents');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. 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->assertNull($o->getValueShort());
386
        $o->value = $r;
387
388
        $r->contents = true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean is incompatible with the declared type array of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
389
        $this->assertNull($o->getValueShort());
390
        $o->type = 'boolean';
391
        $this->assertEquals('true', $o->getValueShort());
392
        $r->contents = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type array of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
393
        $this->assertEquals('false', $o->getValueShort());
394
        $o->type = 'integer';
395
        $r->contents = 1234;
0 ignored issues
show
Documentation Bug introduced by
It seems like 1234 of type integer is incompatible with the declared type array of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
396
        $this->assertEquals(1234, $o->getValueShort());
397
        $o->type = 'double';
398
        $r->contents = 1234.5678;
0 ignored issues
show
Documentation Bug introduced by
It seems like 1234.5678 of type double is incompatible with the declared type array of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
399
        $this->assertEquals(1234.5678, $o->getValueShort());
400
        $o->type = 'array';
401
        $r->contents = array();
402
        $this->assertNull($o->getValueShort());
403
        $o->type = 'string';
404
        $r->contents = 'string';
0 ignored issues
show
Documentation Bug introduced by
It seems like 'string' of type string is incompatible with the declared type array of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
405
        $this->assertNull($o->getValueShort());
406
    }
407
408
    /**
409
     * @covers \Kint\Object\BasicObject::getAccessPath
410
     */
411
    public function testGetAccessPath()
412
    {
413
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
414
        $this->assertNull($o->getAccessPath());
415
        $o->access_path = 'abcdefg, hijk elemeno p';
416
        $this->assertEquals('abcdefg, hijk elemeno p', $o->getAccessPath());
417
    }
418
419
    /**
420
     * @covers \Kint\Object\BasicObject::blank
421
     */
422
    public function testBlank()
423
    {
424
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
425
        $this->assertNull($o->name);
426
        $this->assertNull($o->access_path);
427
428
        $o = BasicObject::blank();
429
        $this->assertNull($o->name);
430
        $this->assertNull($o->access_path);
431
432
        $o = BasicObject::blank('$var');
433
        $this->assertEquals('$var', $o->name);
434
        $this->assertEquals('$var', $o->access_path);
435
436
        $o = BasicObject::blank('Name', 'access_path');
437
        $this->assertEquals('Name', $o->name);
438
        $this->assertEquals('access_path', $o->access_path);
439
    }
440
441
    /**
442
     * @covers \Kint\Object\BasicObject::transplant
443
     */
444
    public function testTransplant()
445
    {
446
        $o = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. 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...
447
448
        $o->name = 'name';
449
        $o->size = 42;
450
        $o->access_path = 'access_path';
451
        $o->access = BasicObject::ACCESS_PUBLIC;
452
        $o->static = true;
453
        $o->const = true;
454
        $o->type = 'type';
455
        $o->depth = 43;
456
        $o->owner_class = 'owner_class';
457
        $o->operator = BasicObject::OPERATOR_OBJECT;
458
        $o->reference = true;
459
        $o->hints = array('test', 'transplant', 'hints');
460
461
        $r = new Representation('Test');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. 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...
462
        $o->addRepresentation($r);
463
464
        $o2 = $o->transplant(new BasicObject());
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o2. 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...
465
466
        $this->assertEquals($o, $o2);
467
        $this->assertNotSame($o, $o2);
468
        $this->assertSame($o->value, $o2->value);
469
470
        $o2 = new BasicObject();
471
        $r2 = new Representation('Test 2');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r2. 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...
472
        $o2->addRepresentation($r2);
473
        $o2->hints = array('test', 'thoroughly');
474
475
        $o2 = $o->transplant($o2);
476
477
        $this->assertSame(array('test_2' => $r2, 'test' => $r), $o2->getRepresentations());
478
        $this->assertSame(array('test', 'transplant', 'hints', 'test', 'thoroughly'), $o2->hints);
479
    }
480
481
    /**
482
     * @covers \Kint\Object\BasicObject::sortByAccess
483
     */
484
    public function testSortByAccess()
485
    {
486
        $o1 = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o1. 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...
487
        $o2 = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o2. 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...
488
        $o3 = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o3. 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...
489
490
        $a = array($o1, $o2, $o3);
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...
491
492
        $o1->access = BasicObject::ACCESS_PRIVATE;
493
        $o2->access = BasicObject::ACCESS_PROTECTED;
494
        $o3->access = BasicObject::ACCESS_PUBLIC;
495
496
        $this->assertSame(array($o1, $o2, $o3), $a);
497
498
        usort($a, 'Kint\\Object\\BasicObject::sortByAccess');
499
        $this->assertSame(array($o3, $o2, $o1), $a);
500
501
        $o1->access = BasicObject::ACCESS_PROTECTED;
502
        $o2->access = BasicObject::ACCESS_PRIVATE;
503
504
        usort($a, 'Kint\\Object\\BasicObject::sortByAccess');
505
        $this->assertSame(array($o3, $o1, $o2), $a);
506
    }
507
508
    /**
509
     * @covers \Kint\Object\BasicObject::sortByName
510
     */
511
    public function testSortByName()
512
    {
513
        $o1 = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o1. 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...
514
        $o2 = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o2. 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...
515
        $o3 = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o3. 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...
516
517
        $a = array($o1, $o2, $o3);
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...
518
519
        $o1->name = 'Name Z';
520
        $o2->name = 'Name B';
521
        $o3->name = 'Name A';
522
523
        $this->assertSame(array($o1, $o2, $o3), $a);
524
525
        usort($a, 'Kint\\Object\\BasicObject::sortByName');
526
        $this->assertSame(array($o3, $o2, $o1), $a);
527
528
        $o1->name = 'Name M';
529
        $o2->name = 'Name Z2';
530
531
        usort($a, 'Kint\\Object\\BasicObject::sortByName');
532
        $this->assertSame(array($o3, $o1, $o2), $a);
533
534
        $o1->name = '123';
535
        $o2->name = 123;
536
537
        usort($a, 'Kint\\Object\\BasicObject::sortByName');
538
        $this->assertSame(array($o2, $o1, $o3), $a);
539
    }
540
}
541