testForUnknownValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cubiche\Core\Bus\Tests\Units\Exception;
12
13
use Cubiche\Core\Bus\Exception\InvalidMiddlewareException;
14
use Cubiche\Core\Bus\Tests\Units\TestCase;
15
16
/**
17
 * InvalidMiddlewareExceptionTests class.
18
 *
19
 * @author Ivannis Suárez Jerez <[email protected]>
20
 */
21
class InvalidMiddlewareExceptionTests extends TestCase
22
{
23
    /**
24
     * Test class.
25
     */
26
    public function testClass()
27
    {
28
        $this
29
            ->testedClass
30
                ->extends(\InvalidArgumentException::class)
31
        ;
32
    }
33
34
    /**
35
     * Test forUnknownValue method.
36
     */
37
    public function testForUnknownValue()
38
    {
39
        $this
40
            ->given($cause = new \Exception('some cause'))
41
            ->when($exception = InvalidMiddlewareException::forUnknownValue('foo', $cause))
42
            ->then
43
                ->object($exception)
44
                    ->isInstanceOf(InvalidMiddlewareException::class)
45
                ->integer($exception->getCode())
46
                    ->isEqualTo(0)
47
                ->object($exception->getPrevious())
48
                    ->isIdenticalTo($cause)
49
        ;
50
51
        $this
52
            ->given($exception = InvalidMiddlewareException::forUnknownValue('bar'))
53
            ->then
54
                ->variable($exception->getPrevious())
55
                    ->isNull()
56
        ;
57
    }
58
}
59