WriteExceptionTests::testForKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
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\WriteException;
16
17
/**
18
 * WriteExceptionTests class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22 View Code Duplication
class WriteExceptionTests 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 forException method.
37
     */
38
    public function testForKey()
39
    {
40
        $this
41
            ->given(
42
                $exceptionCode = 10,
43
                $cause = new \Exception('some cause', $exceptionCode)
44
            )
45
            ->when($exception = WriteException::forException($cause))
46
            ->then()
47
                ->object($exception)
48
                    ->isInstanceOf(WriteException::class)
49
                ->integer($exception->getCode())
50
                    ->isEqualTo($exceptionCode)
51
                ->object($exception->getPrevious())
52
                    ->isIdenticalTo($cause)
53
        ;
54
    }
55
}
56