Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated tests for refactored variant processing
- Loading branch information
Coen Zimmerman
committed
Aug 9, 2017
1 parent
0734179
commit b84f0e5
Showing
5 changed files
with
170 additions
and
48 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
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,90 @@ | ||
<?php | ||
namespace Czim\FileHandling\Test\Unit\Storage\File; | ||
|
||
use Czim\FileHandling\Storage\File\ProcessableFile; | ||
use Czim\FileHandling\Storage\File\SplFileInfoStorableFile; | ||
use Czim\FileHandling\Test\TestCase; | ||
use SplFileInfo; | ||
|
||
class ProcessableFileTest extends TestCase | ||
{ | ||
const XML_TEST_FILE = 'tests/resources/test.xml'; | ||
|
||
/** | ||
* @test | ||
*/ | ||
function it_can_set_and_retrieve_content_data() | ||
{ | ||
$file = new ProcessableFile; | ||
|
||
$fileInfo = new SplFileInfo($this->getExampleLocalPath()); | ||
|
||
static::assertSame($file, $file->setData($fileInfo)); | ||
|
||
static::assertEquals(file_get_contents($fileInfo->getRealPath()), $file->content()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
function it_can_set_data_as_a_path_string() | ||
{ | ||
$file = new ProcessableFile; | ||
|
||
$path = $this->getExampleLocalPath(); | ||
|
||
static::assertSame($file, $file->setData($path)); | ||
|
||
static::assertEquals(file_get_contents($path), $file->content()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @expectedException \RuntimeException | ||
*/ | ||
function it_throws_an_exception_if_the_referenced_path_is_not_found() | ||
{ | ||
$file = new ProcessableFile; | ||
|
||
$fileInfo = new SplFileInfo('/no/file/exists/here'); | ||
|
||
$file->setData($fileInfo); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
function it_returns_content_size_when_set() | ||
{ | ||
$file = new ProcessableFile; | ||
|
||
$fileInfo = new SplFileInfo($this->getExampleLocalPath()); | ||
|
||
static::assertSame($file, $file->setData($fileInfo)); | ||
|
||
static::assertEquals($fileInfo->getSize(), $file->size()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
function it_returns_the_path() | ||
{ | ||
$file = new ProcessableFile; | ||
|
||
$fileInfo = new SplFileInfo($this->getExampleLocalPath()); | ||
|
||
static::assertSame($file, $file->setData($fileInfo)); | ||
|
||
static::assertEquals($fileInfo->getRealPath(), $file->path()); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getExampleLocalPath() | ||
{ | ||
return realpath(dirname(__DIR__) . '/../../../' . static::XML_TEST_FILE); | ||
} | ||
|
||
} |
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 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