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

AbstractFileTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 65
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanBeCreated() 0 8 1
A testCantBeCreated() 0 8 1
A testPath() 0 5 1
A testRawContent() 0 7 1
1
<?php
2
3
namespace Test\DiTesto;
4
5
use LazyEight\DiTesto\AbstractFile;
6
use PHPUnit\Framework\TestCase;
7
8
class AbstractFileTest extends TestCase
9
{
10
    /**
11
     * @var string
12
     */
13
    private $path = 'PATH';
14
15
    /**
16
     * @var string
17
     */
18
    private $content = 'RAW_CONTENT';
19
20
    /**
21
     * @covers \LazyEight\DiTesto\AbstractFile::__construct
22
     * @uses \LazyEight\DiTesto\AbstractFile
23
     * @return \LazyEight\DiTesto\AbstractFile
24
     */
25
    public function testCanBeCreated()
26
    {
27
        $path = $this->path;
28
        $instance = $this->getMockForAbstractClass(AbstractFile::class, [$path]);
29
        $this->assertInstanceOf(AbstractFile::class, $instance);
30
31
        return $instance;
32
    }
33
34
    /**
35
     * @covers \LazyEight\DiTesto\AbstractFile::__construct
36
     * @uses \LazyEight\DiTesto\AbstractFile
37
     */
38
    public function testCantBeCreated()
39
    {
40
        $this->expectException(\TypeError::class);
41
        $instance = $this->getMockForAbstractClass(AbstractFile::class);
42
        $instance->setPath($this->path);
43
44
        return $instance;
45
    }
46
47
    /**
48
     * @covers \LazyEight\DiTesto\AbstractFile::getPath
49
     * @covers \LazyEight\DiTesto\AbstractFile::setPath
50
     * @depends testCanBeCreated
51
     */
52
    public function testPath(AbstractFile $file)
53
    {
54
        $file->setPath($this->path);
55
        $this->assertEquals($this->path, $file->getPath());
56
    }
57
58
    /**
59
     * @covers \LazyEight\DiTesto\AbstractFile::setRawContent
60
     * @covers \LazyEight\DiTesto\AbstractFile::getRawContent
61
     * @depends testCanBeCreated
62
     */
63
    public function testRawContent(AbstractFile $file)
64
    {
65
        $file->setRawContent($this->content);
66
        $this->assertEquals($this->content, $file->getRawContent());
67
68
        return $file;
69
    }
70
71
72
}
73