Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
149 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ composer.lock | |
vendor/ | ||
/coverage/ | ||
coverage.xml | ||
coveralls-upload.json | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace spec\Task\Plugin\Filesystem; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
use Task\Plugin\Filesystem\File; | ||
use org\bovigo\vfs\vfsStream; | ||
use Task\Plugin\Stream\WritableInterface; | ||
|
||
class FileSpec extends ObjectBehavior | ||
{ | ||
private $root; | ||
private $path; | ||
|
||
function let() | ||
{ | ||
$this->root = vfsStream::setup('tmp'); | ||
$this->path = vfsStream::url('tmp').'/test'; | ||
$this->beConstructedWith($this->path); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('Task\Plugin\Filesystem\File'); | ||
} | ||
|
||
function it_should_be_an_spl_file_object() | ||
{ | ||
$this->shouldHaveType('SplFileObject'); | ||
} | ||
|
||
function it_should_be_readable() | ||
{ | ||
$this->shouldHaveType('Task\Plugin\Stream\ReadableInterface'); | ||
} | ||
|
||
function it_should_be_writable() | ||
{ | ||
$this->shouldHaveType('Task\Plugin\Stream\WritableInterface'); | ||
} | ||
|
||
function it_should_read_content() | ||
{ | ||
file_put_contents($this->path, 'foo'); | ||
$this->read()->shouldReturn('foo'); | ||
} | ||
|
||
function it_should_write_content() | ||
{ | ||
$this->write('foo')->shouldReturn($this); | ||
expect(file_get_contents($this->path))->toBe('foo'); | ||
} | ||
|
||
function it_should_write_file_content() | ||
{ | ||
$src = vfsStream::url('tmp').'/src'; | ||
file_put_contents($src, 'foo'); | ||
|
||
$src = new File($src); | ||
$this->write($src); | ||
|
||
$this->read()->shouldReturn('foo'); | ||
} | ||
|
||
function it_should_append_content() | ||
{ | ||
file_put_contents($this->path, 'foo'); | ||
$this->append('bar')->shouldReturn($this); | ||
expect(file_get_contents($this->path))->toBe('foobar'); | ||
} | ||
|
||
function it_should_pipe(WritableInterface $to) | ||
{ | ||
file_put_contents($this->path, 'foo'); | ||
$to->write('foo')->willReturn($to); | ||
$this->pipe($to)->shouldReturn($to); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace spec\Task\Plugin\Filesystem; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
use Task\Plugin\Stream\WritableInterface; | ||
|
||
class FilesystemIteratorSpec extends ObjectBehavior | ||
{ | ||
function let() | ||
{ | ||
$this->beConstructedWith(sys_get_temp_dir()); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('Task\Plugin\Filesystem\FilesystemIterator'); | ||
} | ||
|
||
function it_should_be_a_recursive_iterator() | ||
{ | ||
$this->shouldHaveType('RecursiveIteratorIterator'); | ||
} | ||
|
||
function it_should_be_readable() | ||
{ | ||
$this->shouldHaveType('Task\Plugin\Stream\ReadableInterface'); | ||
} | ||
|
||
function it_should_preserve_original_path() | ||
{ | ||
$this->getPath()->shouldEqual(sys_get_temp_dir()); | ||
} | ||
|
||
function it_should_read() | ||
{ | ||
$this->read()->shouldEqual($this); | ||
} | ||
|
||
function it_should_pipe(WritableInterface $to) | ||
{ | ||
$to->write($this)->willReturn($to); | ||
$this->pipe($to)->shouldReturn($to); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters