Test Setup Failed
Push — test ( 4e9ef0...2bbcf6 )
by Jonathan
02:51
created

BasicObjectTest::testSortByName()   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::getRepresentations
12
     * @covers \Kint\Object\BasicObject::addRepresentation
13
     */
14
    public function testAddRepresentation()
15
    {
16
        $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...
17
18
        $this->assertSame(array(), $o->getRepresentations());
19
        $this->assertSame(null, $o->value);
20
21
        $this->assertTrue($o->addRepresentation($r1 = new Representation('Rep 1')));
22
        $this->assertSame(
23
            array(
24
                'rep_1' => $r1,
25
            ),
26
            $o->getRepresentations()
27
        );
28
        $this->assertSame(null, $o->value);
29
30
        $this->assertFalse($o->addRepresentation($r1));
31
        $this->assertSame(
32
            array(
33
                'rep_1' => $r1,
34
            ),
35
            $o->getRepresentations()
36
        );
37
38
        $this->assertTrue($o->addRepresentation($r2 = new Representation('Rep 2')));
39
        $this->assertSame(
40
            array(
41
                'rep_1' => $r1,
42
                'rep_2' => $r2,
43
            ),
44
            $o->getRepresentations()
45
        );
46
47
        $this->assertTrue($o->addRepresentation($r3 = new Representation('Rep 3'), 0));
48
        $this->assertSame(
49
            array(
50
                'rep_3' => $r3,
51
                'rep_1' => $r1,
52
                'rep_2' => $r2,
53
            ),
54
            $o->getRepresentations()
55
        );
56
57
        $this->assertTrue($o->addRepresentation($r4 = new Representation('Rep 4'), 1));
58
        $this->assertSame(
59
            array(
60
                'rep_3' => $r3,
61
                'rep_4' => $r4,
62
                'rep_1' => $r1,
63
                'rep_2' => $r2,
64
            ),
65
            $o->getRepresentations()
66
        );
67
68
        $this->assertTrue($o->addRepresentation($r5 = new Representation('Rep 5'), 100));
69
        $this->assertSame(
70
            array(
71
                'rep_3' => $r3,
72
                'rep_4' => $r4,
73
                'rep_1' => $r1,
74
                'rep_2' => $r2,
75
                'rep_5' => $r5,
76
            ),
77
            $o->getRepresentations()
78
        );
79
80
        $this->assertTrue($o->addRepresentation($r6 = new Representation('Rep 6'), -100));
81
        $this->assertSame(
82
            array(
83
                'rep_6' => $r6,
84
                'rep_3' => $r3,
85
                'rep_4' => $r4,
86
                'rep_1' => $r1,
87
                'rep_2' => $r2,
88
                'rep_5' => $r5,
89
            ),
90
            $o->getRepresentations()
91
        );
92
93
        $this->assertSame(null, $o->value);
94
    }
95
96
    /**
97
     * @covers \Kint\Object\BasicObject::replaceRepresentation
98
     */
99
    public function testReplaceRepresentation()
100
    {
101
        $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...
102
        $o->addRepresentation($r1 = new Representation('Rep 1'));
103
        $o->addRepresentation($r2 = new Representation('Rep 2'));
104
        $o->addRepresentation($r3 = new Representation('Rep 3'));
105
106
        $this->assertSame(
107
            array(
108
                'rep_1' => $r1,
109
                'rep_2' => $r2,
110
                'rep_3' => $r3,
111
            ),
112
            $o->getRepresentations()
113
        );
114
115
        $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...
116
117
        $this->assertSame(
118
            array(
119
                'rep_1' => $r1,
120
                '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...
121
                'rep_3' => $r3,
122
            ),
123
            $o->getRepresentations()
124
        );
125
126
        $o->replaceRepresentation($r2, 0);
127
128
        $this->assertSame(
129
            array(
130
                'rep_2' => $r2,
131
                'rep_1' => $r1,
132
                'rep_3' => $r3,
133
            ),
134
            $o->getRepresentations()
135
        );
136
137
        $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...
138
139
        $this->assertSame(
140
            array(
141
                'rep_1' => $r1,
142
                '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...
143
                'rep_3' => $r3,
144
            ),
145
            $o->getRepresentations()
146
        );
147
    }
148
149
    /**
150
     * @covers \Kint\Object\BasicObject::replaceRepresentation
151
     */
152
    public function testRemoveRepresentation()
153
    {
154
        $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...
155
        $o->addRepresentation($r1 = new Representation('Rep 1'));
156
        $o->addRepresentation($r2 = new Representation('Rep 2'));
157
        $o->addRepresentation($r3 = new Representation('Rep 3'));
158
159
        $this->assertSame(
160
            array(
161
                'rep_1' => $r1,
162
                'rep_2' => $r2,
163
                'rep_3' => $r3,
164
            ),
165
            $o->getRepresentations()
166
        );
167
168
        $o->removeRepresentation('rep_2');
169
170
        $this->assertSame(
171
            array(
172
                'rep_1' => $r1,
173
                'rep_3' => $r3,
174
            ),
175
            $o->getRepresentations()
176
        );
177
    }
178
179
    /**
180
     * @covers \Kint\Object\BasicObject::replaceRepresentation
181
     */
182
    public function testGetRepresentation()
183
    {
184
        $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...
185
        $o->addRepresentation($r1 = new Representation('Rep 1'));
186
        $o->addRepresentation($r2 = new Representation('Rep 2'));
187
        $o->addRepresentation($r3 = new Representation('Rep 3'));
188
189
        $this->assertSame($r1, $o->getRepresentation('rep_1'));
190
        $this->assertSame($r2, $o->getRepresentation('rep_2'));
191
        $this->assertSame($r3, $o->getRepresentation('rep_3'));
192
        $this->assertSame(null, $o->getRepresentation('Non-existant representation name'));
193
    }
194
195
    /**
196
     * @covers \Kint\Object\BasicObject::getRepresentations
197
     */
198
    public function testGetRepresentations()
199
    {
200
        $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...
201
        $o->addRepresentation($r1 = new Representation('Rep 1'));
202
        $o->addRepresentation($r2 = new Representation('Rep 2'));
203
        $o->addRepresentation($r3 = new Representation('Rep 3'));
204
205
        $this->assertSame(
206
            array(
207
                'rep_1' => $r1,
208
                'rep_2' => $r2,
209
                'rep_3' => $r3,
210
            ),
211
            $o->getRepresentations()
212
        );
213
    }
214
215
    /**
216
     * @covers \Kint\Object\BasicObject::clearRepresentations
217
     */
218
    public function testClearRepresentations()
219
    {
220
        $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...
221
        $o->addRepresentation($r1 = new Representation('Rep 1'));
222
        $o->addRepresentation(new Representation('Rep 2'));
223
        $o->addRepresentation(new Representation('Rep 3'));
224
        $o->value = $r1;
225
226
        $o->clearRepresentations();
227
228
        $this->assertSame(array(), $o->getRepresentations());
229
        $this->assertSame($r1, $o->value);
230
    }
231
232
    /**
233
     * @covers \Kint\Object\BasicObject::getType
234
     */
235
    public function testGetType()
236
    {
237
        $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...
238
        $o->type = 'array';
239
        $this->assertEquals('array', $o->getType());
240
    }
241
242
    public function modifierProvider()
243
    {
244
        return array(
245
            'public' => array(
246
                false,
247
                false,
248
                BasicObject::ACCESS_PUBLIC,
249
                'public',
250
            ),
251
            'public const' => array(
252
                true,
253
                false,
254
                BasicObject::ACCESS_PUBLIC,
255
                'public const',
256
            ),
257
            'public static' => array(
258
                false,
259
                true,
260
                BasicObject::ACCESS_PUBLIC,
261
                'public static',
262
            ),
263
            'protected' => array(
264
                false,
265
                false,
266
                BasicObject::ACCESS_PROTECTED,
267
                'protected',
268
            ),
269
            'private' => array(
270
                false,
271
                false,
272
                BasicObject::ACCESS_PRIVATE,
273
                'private',
274
            ),
275
            'none' => array(
276
                false,
277
                false,
278
                BasicObject::ACCESS_NONE,
279
                null,
280
            ),
281
            'private static' => array(
282
                false,
283
                true,
284
                BasicObject::ACCESS_PRIVATE,
285
                'private static',
286
            ),
287
            'public const static' => array(
288
                true,
289
                true,
290
                BasicObject::ACCESS_PUBLIC,
291
                'public const static',
292
            ),
293
            'const' => array(
294
                true,
295
                false,
296
                BasicObject::ACCESS_NONE,
297
                'const',
298
            ),
299
        );
300
        $accesses = array(
0 ignored issues
show
Unused Code introduced by
$accesses = array(\Kint\...bject::ACCESS_PRIVATE); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
Unused Code introduced by
$accesses is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
301
            BasicObject::ACCESS_NONE,
302
            BasicObject::ACCESS_PUBLIC,
303
            BasicObject::ACCESS_PROTECTED,
304
            BasicObject::ACCESS_PRIVATE,
305
        );
306
    }
307
308
    /**
309
     * @dataProvider modifierProvider
310
     * @covers \Kint\Object\BasicObject::getModifiers
311
     */
312
    public function testGetModifiers($const, $static, $access, $expect)
313
    {
314
        $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...
315
        $o->const = $const;
316
        $o->static = $static;
317
        $o->access = $access;
318
        $this->assertSame($expect, $o->getModifiers());
319
    }
320
321
    /**
322
     * @covers \Kint\Object\BasicObject::getAccess
323
     */
324
    public function testGetAccess()
325
    {
326
        $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...
327
        $this->assertNull($o->getAccess());
328
        $o->access = BasicObject::ACCESS_PUBLIC;
329
        $this->assertEquals('public', $o->getAccess());
330
        $o->access = BasicObject::ACCESS_PROTECTED;
331
        $this->assertEquals('protected', $o->getAccess());
332
        $o->access = BasicObject::ACCESS_PRIVATE;
333
        $this->assertEquals('private', $o->getAccess());
334
    }
335
336
    /**
337
     * @covers \Kint\Object\BasicObject::getName
338
     */
339 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...
340
    {
341
        $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...
342
        $o->name = '$var';
343
        $this->assertEquals('$var', $o->getName());
344
        $o->name = '($a + $b)';
345
        $this->assertEquals('($a + $b)', $o->getName());
346
        $o->name = 'This is just a name, nothing more, nothing less.';
347
        $this->assertEquals('This is just a name, nothing more, nothing less.', $o->getName());
348
    }
349
350
    /**
351
     * @covers \Kint\Object\BasicObject::getOperator
352
     */
353
    public function testGetOperator()
354
    {
355
        $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...
356
        $this->assertNull($o->getOperator());
357
        $o->operator = BasicObject::OPERATOR_NONE;
358
        $this->assertNull($o->getOperator());
359
        $o->operator = BasicObject::OPERATOR_ARRAY;
360
        $this->assertEquals('=>', $o->getOperator());
361
        $o->operator = BasicObject::OPERATOR_OBJECT;
362
        $this->assertEquals('->', $o->getOperator());
363
        $o->operator = BasicObject::OPERATOR_STATIC;
364
        $this->assertEquals('::', $o->getOperator());
365
    }
366
367
    /**
368
     * @covers \Kint\Object\BasicObject::getSize
369
     */
370 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...
371
    {
372
        $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...
373
        $this->assertNull($o->getSize());
374
        $o->size = 0;
375
        $this->assertEquals(0, $o->getSize());
376
        $o->size = 42;
377
        $this->assertEquals(42, $o->getSize());
378
    }
379
380
    /**
381
     * @covers \Kint\Object\BasicObject::getValueShort
382
     */
383
    public function testGetValueShort()
384
    {
385
        $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...
386
        $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...
387
        $this->assertNull($o->getValueShort());
388
        $o->value = $r;
389
390
        $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...
391
        $this->assertNull($o->getValueShort());
392
        $o->type = 'boolean';
393
        $this->assertEquals('true', $o->getValueShort());
394
        $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...
395
        $this->assertEquals('false', $o->getValueShort());
396
        $o->type = 'integer';
397
        $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...
398
        $this->assertEquals(1234, $o->getValueShort());
399
        $o->type = 'double';
400
        $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...
401
        $this->assertEquals(1234.5678, $o->getValueShort());
402
        $o->type = 'array';
403
        $r->contents = array();
404
        $this->assertNull($o->getValueShort());
405
        $o->type = 'string';
406
        $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...
407
        $this->assertNull($o->getValueShort());
408
    }
409
410
    /**
411
     * @covers \Kint\Object\BasicObject::getAccessPath
412
     */
413
    public function testGetAccessPath()
414
    {
415
        $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...
416
        $this->assertNull($o->getAccessPath());
417
        $o->access_path = 'abcdefg, hijk elemeno p';
418
        $this->assertEquals('abcdefg, hijk elemeno p', $o->getAccessPath());
419
    }
420
421
    /**
422
     * @covers \Kint\Object\BasicObject::blank
423
     */
424
    public function testBlank()
425
    {
426
        $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...
427
        $this->assertNull($o->name);
428
        $this->assertNull($o->access_path);
429
430
        $o = BasicObject::blank();
431
        $this->assertNull($o->name);
432
        $this->assertNull($o->access_path);
433
434
        $o = BasicObject::blank('$var');
435
        $this->assertEquals('$var', $o->name);
436
        $this->assertEquals('$var', $o->access_path);
437
438
        $o = BasicObject::blank('Name', 'access_path');
439
        $this->assertEquals('Name', $o->name);
440
        $this->assertEquals('access_path', $o->access_path);
441
    }
442
443
    /**
444
     * @covers \Kint\Object\BasicObject::transplant
445
     */
446
    public function testTransplant()
447
    {
448
        $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...
449
450
        $o->name = 'name';
451
        $o->size = 42;
452
        $o->access_path = 'access_path';
453
        $o->access = BasicObject::ACCESS_PUBLIC;
454
        $o->static = true;
455
        $o->const = true;
456
        $o->type = 'type';
457
        $o->depth = 43;
458
        $o->owner_class = 'owner_class';
459
        $o->operator = BasicObject::OPERATOR_OBJECT;
460
        $o->reference = true;
461
        $o->hints = array('test', 'transplant', 'hints');
462
463
        $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...
464
        $o->addRepresentation($r);
465
466
        $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...
467
468
        $this->assertEquals($o, $o2);
469
        $this->assertNotSame($o, $o2);
470
        $this->assertSame($o->value, $o2->value);
471
472
        $o2 = new BasicObject();
473
        $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...
474
        $o2->addRepresentation($r2);
475
        $o2->hints = array('test', 'thoroughly');
476
477
        $o2 = $o->transplant($o2);
478
479
        $this->assertSame(array('test_2' => $r2, 'test' => $r), $o2->getRepresentations());
480
        $this->assertSame(array('test', 'transplant', 'hints', 'test', 'thoroughly'), $o2->hints);
481
    }
482
483
    /**
484
     * @covers \Kint\Object\BasicObject::isSequential
485
     */
486
    public function testIsSequential()
487
    {
488
        $this->assertTrue(BasicObject::isSequential(array(1, 2, 3, 4)));
489
        $this->assertFalse(BasicObject::isSequential(array(0 => 1, 1 => 2, 3 => 3, 2 => 4)));
490
        $this->assertFalse(BasicObject::isSequential(array(0 => 1, 1 => 2, '02' => 3, 3 => 4)));
491
    }
492
493
    /**
494
     * @covers \Kint\Object\BasicObject::sortByAccess
495
     */
496
    public function testSortByAccess()
497
    {
498
        $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...
499
        $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...
500
        $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...
501
502
        $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...
503
504
        $o1->access = BasicObject::ACCESS_PRIVATE;
505
        $o2->access = BasicObject::ACCESS_PROTECTED;
506
        $o3->access = BasicObject::ACCESS_PUBLIC;
507
508
        $this->assertSame(array($o1, $o2, $o3), $a);
509
510
        usort($a, 'Kint\\Object\\BasicObject::sortByAccess');
511
        $this->assertSame(array($o3, $o2, $o1), $a);
512
513
        $o1->access = BasicObject::ACCESS_PROTECTED;
514
        $o2->access = BasicObject::ACCESS_PRIVATE;
515
516
        usort($a, 'Kint\\Object\\BasicObject::sortByAccess');
517
        $this->assertSame(array($o3, $o1, $o2), $a);
518
    }
519
520
    /**
521
     * @covers \Kint\Object\BasicObject::sortByName
522
     */
523
    public function testSortByName()
524
    {
525
        $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...
526
        $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...
527
        $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...
528
529
        $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...
530
531
        $o1->name = 'Name Z';
532
        $o2->name = 'Name B';
533
        $o3->name = 'Name A';
534
535
        $this->assertSame(array($o1, $o2, $o3), $a);
536
537
        usort($a, 'Kint\\Object\\BasicObject::sortByName');
538
        $this->assertSame(array($o3, $o2, $o1), $a);
539
540
        $o1->name = 'Name M';
541
        $o2->name = 'Name Z2';
542
543
        usort($a, 'Kint\\Object\\BasicObject::sortByName');
544
        $this->assertSame(array($o3, $o1, $o2), $a);
545
    }
546
}
547