Test Setup Failed
Push — test ( d5b2bb...f2c6f9 )
by Jonathan
03:17
created

SplFileInfoRepresentationTest::testConstructNone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 19
rs 9.4285
c 1
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 View Code Duplication
    public function testConstructFileLink()
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...
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);
0 ignored issues
show
Unused Code introduced by
$size 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...
317
            $ctime = filectime($f);
0 ignored issues
show
Unused Code introduced by
$ctime 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...
318
            $mtime = filemtime($f);
0 ignored issues
show
Unused Code introduced by
$mtime 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...
319
            $owner = fileowner($f);
0 ignored issues
show
Unused Code introduced by
$owner 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...
320
            $group = filegroup($f);
0 ignored issues
show
Unused Code introduced by
$group 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...
321
            $perms = fileperms($f);
0 ignored issues
show
Unused Code introduced by
$perms 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...
322
        } else {
323
            $mock = $this->prophesize('SplFileInfo');
324
            $mock->getSize()->willReturn($size = 0);
325
            $mock->getCTime()->willReturn($ctime = time());
326
            $mock->getMTime()->willReturn($mtime = time());
327
            $mock->getPerms()->willReturn($perms = 0x6444);
328
            $mock->getOwner()->willReturn($owner = fileowner(__FILE__));
329
            $mock->getGroup()->willReturn($group = filegroup(__FILE__));
330
            $mock->getPathname()->willReturn($f);
331
            $mock->getRealPath()->willReturn($f);
332
            $mock->isDir()->willReturn(false);
333
            $mock->isFile()->willReturn(false);
334
            $mock->isLink()->willReturn(false);
335
            $sfi = $mock->reveal();
336
        }
337
338
        $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...
339
340
        $this->assertSame(filesize($f), $r->size);
341
        $this->assertSame(filectime($f), $r->ctime);
342
        $this->assertSame(filemtime($f), $r->mtime);
343
        $this->assertSame(fileperms($f), $r->perms);
344
        $this->assertSame(fileowner($f), $r->owner);
345
        $this->assertSame(filegroup($f), $r->group);
346
        $this->assertSame('Block device', $r->typename);
347
        $this->assertSame('b', $r->typeflag);
348
        $this->assertSame($f, $r->path);
349
        $this->assertSame($f, $r->realpath);
350
        $this->assertNull($r->linktarget);
351
352
        if (filetype($f) === 'block') {
353
            $this->assertFalse($r->is_file);
354
            $this->assertFalse($r->is_dir);
355
            $this->assertFalse($r->is_link);
356
        } else {
357
            throw new UnexpectedValueException($f.' type is not "block"');
358
        }
359
    }
360
361
    /**
362
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::__construct
363
     */
364
    public function testConstructNone()
365
    {
366
        $r = new SplFileInfoRepresentation(new SplFileInfo(__FILE__.'/nonexistant'));
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...
367
368
        $this->assertNull($r->size);
369
        $this->assertNull($r->ctime);
370
        $this->assertNull($r->mtime);
371
        $this->assertNull($r->perms);
372
        $this->assertNull($r->owner);
373
        $this->assertNull($r->group);
374
        $this->assertSame('Unknown file', $r->typename);
375
        $this->assertSame('-', $r->typeflag);
376
        $this->assertNull($r->path);
377
        $this->assertNull($r->realpath);
378
        $this->assertNull($r->linktarget);
379
        $this->assertFalse($r->is_file);
380
        $this->assertFalse($r->is_dir);
381
        $this->assertFalse($r->is_link);
382
    }
383
384
    /**
385
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::getLabel
386
     */
387
    public function testGetLabel()
388
    {
389
        $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...
390
391
        $r->typename = 'test123';
392
        $r->size = 1100;
393
394
        $this->assertSame('test123 (1.07KB)', $r->getLabel());
395
    }
396
397
    /**
398
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::getSize
399
     */
400
    public function testGetSize()
401
    {
402
        $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...
403
404
        $r->size = 0;
405
        $this->assertNull($r->getSize());
406
407
        $r->size = 42;
408
        $this->assertSame('42B', $r->getSize());
409
410
        $r->size = 1024;
411
        $this->assertSame('1KB', $r->getSize());
412
413
        $r->size = 1100;
414
        $this->assertSame('1.07KB', $r->getSize());
415
416
        $r->size = 1024 * 1024;
417
        $this->assertSame('1MB', $r->getSize());
418
    }
419
420
    /**
421
     * @covers \Kint\Object\Representation\SplFileInfoRepresentation::getMTime
422
     */
423
    public function testGetMTime()
424
    {
425
        $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...
426
        $r->mtime = 0;
427
428
        $this->assertSame('Jan 01 1970', $r->getMTime());
429
430
        $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...
431
        $r->mtime = $dt->format('U');
432
433
        $this->assertSame(date('M d').' 01:23', $r->getMTime());
434
    }
435
}
436