KeyNotFoundExceptionTests::testForKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
dl 21
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Storage\Tests\Units\Exception;
13
14
use Cubiche\Core\Storage\Tests\Units\TestCase;
15
use Cubiche\Core\Storage\Exception\KeyNotFoundException;
16
17
/**
18
 * KeyNotFoundExceptionTests class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22 View Code Duplication
class KeyNotFoundExceptionTests extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
{
24
    /**
25
     * Test class.
26
     */
27
    public function testClass()
28
    {
29
        $this
30
            ->testedClass
31
                ->extends(\RuntimeException::class)
32
        ;
33
    }
34
35
    /*
36
     * Test forKey method.
37
     */
38
    public function testForKey()
39
    {
40
        $this
41
            ->given($cause = new \Exception('some cause'))
42
            ->when($exception = KeyNotFoundException::forKey('foo', $cause))
43
            ->then()
44
                ->object($exception)
45
                    ->isInstanceOf(KeyNotFoundException::class)
46
                ->integer($exception->getCode())
47
                    ->isEqualTo(0)
48
                ->object($exception->getPrevious())
49
                    ->isIdenticalTo($cause)
50
        ;
51
52
        $this
53
            ->given($exception = KeyNotFoundException::forKey('bar'))
54
            ->then()
55
                ->variable($exception->getPrevious())
56
                    ->isNull()
57
        ;
58
    }
59
}
60