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

ReadmeTestCase   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 4
c 3
b 1
f 1
lcom 1
cbo 5
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormatFactory() 0 4 1
A assertReadme() 0 19 3
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