Skip to content

Commit

Permalink
SplFileInfoRepresentationTest: Check file type first
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Aug 18, 2024
1 parent d48f7bf commit b9bd6d3
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions tests/Zval/Representation/SplFileInfoRepresentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,15 @@ public function testConstructBlockDevice()
{
$f = '/dev/loop0';

if (\file_exists($f)) {
if (\file_exists($f) && 'block' === \filetype($f)) {
$sfi = new SplFileInfo($f);
$size = \filesize($f);
$ctime = \filectime($f);
$mtime = \filemtime($f);
$perms = \fileperms($f);
$owner = \fileowner($f);
$group = \filegroup($f);
$type = \filetype($f);
} else {
$type = 'block';
$sfi = $this->createMock('SplFileInfo');
$sfi->method('getSize')->willReturn($size = 0);
$sfi->method('getCTime')->willReturn($ctime = \time());
Expand Down Expand Up @@ -428,14 +426,9 @@ public function testConstructBlockDevice()
$this->assertSame($f, $r->realpath);
$this->assertNull($r->linktarget);
$this->assertSame(\str_split('brw-rw----'), $r->flags);

if ('block' === $type) {
$this->assertFalse($r->is_file);
$this->assertFalse($r->is_dir);
$this->assertFalse($r->is_link);
} else {
throw new UnexpectedValueException($f.' type is not "block"');
}
$this->assertFalse($r->is_file);
$this->assertFalse($r->is_dir);
$this->assertFalse($r->is_link);
}

/**
Expand Down

0 comments on commit b9bd6d3

Please sign in to comment.