InvalidKeyExceptionTests   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testClass() 0 7 1
A testForKey() 0 20 1
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
namespace Cubiche\Core\Collections\Tests\Units\Exception;
11
12
use Cubiche\Core\Collections\Exception\InvalidKeyException;
13
use Cubiche\Tests\TestCase;
14
15
/**
16
 * InvalidKeyExceptionTests class.
17
 *
18
 * @author Ivannis Suárez Jerez <[email protected]>
19
 */
20
class InvalidKeyExceptionTests extends TestCase
21
{
22
    /**
23
     * Test class.
24
     */
25
    public function testClass()
26
    {
27
        $this
28
            ->testedClass
29
                ->extends(\InvalidArgumentException::class)
30
        ;
31
    }
32
33
    /*
34
     * Test forKey method.
35
     */
36
    public function testForKey()
37
    {
38
        $this
39
            ->given($cause = new \Exception('some cause'))
40
            ->when($exception = InvalidKeyException::forKey('foo', '', $cause))
41
            ->then
42
                ->object($exception)
43
                    ->isInstanceOf(InvalidKeyException::class)
44
                ->integer($exception->getCode())
45
                    ->isEqualTo(0)
46
                ->object($exception->getPrevious())
47
                    ->isIdenticalTo($cause)
48
        ;
49
50
        $this
51
            ->given($exception = InvalidKeyException::forKey('bar'))
52
            ->then
53
                ->variable($exception->getPrevious())->isNull()
54
        ;
55
    }
56
}
57