File: PathComparatorTest.php

package info (click to toggle)
phpab 1.29.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 852 kB
  • sloc: php: 3,467; xml: 162; makefile: 28
file content (49 lines) | stat: -rw-r--r-- 1,672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace TheSeer\Autoload\Tests {

    use TheSeer\Autoload\PathComparator;
    use PHPUnit\Framework\Attributes\DataProvider;

    class PathComparatorTest extends \PHPUnit\Framework\TestCase {

        /**
         * @dataProvider directoriesProvider
         */
        #[DataProvider('directoriesProvider')]
        public function testComparatorYieldsCorrectCommonBase(array $directories, $common) {
            $comparator = new PathComparator($directories);
            $this->assertEquals($common, $comparator->getCommonBase());
        }

        public static function directoriesProvider() {
            return array(
                'empty' => array(
                    array(), '/'
                ),
                'single' => array(
                    array(__DIR__), __DIR__
                ),
                'two' => array(
                    array(__DIR__, dirname(__DIR__)), dirname(__DIR__)
                ),
                'shortfirst' => array(
                    array(dirname(__DIR__), __DIR__), dirname(__DIR__)
                ),
                'parents' => array(
                    array(__DIR__ . '/../src', __DIR__ . '/../tests/_data'), dirname(__DIR__)
                ),
                'with0' => array(
                    array($a=__DIR__.'/_data/parser/trait0.php'), $a
                ),
                'dirwithprefix' => array(
                    array(__DIR__.'/_data/parser/trait0.php', __DIR__.'/_data/parser/trait1.php'), __DIR__.'/_data/parser'
                ),
                'dirwithoutprefix' => array(
                    array(__DIR__, '/usr'), '/'
                )
            );
        }
    }

}