InvalidKeyExceptionTests::testClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
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
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