CacheExceptionTest::testFromNonClearableCache()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace RoaveTest\DoctrineSimpleCache\Exception;
5
6
use Doctrine\Common\Cache\Cache as DoctrineCache;
7
use PHPUnit\Framework\TestCase;
8
use Psr\SimpleCache\CacheException as PsrCacheException;
9
use Roave\DoctrineSimpleCache\Exception\CacheException;
10
11
/**
12
 * @covers \Roave\DoctrineSimpleCache\Exception\CacheException
13
 */
14
final class CacheExceptionTest extends TestCase
15
{
16 View Code Duplication
    public function testFromNonClearableCache()
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...
17
    {
18
        /** @var DoctrineCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */
19
        $doctrineCache = $this->createMock(DoctrineCache::class);
20
21
        $exception = CacheException::fromNonClearableCache($doctrineCache);
22
23
        self::assertInstanceOf(CacheException::class, $exception);
24
        self::assertInstanceOf(PsrCacheException::class, $exception);
25
26
        self::assertStringMatchesFormat(
27
            'The given cache %s was not clearable, but you tried to use a feature that requires a clearable cache.',
28
            $exception->getMessage()
29
        );
30
    }
31
32 View Code Duplication
    public function testFromNonMultiOperationCache()
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...
33
    {
34
        /** @var DoctrineCache|\PHPUnit_Framework_MockObject_MockObject $doctrineCache */
35
        $doctrineCache = $this->createMock(DoctrineCache::class);
36
37
        $exception = CacheException::fromNonMultiOperationCache($doctrineCache);
38
39
        self::assertInstanceOf(CacheException::class, $exception);
40
        self::assertInstanceOf(PsrCacheException::class, $exception);
41
42
        self::assertStringMatchesFormat(
43
            'The given cache %s does not support multiple operations, '
44
            . 'but you tried to use a feature that requires a multi-operation cache.',
45
            $exception->getMessage()
46
        );
47
    }
48
}
49