Passed
Pull Request — master (#38)
by Alejandro
04:23
created

InvalidHttpMiddlewareExceptionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A provideMessages() 0 5 1
A exceptionIsCreatedAsExpected() 0 4 1
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