Completed
Push — master ( 6c409f...23b86d )
by James
11s
created

testFromKeyAndInvalidTTLObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace RoaveTest\DoctrineSimpleCache\Exception;
5
6
use Roave\DoctrineSimpleCache\Exception\InvalidArgumentException;
7
8
/**
9
 * @covers \Roave\DoctrineSimpleCache\Exception\InvalidArgumentException
10
 */
11
final class InvalidArgumentExceptionTest extends \PHPUnit_Framework_TestCase
12
{
13 View Code Duplication
    public function testFromKeyAndInvalidTTLObject()
0 ignored issues
show
Duplication introduced by
This method 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...
14
    {
15
        $invalidTTL = new \stdClass();
16
        $exception = InvalidArgumentException::fromKeyAndInvalidTTL('key', $invalidTTL);
17
        self::assertInstanceOf(InvalidArgumentException::class, $exception);
18
        self::assertInstanceOf(\Psr\SimpleCache\InvalidArgumentException::class, $exception);
19
20
        self::assertStringMatchesFormat(
21
            'TTL for "%s" should be defined by an integer or a DateInterval, but stdClass is given.',
22
            $exception->getMessage()
23
        );
24
    }
25
26 View Code Duplication
    public function testFromKeyAndInvalidTTLNonObject()
0 ignored issues
show
Duplication introduced by
This method 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...
27
    {
28
        $invalidTTL = random_int(100, 200);
29
        $exception = InvalidArgumentException::fromKeyAndInvalidTTL('key', $invalidTTL);
30
        self::assertInstanceOf(InvalidArgumentException::class, $exception);
31
        self::assertInstanceOf(\Psr\SimpleCache\InvalidArgumentException::class, $exception);
32
33
        self::assertStringMatchesFormat(
34
            'TTL for "%s" should be defined by an integer or a DateInterval, but integer is given.',
35
            $exception->getMessage()
36
        );
37
    }
38
}
39