Skip to content

Commit

Permalink
fixed bad commnit revert
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-donat committed Nov 4, 2013
1 parent bdbe618 commit 84f13f9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/VirtualFileSystem/WrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ public function testStreamReading()
$fs->container()->createFile('/file2', str_repeat('test data', 5000));
$this->assertEquals(str_repeat('test data', 5000), file_get_contents($fs->path('/file2')));

$fs->container()->createDir('/dir');

$this->assertEmpty(file_get_contents($fs->path('/dir')));

}

public function testOpeningForReadingOnNonExistingFails()
Expand Down Expand Up @@ -747,4 +751,39 @@ public function testDirectoryIterationWithDirectoryIterator()
$this->assertEquals(array('dir1', 'dir2', 'dir3'), $result, 'All directories found');

}

public function testStreamOpenDoesNotOpenDirectoriesForWriting()
{
$fs = new FileSystem();
$fs->container()->createDir('/dir');

$this->assertFalse(@fopen($fs->path('/dir'), 'w'));
$this->assertFalse(@fopen($fs->path('/dir'), 'r+'));
$this->assertFalse(@fopen($fs->path('/dir'), 'w+'));

$opened_path = null;

$wr = new Wrapper();
@$wr->stream_open($fs->path('/dir'), 'w', STREAM_REPORT_ERRORS, $opened_path);

$error = error_get_last();

$this->assertStringMatchesFormat(
'fopen(%s): failed to open stream: Is a directory',
$error['message'],
'Stream does not open directories'
);
}

public function testStreamOpenAllowsForDirectoryOpeningForReadingAndReturnsEmptyStrings()
{
$fs = new FileSystem();
$fs->container()->createDir('/dir');

$handle = fopen($fs->path('/dir'), 'r');

$this->assertTrue(is_resource($handle));

$this->assertEmpty(fread($handle, 1));
}
}

0 comments on commit 84f13f9

Please sign in to comment.