Passed
Push — master ( e11383...6e4589 )
by Théo
04:13 queued 02:07
created

ConfigurationTest::test_it_validates_the_prefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 19
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
use Humbug\PhpScoper\Configuration;
6
use Humbug\PhpScoper\Whitelist;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @covers \Humbug\PhpScoper\ConfigurationFactory
11
 */
12
final class ConfigurationTest extends TestCase
13
{
14
    /**
15
     * @dataProvider prefixProvider
16
     */
17
    public function test_it_validates_the_prefix(
18
        string $prefix,
19
        string $expectedExceptionMessage
20
    ): void
21
    {
22
        $this->expectException(InvalidArgumentException::class);
23
        $this->expectExceptionMessage($expectedExceptionMessage);
24
25
        new Configuration(
26
            null,
27
            $prefix,
28
            [],
29
            [],
30
            Whitelist::create(
31
                false,
32
                false,
33
                false,
34
            ),
35
            [],
36
        );
37
    }
38
39
    public static function prefixProvider(): iterable
40
    {
41
        yield [
42
            ';',
43
            'The prefix needs to be composed solely of letters, digits and backslashes (as namespace separators). Got ";"',
44
        ];
45
46
        yield [
47
            'App\\\\Foo',
48
            'Invalid namespace separator sequence. Got "App\\\\Foo"',
49
        ];
50
    }
51
}
52