Code Duplication    Length = 38-38 lines in 2 locations

Tests/Units/Exception/InvalidKeyExceptionTests.php 1 location

@@ 22-59 (lines=38) @@
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class InvalidKeyExceptionTests extends TestCase
23
{
24
    /**
25
     * Test class.
26
     */
27
    public function testClass()
28
    {
29
        $this
30
            ->testedClass
31
                ->extends(\InvalidArgumentException::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 = InvalidKeyException::forKey('foo', $cause))
43
            ->then()
44
                ->object($exception)
45
                    ->isInstanceOf(InvalidKeyException::class)
46
                ->integer($exception->getCode())
47
                    ->isEqualTo(0)
48
                ->object($exception->getPrevious())
49
                    ->isIdenticalTo($cause)
50
        ;
51
52
        $this
53
            ->given($exception = InvalidKeyException::forKey('bar'))
54
            ->then()
55
                ->variable($exception->getPrevious())
56
                    ->isNull()
57
        ;
58
    }
59
}
60

Tests/Units/Exception/KeyNotFoundExceptionTests.php 1 location

@@ 22-59 (lines=38) @@
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class KeyNotFoundExceptionTests extends TestCase
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