Completed
Push — master ( 7c00aa...d8aae5 )
by Ivannis Suárez
19:41
created

NotFoundExceptionTests::testNameOfMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
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\NotFoundException;
14
use Cubiche\Core\Bus\Tests\Units\TestCase;
15
16
/**
17
 * NotFoundExceptionTests class.
18
 *
19
 * @author Ivannis Suárez Jerez <[email protected]>
20
 */
21
class NotFoundExceptionTests extends TestCase
22
{
23
    /**
24
     * Test class.
25
     */
26
    public function testClass()
27
    {
28
        $this
29
            ->testedClass
30
                ->extends(\RuntimeException::class)
31
        ;
32
    }
33
34
    /**
35
     * Test nameOfMessage method.
36
     */
37
    public function testNameOfMessage()
38
    {
39
        $this
40
            ->given($cause = new \Exception('some cause'))
41
            ->when($exception = NotFoundException::nameOfMessage('foo', $cause))
42
            ->then()
43
                ->object($exception)
44
                    ->isInstanceOf(NotFoundException::class)
45
                ->integer($exception->getCode())
46
                    ->isEqualTo(0)
47
                ->object($exception->getPrevious())
48
                    ->isIdenticalTo($cause)
49
        ;
50
    }
51
52
    /**
53
     * Test handlerMethodNameForObject method.
54
     */
55
    public function testMethodNameForObject()
56
    {
57
        $this
58
            ->given($exception = NotFoundException::handlerMethodNameForObject('bar'))
59
            ->then()
60
                ->variable($exception->getPrevious())
61
                    ->isNull()
62
        ;
63
    }
64
65
    /**
66
     * Test handlerFor method.
67
     */
68
    public function testHandlerFor()
69
    {
70
        $this
71
            ->given($exception = NotFoundException::handlerFor('bar'))
72
            ->then()
73
                ->variable($exception->getPrevious())
74
                    ->isNull()
75
        ;
76
    }
77
78
    /**
79
     * Test middlewareOfType method.
80
     */
81
    public function testMiddlewareOfType()
82
    {
83
        $this
84
            ->given($exception = NotFoundException::middlewareOfType('bar'))
85
            ->then()
86
                ->variable($exception->getPrevious())
87
                    ->isNull()
88
        ;
89
    }
90
91
    /**
92
     * Test nameOfCommand method.
93
     */
94
    public function testNameOfCommand()
95
    {
96
        $this
97
            ->given($exception = NotFoundException::nameOfCommand('bar'))
98
            ->then()
99
                ->variable($exception->getPrevious())
100
                    ->isNull()
101
        ;
102
    }
103
104
    /**
105
     * Test nameOfQuery method.
106
     */
107
    public function testNameOfQuery()
108
    {
109
        $this
110
            ->given($exception = NotFoundException::nameOfQuery('bar'))
111
            ->then()
112
                ->variable($exception->getPrevious())
113
                    ->isNull()
114
        ;
115
    }
116
117
    /**
118
     * Test methodForObject method.
119
     */
120
    public function testMethodForObject()
121
    {
122
        $this
123
            ->given($exception = NotFoundException::methodForObject('foo', 'bar'))
124
            ->then()
125
                ->variable($exception->getPrevious())
126
                    ->isNull()
127
        ;
128
    }
129
}
130