Passed
Push — master ( 1fb483...35eebd )
by Roman
04:31
created

CrosswordReceiverTest::testSuccessfullyReceived()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Tests\Crossword\Features\Receiver;
6
7
use App\Crossword\Features\Receiver\CrosswordReceiver;
8
use App\Crossword\Features\Receiver\ReceiveCrosswordException;
9
use App\Crossword\Features\Receiver\Type\Type;
10
use App\Crossword\Infrastructure\Cache\CacheItem;
11
use App\Crossword\Infrastructure\Cache\InMemoryClient;
12
use App\Crossword\Infrastructure\Repository\Redis\ReadCrosswordRepository;
13
use Psr\Log\NullLogger;
0 ignored issues
show
Bug introduced by
The type Psr\Log\NullLogger was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use App\Tests\Crossword\CrosswordTestCase;
15
16
/**
17
 * @coversDefaultClass \App\Crossword\Features\Receiver\CrosswordReceiver
18
 */
19
final class CrosswordReceiverTest extends CrosswordTestCase
20
{
21
    /**
22
     * @covers ::receive
23
     */
24
    public function testSuccessfullyReceived(): void
25
    {
26
        $data = ['data' => 'value'];
27
        $cache = new InMemoryClient();
28
        $cache->save(new CacheItem('ua-normal-3', [time() => json_encode(['data' => 'value'], JSON_THROW_ON_ERROR)]));
29
30
        $crosswordReceiver = new CrosswordReceiver(new ReadCrosswordRepository($cache), new NullLogger());
31
        $crossword = $crosswordReceiver->receive(sprintf('%s-%s-%d', 'ua', Type::NORMAL, 3));
32
33
        self::assertSame($crossword, $data);
34
    }
35
36
    /**
37
     * @covers ::receive
38
     */
39
    public function testThrowExceptionWhenCrosswordNotFoundInTheStorage(): void
40
    {
41
        $this->expectException(ReceiveCrosswordException::class);
42
43
        $crosswordReceiver = new CrosswordReceiver(new ReadCrosswordRepository(new InMemoryClient()), new NullLogger());
44
        $crosswordReceiver->receive(sprintf('%s-%s-%d', 'ua', Type::NORMAL, 3));
45
    }
46
}
47