Completed
Push — develop ( 48a3ec...fa4cb4 )
by Mike
05:54
created

FlySystemFileTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFileCanBeInstantiatedAndPathIsReturned() 0 7 1
A testContentsOfFileCanBeRetrieved() 0 12 1
A testGetHashForFile() 0 12 1
1
<?php declare(strict_types=1);
2
3
namespace phpDocumentor\Parser;
4
5
use League\Flysystem\FilesystemInterface;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @coversDefaultClass \phpDocumentor\Parser\FlySystemFile
10
 * @covers ::__construct
11
 * @covers ::<private>
12
 */
13
final class FlySystemFileTest extends TestCase
14
{
15
    /**
16
     * @covers ::path()
17
     */
18
    public function testFileCanBeInstantiatedAndPathIsReturned()
19
    {
20
        $path = '/path/to/file';
21
        $file = new FlySystemFile($this->prophesize(FilesystemInterface::class)->reveal(), $path);
22
23
        $this->assertSame($path, $file->path());
24
    }
25
26
    /**
27
     * @covers ::getContents
28
     */
29
    public function testContentsOfFileCanBeRetrieved()
30
    {
31
        $path = '/path/to/file';
32
        $contents = 'contents';
33
34
        $fileSystem = $this->prophesize(FilesystemInterface::class);
35
        $fileSystem->read($path)->willReturn($contents);
36
37
        $file = new FlySystemFile($fileSystem->reveal(), $path);
38
39
        $this->assertSame($contents, $file->getContents());
40
    }
41
42
    /**
43
     * @covers ::md5
44
     */
45
    public function testGetHashForFile()
46
    {
47
        $path = '/path/to/file';
48
        $contents = 'contents';
49
50
        $fileSystem = $this->prophesize(FilesystemInterface::class);
51
        $fileSystem->read($path)->willReturn($contents);
52
53
        $file = new FlySystemFile($fileSystem->reveal(), $path);
54
55
        $this->assertSame(md5($contents), $file->md5());
56
    }
57
}
58