Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions spec/Task/Plugin/Filesystem/FileSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,25 @@ function it_should_write_content()
expect(file_get_contents($this->path))->toBe('foo');
}

function it_should_write_file_content()
function it_should_write_new_file_content()
{
$src = vfsStream::url('tmp').'/src';

$src = new File($src);
$this->write('bar');

$this->read()->shouldReturn('bar');
}

function it_should_overwrite_file_content()
{
$src = vfsStream::url('tmp').'/src';
file_put_contents($src, 'foo');

$src = new File($src);
$this->write($src);
$this->write('bar');

$this->read()->shouldReturn('foo');
$this->read()->shouldReturn('bar');
}

function it_should_append_content()
Expand Down
1 change: 1 addition & 0 deletions src/Filesystem/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function write($data)
}

$this->ftruncate(0);
$this->rewind();
$this->fwrite($data);
return $this;
}
Expand Down