Passed
Pull Request — master (#10)
by Robbie
01:27
created

DocumentationCheckTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRun() 0 17 1
A runProvider() 0 5 1
1
<?php
2
3
namespace SilverStripe\ModuleRatings\Tests\Check;
4
5
use PHPUnit\Framework\TestCase;
6
use SilverStripe\ModuleRatings\Check\DocumentationCheck;
7
use SilverStripe\ModuleRatings\CheckSuite;
8
use Symfony\Component\Finder\Finder;
9
10
class DocumentationCheckTest extends TestCase
11
{
12
    /**
13
     * @dataProvider runProvider
14
     * @param string[] $filenames
15
     * @param bool $expected
16
     */
17
    public function testRun($filenames, $expected)
18
    {
19
        // Set up the Finder mock
20
        $finder = $this->getMockBuilder(Finder::class)
21
            ->setMethods(['directories', 'in', 'name'])
22
            ->getMock();
23
24
        $finder->expects($this->once())->method('directories')->will($this->returnSelf());
25
        $finder->expects($this->once())->method('in')->will($this->returnSelf());
26
        $finder->expects($this->once())->method('name')->willReturn($filenames);
27
28
        $check = new DocumentationCheck();
29
        $check->setSuite(new CheckSuite());
30
        $check->setFinder($finder);
31
        $check->run();
32
33
        $this->assertSame($expected, $check->getSuccessful());
34
    }
35
36
    /**
37
     * @return array[]
38
     */
39
    public function runProvider()
40
    {
41
        return [
42
            'docs folder' => [['doc'], true],
43
            'doc folder' => [['docs'], true],
44
        ];
45
    }
46
}
47