NotAPsrContainerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A nonContainerValuesProvider() 0 9 1
A testExceptionForContainerValues() 0 17 1
1
<?php
2
declare(strict_types=1);
3
4
namespace RoaveTest\BehatPsrContainer\Exception;
5
6
use PHPUnit\Framework\TestCase;
7
use Roave\BehatPsrContainer\Exception\NotAPsrContainer;
8
9
/**
10
 * @covers \Roave\BehatPsrContainer\Exception\NotAPsrContainer
11
 */
12
final class NotAPsrContainerTest extends TestCase
13
{
14
    public function nonContainerValuesProvider() : array
15
    {
16
        return [
17
            ['just a string', 'string'],
18
            [42, 'integer'],
19
            [3.14, 'double'],
20
            [new \stdClass(), \stdClass::class],
21
        ];
22
    }
23
24
    /**
25
     * @param mixed $value
26
     * @param string $expectedType
27
     * @dataProvider nonContainerValuesProvider
28
     */
29
    public function testExceptionForContainerValues($value, string $expectedType) : void
30
    {
31
        $filename = uniqid('filename', true);
32
33
        $exception = NotAPsrContainer::fromAnythingButAPsrContainer($filename, $value);
34
35
        self::assertInstanceOf(NotAPsrContainer::class, $exception);
36
        self::assertInstanceOf(\RuntimeException::class, $exception);
37
        self::assertSame(
38
            sprintf(
39
                'File %s must return a PSR-11 container, actually returned %s',
40
                $filename,
41
                $expectedType
42
            ),
43
            $exception->getMessage()
44
        );
45
    }
46
}
47