Test Setup Failed
Push — next ( 738e04...b06172 )
by Jonathan
25:05
created

SplFileInfoRepresentationTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Kint\Test\Object\Representation;
4
5
use DateTime;
6
use Kint\Object\Representation\SplFileInfoRepresentation;
7
use Kint\Test\KintTestCase;
8
use SplFileInfo;
9
use UnexpectedValueException;
10
11
class SplFileInfoRepresentationTest extends KintTestCase
12
{
13
    protected $socket;
14
15
    public function setUp()
16
    {
17
        symlink(dirname(__DIR__), __DIR__.'/testDirLink');
18
        symlink(__FILE__, __DIR__.'/testFileLink');
19
        symlink(__DIR__.'/testDirLink', __DIR__.'/testDirLink2');
20
        symlink(__DIR__.'/testFileLink', __DIR__.'/testFileLink2');
21
22
        posix_mkfifo(__DIR__.'/testPipe', 0777);
23
24
        $this->socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
25
        socket_bind($this->socket, __DIR__.'/testSocket');
26
    }
27
28
    public function tearDown()
29
    {
30
        unlink(__DIR__.'/testDirLink2');
31
        unlink(__DIR__.'/testFileLink2');
32
        unlink(__DIR__.'/testDirLink');
33
        unlink(__DIR__.'/testFileLink');
34
35
        unlink(__DIR__.'/testPipe');
36
37
        socket_close($this->socket);
38
        unlink(__DIR__.'/testSocket');
39
    }
40
41
    /**
42
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
43
     */
44 View Code Duplication
    public function testConstructFile()
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...
45
    {
46
        $r = new SplFileInfoRepresentation(new SplFileInfo(__FILE__));
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...
47
48
        $this->assertSame(filesize(__FILE__), $r->size);
49
        $this->assertSame(filectime(__FILE__), $r->ctime);
50
        $this->assertSame(filemtime(__FILE__), $r->mtime);
51
        $this->assertSame(fileperms(__FILE__), $r->perms);
52
        $this->assertSame(fileowner(__FILE__), $r->owner);
53
        $this->assertSame(filegroup(__FILE__), $r->group);
54
        $this->assertSame('File', $r->typename);
55
        $this->assertSame('-', $r->typeflag);
56
        $this->assertSame(__FILE__, $r->path);
57
        $this->assertSame(__FILE__, $r->realpath);
58
        $this->assertNull($r->linktarget);
59
60
        if (filetype(__FILE__) === 'file') {
61
            $this->assertTrue($r->is_file);
62
            $this->assertFalse($r->is_dir);
63
            $this->assertFalse($r->is_link);
64
        } else {
65
            throw new UnexpectedValueException(__FILE__.' type is not "file"');
66
        }
67
    }
68
69
    /**
70
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
71
     */
72
    public function testConstructFileLink()
73
    {
74
        $f = __DIR__.'/testFileLink2';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
75
76
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
77
78
        $this->assertSame(filesize($f), $r->size);
79
        $this->assertSame(filectime($f), $r->ctime);
80
        $this->assertSame(filemtime($f), $r->mtime);
81
        $this->assertSame(fileperms($f), $r->perms);
82
        $this->assertSame(fileowner($f), $r->owner);
83
        $this->assertSame(filegroup($f), $r->group);
84
        $this->assertSame('File symlink', $r->typename);
85
        $this->assertSame('l', $r->typeflag);
86
        $this->assertSame($f, $r->path);
87
        $this->assertSame(__FILE__, $r->realpath);
88
        $this->assertSame(__DIR__.'/testFileLink', $r->linktarget);
89
90
        if (filetype($f) === 'link') {
91
            $this->assertTrue($r->is_file);
92
            $this->assertFalse($r->is_dir);
93
            $this->assertTrue($r->is_link);
94
        } else {
95
            throw new UnexpectedValueException($f.' type is not "link"');
96
        }
97
    }
98
99
    /**
100
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
101
     */
102 View Code Duplication
    public function testConstructLinkedFile()
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...
103
    {
104
        $f = __DIR__.'/testDirLink/'.basename(__DIR__).'/'.basename(__FILE__);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
105
106
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
107
108
        $this->assertSame(filesize($f), $r->size);
109
        $this->assertSame(filectime($f), $r->ctime);
110
        $this->assertSame(filemtime($f), $r->mtime);
111
        $this->assertSame(fileperms($f), $r->perms);
112
        $this->assertSame(fileowner($f), $r->owner);
113
        $this->assertSame(filegroup($f), $r->group);
114
        $this->assertSame('File', $r->typename);
115
        $this->assertSame('-', $r->typeflag);
116
        $this->assertSame($f, $r->path);
117
        $this->assertSame(__FILE__, $r->realpath);
118
        $this->assertNull($r->linktarget);
119
120
        if (filetype($f) === 'file') {
121
            $this->assertTrue($r->is_file);
122
            $this->assertFalse($r->is_dir);
123
            $this->assertFalse($r->is_link);
124
        } else {
125
            throw new UnexpectedValueException($f.' type is not "file"');
126
        }
127
    }
128
129
    /**
130
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
131
     */
132 View Code Duplication
    public function testConstructDir()
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...
133
    {
134
        $r = new SplFileInfoRepresentation(new SplFileInfo(__DIR__));
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...
135
136
        $this->assertSame(filesize(__DIR__), $r->size);
137
        $this->assertSame(filectime(__DIR__), $r->ctime);
138
        $this->assertSame(filemtime(__DIR__), $r->mtime);
139
        $this->assertSame(fileperms(__DIR__), $r->perms);
140
        $this->assertSame(fileowner(__DIR__), $r->owner);
141
        $this->assertSame(filegroup(__DIR__), $r->group);
142
        $this->assertSame('Directory', $r->typename);
143
        $this->assertSame('d', $r->typeflag);
144
        $this->assertSame(__DIR__, $r->path);
145
        $this->assertSame(__DIR__, $r->realpath);
146
        $this->assertNull($r->linktarget);
147
148
        if (filetype(__DIR__) === 'dir') {
149
            $this->assertFalse($r->is_file);
150
            $this->assertTrue($r->is_dir);
151
            $this->assertFalse($r->is_link);
152
        } else {
153
            throw new UnexpectedValueException(__DIR__.' type is not "dir"');
154
        }
155
    }
156
157
    /**
158
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
159
     */
160 View Code Duplication
    public function testConstructDirLink()
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...
161
    {
162
        $f = __DIR__.'/testDirLink2';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
163
164
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
165
166
        $this->assertSame(filesize($f), $r->size);
167
        $this->assertSame(filectime($f), $r->ctime);
168
        $this->assertSame(filemtime($f), $r->mtime);
169
        $this->assertSame(fileperms($f), $r->perms);
170
        $this->assertSame(fileowner($f), $r->owner);
171
        $this->assertSame(filegroup($f), $r->group);
172
        $this->assertSame('Directory symlink', $r->typename);
173
        $this->assertSame('l', $r->typeflag);
174
        $this->assertSame($f, $r->path);
175
        $this->assertSame(dirname(__DIR__), $r->realpath);
176
        $this->assertSame(__DIR__.'/testDirLink', $r->linktarget);
177
178
        if (filetype($f) === 'link') {
179
            $this->assertFalse($r->is_file);
180
            $this->assertTrue($r->is_dir);
181
            $this->assertTrue($r->is_link);
182
        } else {
183
            throw new UnexpectedValueException($f.' type is not "link"');
184
        }
185
    }
186
187
    /**
188
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
189
     */
190 View Code Duplication
    public function testConstructLinkedDir()
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...
191
    {
192
        $f = __DIR__.'/testDirLink/'.basename(__DIR__);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
193
194
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
195
196
        $this->assertSame(filesize($f), $r->size);
197
        $this->assertSame(filectime($f), $r->ctime);
198
        $this->assertSame(filemtime($f), $r->mtime);
199
        $this->assertSame(fileperms($f), $r->perms);
200
        $this->assertSame(fileowner($f), $r->owner);
201
        $this->assertSame(filegroup($f), $r->group);
202
        $this->assertSame('Directory', $r->typename);
203
        $this->assertSame('d', $r->typeflag);
204
        $this->assertSame($f, $r->path);
205
        $this->assertSame(__DIR__, $r->realpath);
206
        $this->assertNull($r->linktarget);
207
208
        if (filetype($f) === 'dir') {
209
            $this->assertFalse($r->is_file);
210
            $this->assertTrue($r->is_dir);
211
            $this->assertFalse($r->is_link);
212
        } else {
213
            throw new UnexpectedValueException($f.' type is not "dir"');
214
        }
215
    }
216
217
    /**
218
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
219
     */
220 View Code Duplication
    public function testConstructPipe()
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...
221
    {
222
        $f = __DIR__.'/testPipe';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
223
224
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
225
226
        $this->assertSame(filesize($f), $r->size);
227
        $this->assertSame(filectime($f), $r->ctime);
228
        $this->assertSame(filemtime($f), $r->mtime);
229
        $this->assertSame(fileperms($f), $r->perms);
230
        $this->assertSame(fileowner($f), $r->owner);
231
        $this->assertSame(filegroup($f), $r->group);
232
        $this->assertSame('Named pipe', $r->typename);
233
        $this->assertSame('p', $r->typeflag);
234
        $this->assertSame($f, $r->path);
235
        $this->assertSame($f, $r->realpath);
236
        $this->assertNull($r->linktarget);
237
238
        if (filetype($f) === 'fifo') {
239
            $this->assertFalse($r->is_file);
240
            $this->assertFalse($r->is_dir);
241
            $this->assertFalse($r->is_link);
242
        } else {
243
            throw new UnexpectedValueException($f.' type is not "fifo"');
244
        }
245
    }
246
247
    /**
248
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
249
     */
250 View Code Duplication
    public function testConstructSocket()
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...
251
    {
252
        $f = __DIR__.'/testSocket';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
253
254
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
255
256
        $this->assertSame(filesize($f), $r->size);
257
        $this->assertSame(filectime($f), $r->ctime);
258
        $this->assertSame(filemtime($f), $r->mtime);
259
        $this->assertSame(fileperms($f), $r->perms);
260
        $this->assertSame(fileowner($f), $r->owner);
261
        $this->assertSame(filegroup($f), $r->group);
262
        $this->assertSame('Socket', $r->typename);
263
        $this->assertSame('s', $r->typeflag);
264
        $this->assertSame($f, $r->path);
265
        $this->assertSame($f, $r->realpath);
266
        $this->assertNull($r->linktarget);
267
268
        if (filetype($f) === 'socket') {
269
            $this->assertFalse($r->is_file);
270
            $this->assertFalse($r->is_dir);
271
            $this->assertFalse($r->is_link);
272
        } else {
273
            throw new UnexpectedValueException($f.' type is not "socket"');
274
        }
275
    }
276
277
    /**
278
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
279
     */
280 View Code Duplication
    public function testConstructCharacterDevice()
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...
281
    {
282
        $f = '/dev/null';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
283
284
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
285
286
        $this->assertSame(filesize($f), $r->size);
287
        $this->assertSame(filectime($f), $r->ctime);
288
        $this->assertSame(filemtime($f), $r->mtime);
289
        $this->assertSame(fileperms($f), $r->perms);
290
        $this->assertSame(fileowner($f), $r->owner);
291
        $this->assertSame(filegroup($f), $r->group);
292
        $this->assertSame('Character device', $r->typename);
293
        $this->assertSame('c', $r->typeflag);
294
        $this->assertSame($f, $r->path);
295
        $this->assertSame($f, $r->realpath);
296
        $this->assertNull($r->linktarget);
297
298
        if (filetype($f) === 'char') {
299
            $this->assertFalse($r->is_file);
300
            $this->assertFalse($r->is_dir);
301
            $this->assertFalse($r->is_link);
302
        } else {
303
            throw new UnexpectedValueException($f.' type is not "char"');
304
        }
305
    }
306
307
    /**
308
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
309
     */
310
    public function testConstructBlockDevice()
311
    {
312
        $f = '/dev/loop0';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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
314
        if (file_exists($f)) {
315
            $sfi = new SplFileInfo($f);
316
            $size = filesize($f);
317
            $ctime = filectime($f);
318
            $mtime = filemtime($f);
319
            $perms = fileperms($f);
320
            $owner = fileowner($f);
321
            $group = filegroup($f);
322
            $type = filetype($f);
323
        } else {
324
            $type = 'block';
325
            $mock = $this->prophesize('SplFileInfo');
326
            $mock->getSize()->willReturn($size = 0);
327
            $mock->getCTime()->willReturn($ctime = time());
328
            $mock->getMTime()->willReturn($mtime = time());
329
            $mock->getPerms()->willReturn($perms = 0x6444);
330
            $mock->getOwner()->willReturn($owner = fileowner(__FILE__));
331
            $mock->getGroup()->willReturn($group = filegroup(__FILE__));
332
            $mock->getPathname()->willReturn($f);
333
            $mock->getRealPath()->willReturn($f);
334
            $mock->isDir()->willReturn(false);
335
            $mock->isFile()->willReturn(false);
336
            $mock->isLink()->willReturn(false);
337
            $sfi = $mock->reveal();
338
        }
339
340
        $r = new SplFileInfoRepresentation($sfi);
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...
341
342
        $this->assertSame($size, $r->size);
343
        $this->assertSame($ctime, $r->ctime);
344
        $this->assertSame($mtime, $r->mtime);
345
        $this->assertSame($perms, $r->perms);
346
        $this->assertSame($owner, $r->owner);
347
        $this->assertSame($group, $r->group);
348
        $this->assertSame('Block device', $r->typename);
349
        $this->assertSame('b', $r->typeflag);
350
        $this->assertSame($f, $r->path);
351
        $this->assertSame($f, $r->realpath);
352
        $this->assertNull($r->linktarget);
353
354
        if ($type === 'block') {
355
            $this->assertFalse($r->is_file);
356
            $this->assertFalse($r->is_dir);
357
            $this->assertFalse($r->is_link);
358
        } else {
359
            throw new UnexpectedValueException($f.' type is not "block"');
360
        }
361
    }
362
363
    /**
364
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
365
     */
366
    public function testConstructNone()
367
    {
368
        $f = __FILE__.'/nonexistant';
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $f. 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...
369
370
        $r = new SplFileInfoRepresentation(new SplFileInfo($f));
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...
371
372
        $this->assertNull($r->size);
373
        $this->assertNull($r->ctime);
374
        $this->assertNull($r->mtime);
375
        $this->assertNull($r->perms);
376
        $this->assertNull($r->owner);
377
        $this->assertNull($r->group);
378
        $this->assertSame('Unknown file', $r->typename);
379
        $this->assertSame('-', $r->typeflag);
380
        $this->assertSame($f, $r->path);
381
        $this->assertNull($r->realpath);
382
        $this->assertNull($r->linktarget);
383
        $this->assertFalse($r->is_file);
384
        $this->assertFalse($r->is_dir);
385
        $this->assertFalse($r->is_link);
386
    }
387
388
    /**
389
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::getLabel
390
     */
391
    public function testGetLabel()
392
    {
393
        $r = new SplFileInfoRepresentation(new SplFileInfo(__FILE__));
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...
394
395
        $r->typename = 'test123';
396
        $r->size = 1100;
397
398
        $this->assertSame('test123 (1.07KB)', $r->getLabel());
399
    }
400
401
    /**
402
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::getSize
403
     */
404
    public function testGetSize()
405
    {
406
        $r = new SplFileInfoRepresentation(new SplFileInfo(__FILE__));
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...
407
408
        $r->size = 0;
409
        $this->assertNull($r->getSize());
410
411
        $r->size = 42;
412
        $this->assertSame('42B', $r->getSize());
413
414
        $r->size = 1024;
415
        $this->assertSame('1KB', $r->getSize());
416
417
        $r->size = 1100;
418
        $this->assertSame('1.07KB', $r->getSize());
419
420
        $r->size = 1024 * 1024;
421
        $this->assertSame('1MB', $r->getSize());
422
    }
423
424
    /**
425
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::getMTime
426
     */
427
    public function testGetMTime()
428
    {
429
        $r = new SplFileInfoRepresentation(new SplFileInfo(__FILE__));
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...
430
        $r->mtime = 0;
431
432
        $this->assertSame('Jan 01 1970', $r->getMTime());
433
434
        $dt = new DateTime('midnight +1 hour +23 minutes');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $dt. 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...
435
        $r->mtime = $dt->format('U');
436
437
        $this->assertSame(date('M d').' 01:23', $r->getMTime());
438
    }
439
}
440