Passed
Pull Request — master (#489)
by Théo
02:17
created

ConfigurationTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_it_validates_the_prefix() 0 19 1
A prefixProvider() 0 10 1
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