Completed
Push — master ( 12b419...48a936 )
by Alejandro
25s queued 18s
created

exceptionIsCreatedAsExpected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Common\Http\Exception;
6
7
use PHPUnit\Framework\TestCase;
8
use Shlinkio\Shlink\Common\Http\Exception\InvalidHttpMiddlewareException;
9
use stdClass;
10
11
class InvalidHttpMiddlewareExceptionTest extends TestCase
12
{
13
    /**
14
     * @param mixed $middleware
15
     * @test
16
     * @dataProvider provideMessages
17
     */
18
    public function exceptionIsCreatedAsExpected($middleware, string $expectedMessage): void
19
    {
20
        $e = InvalidHttpMiddlewareException::fromMiddleware($middleware);
21
        $this->assertEquals($expectedMessage, $e->getMessage());
22
    }
23
24
    public function provideMessages(): iterable
25
    {
26
        yield [new stdClass(), 'Provided middleware does not have a valid type. Expected callable, stdClass provided'];
27
        yield ['foobar', 'Provided middleware does not have a valid type. Expected callable, string provided'];
28
        yield [23, 'Provided middleware does not have a valid type. Expected callable, integer provided'];
29
    }
30
}
31