Completed
Pull Request — master (#13)
by Victor
01:57
created

FileSystemReaderTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 72
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCanCreate() 0 7 1
1
<?php
2
3
namespace Test\DiTesto\FileSystem;
4
5
use LazyEight\DiTesto\FileSystem\FileSystemPath;
6
use LazyEight\DiTesto\FileSystem\FileSystemReader;
7
use PHPUnit\Framework\TestCase;
8
9
class FileSystemReaderTest extends TestCase
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $file = './tests/files/urls.txt';
15
16
    /**
17
     * @var string
18
     */
19
    protected $imageFile = './tests/files/images.jpg';
20
21
    /**
22
     * @var string
23
     */
24
    protected $notReadable = './tests/files/urls_not_readable.txt';
25
26
    /**
27
     * @covers \LazyEight\DiTesto\FileSystem\FileSystemReader::__construct
28
     * @return FileSystemReader
29
     */
30
    public function testCanCreate()
31
    {
32
        $instance = new FileSystemReader(new FileSystemPath($this->file));
33
        $this->assertInstanceOf(FileSystemReader::class, $instance);
34
35
        return $instance;
36
    }
37
38
//    /**
39
//     * @covers \LazyEight\DiTesto\FileReader::__construct
40
//     * @covers \LazyEight\DiTesto\FileReader::readFile
41
//     * @covers \LazyEight\DiTesto\FileSystem\FileSystemHandler::readable
42
//     * @covers \LazyEight\DiTesto\FileSystem\FileSystemHandler::read
43
//     * @uses \LazyEight\DiTesto\FileReader
44
//     * @uses \LazyEight\DiTesto\FileReader
45
//     * @param \LazyEight\DiTesto\TextFileLoader
46
//     */
47
//    public function testCanRead()
48
//    {
49
//        $textFile = new TextFile($this->file);
50
//        (new FileReader($textFile, new FileSystemHandler($textFile->getPath())))->readFile();
51
//
52
//        $arrFile = explode(PHP_EOL, file_get_contents($this->file));
53
//        $this->assertTrue(count($arrFile) === count($textFile));
54
//    }
55
//
56
//    /**
57
//     * @covers \LazyEight\DiTesto\FileReader::readFile
58
//     * @covers \LazyEight\DiTesto\FileSystem\FileSystemHandler::readable
59
//     * @covers \LazyEight\DiTesto\FileSystem\FileSystemHandler::read
60
//     * @expectedException \LazyEight\DiTesto\Exceptions\FileSystemException
61
//     * @uses \LazyEight\DiTesto\FileReader
62
//     */
63
//    public function testCantBeLoaded()
64
//    {
65
//        $this->expectException(\Throwable::class);
66
//        (new FileReader(new TextFile(''), new FileSystemHandler('')))->readFile();
67
//    }
68
//
69
//    /**
70
//     * @covers \LazyEight\DiTesto\FileReader::readFile
71
//     * @expectedException \LazyEight\DiTesto\Exceptions\FileSystemException
72
//     */
73
//    public function testCantRead()
74
//    {
75
//        chmod($this->notReadable, 0000);
76
//
77
//        $this->expectException(FileSystemException::class);
78
//        (new FileReader(new TextFile($this->notReadable), new FileSystemHandler($this->notReadable)))->readFile();
79
//    }
80
}
81