DirectoryClassScannerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 57
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testDirectoryScannerWithPaths() 0 13 1
A testDirectoryScannerWithIterator() 0 4 1
A pathsProvider() 0 20 1
1
<?php
2
3
namespace FinalizerTest\Scanner;
4
5
use Finalizer\Scanner\DirectoryClassScanner;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @covers \Finalizer\Scanner\DirectoryClassScanner
10
 */
11
class DirectoryClassScannerTest extends TestCase
12
{
13
    /**
14
     * @dataProvider pathsProvider
15
     *
16
     * @param string[]|\Traversable $paths
17
     * @param string[]              $expectedClasses
18
     */
19
    public function testDirectoryScannerWithPaths($paths, $expectedClasses)
20
    {
21
        $found = array_values(array_map(
22
            function (\ReflectionClass $class) {
23
                return $class->getName();
24
            },
25
            (new DirectoryClassScanner())->__invoke($paths)
26
        ));
27
28
        sort($found);
29
30
        $this->assertEquals($expectedClasses, $found);
31
    }
32
33
    /**
34
     * @dataProvider pathsProvider
35
     *
36
     * @param string[]|array $paths
37
     * @param string[]       $expectedClasses
38
     */
39
    public function testDirectoryScannerWithIterator(array $paths, $expectedClasses)
40
    {
41
        $this->testDirectoryScannerWithPaths(new \ArrayIterator($paths), $expectedClasses);
42
    }
43
44
    /**
45
     * @return string[][][]
46
     */
47
    public function pathsProvider()
48
    {
49
        return [
50
            [
51
                [__FILE__],
52
                [__CLASS__],
53
            ],
54
            [
55
                [__FILE__, __DIR__ . '/DirectoryFileScannerTest.php'],
56
                [__CLASS__, DirectoryFileScannerTest::class],
57
            ],
58
            [
59
                [
60
                    __FILE__,
61
                    __DIR__ . '/../../FinalizerTestAsset/Scanner/DirectoryFileScanner/DirWithOnePhpFile/1.php'
62
                ],
63
                [__CLASS__],
64
            ],
65
        ];
66
    }
67
}
68