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