Completed
Push — master ( efd42a...575f81 )
by Hannes
02:14
created

ReadmeTestCase::getFormatFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace hanneskod\readmetester\PHPUnit;
4
5
use hanneskod\readmetester;
6
7
class ReadmeTestCase extends \PHPUnit_Framework_TestCase
8
{
9
    protected function getFormatFactory()
10
    {
11
        return new readmetester\Format\FormatFactory;
12
    }
13
14
    public function assertReadme($filename, $formatIdentifier = '')
15
    {
16
        $this->addToAssertionCount(1);
17
18
        $file = new \SplFileObject($filename);
19
20
        if (!$formatIdentifier) {
21
            $formatIdentifier = $file->getExtension();
22
        }
23
24
        $format = $this->getFormatFactory()->createFormat($formatIdentifier);
25
26
        $tester = new readmetester\ReadmeTester;
27
        $result = $this->getTestResultObject();
28
29
        foreach ($tester->test($file, $format) as $line) {
30
            $result->addFailure($this, new \PHPUnit_Framework_AssertionFailedError($line), 0.0);
31
        }
32
    }
33
}
34