1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: victor |
5
|
|
|
* Date: 10/04/16 |
6
|
|
|
* Time: 02:04 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Test\DiTesto; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
use LazyEight\BasicTypes\Stringy; |
13
|
|
|
use LazyEight\DiTesto\ValueObject\FileContent; |
14
|
|
|
|
15
|
|
|
class FileContentTest extends \PHPUnit_Framework_TestCase |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $file = './tests/files/urls.txt'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @covers \LazyEight\DiTesto\ValueObject\FileContent::__construct |
24
|
|
|
* @uses \LazyEight\DiTesto\ValueObject\FileContent |
25
|
|
|
* @return \LazyEight\DiTesto\ValueObject\FileContent |
26
|
|
|
*/ |
27
|
|
|
public function testCanBeCreated() |
28
|
|
|
{ |
29
|
|
|
$instance = new FileContent(new Stringy(file_get_contents($this->file))); |
30
|
|
|
$this->assertInstanceOf(FileContent::class, $instance); |
31
|
|
|
return $instance; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @covers \LazyEight\DiTesto\ValueObject\FileContent::getValue |
36
|
|
|
* @covers \LazyEight\DiTesto\ValueObject\AbstractFileContent::getValue |
37
|
|
|
* @uses \LazyEight\DiTesto\ValueObject\FileContent |
38
|
|
|
* @depends testCanBeCreated |
39
|
|
|
* @uses \LazyEight\DiTesto\ValueObject\FileContent |
40
|
|
|
* @param \LazyEight\DiTesto\ValueObject\FileContent |
41
|
|
|
*/ |
42
|
|
|
public function testValueCanBeRetrieved(FileContent $content) |
43
|
|
|
{ |
44
|
|
|
$this->assertEquals($content->getValue()->getValue(), new Stringy(file_get_contents($this->file))); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @covers \LazyEight\DiTesto\ValueObject\FileContent::__toString |
49
|
|
|
* @covers \LazyEight\DiTesto\ValueObject\AbstractFileContent::__toString |
50
|
|
|
* @uses \LazyEight\DiTesto\ValueObject\FileContent |
51
|
|
|
* @depends testCanBeCreated |
52
|
|
|
* @uses \LazyEight\DiTesto\ValueObject\FileContent |
53
|
|
|
* @param \LazyEight\DiTesto\ValueObject\FileContent |
54
|
|
|
*/ |
55
|
|
|
public function testToString(FileContent $content) |
56
|
|
|
{ |
57
|
|
|
$this->assertEquals($content->__toString(), file_get_contents($this->file)); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|