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

testThrowExceptionWhenLanguagesIsNotReceived()   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\Languages;
6
7
use App\Crossword\Features\Languages\Dictionary\DictionaryLanguagesDto;
8
use App\Crossword\Features\Languages\NotFoundSupportedLanguagesException;
9
use App\Crossword\Features\Languages\SupportedLanguages;
10
use App\Crossword\Features\Receiver\Response\SuccessApiResponse;
11
use App\Crossword\Infrastructure\Adapter\Dictionary\InMemoryDictionaryAdapter;
12
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...
13
use App\Tests\Crossword\CrosswordTestCase;
14
15
/**
16
 * @coversDefaultClass \App\Crossword\Features\Languages\SupportedLanguages
17
 */
18
final class SupportedLanguagesTest extends CrosswordTestCase
19
{
20
    /**
21
     * @covers ::receive
22
     */
23
    public function testSuccessfullyReceivedLanguages(): void
24
    {
25
        $response = new SuccessApiResponse(['en', 'ua']);
26
        $dictionaryLanguagesDto = new DictionaryLanguagesDto($response->body());
27
        $inMemoryDictionaryProvider = new InMemoryDictionaryAdapter($dictionaryLanguagesDto, null);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type App\Crossword\Features\C...Adapter\Dictionary\null expected by parameter $wordDto of App\Crossword\Infrastruc...yAdapter::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        $inMemoryDictionaryProvider = new InMemoryDictionaryAdapter($dictionaryLanguagesDto, /** @scrutinizer ignore-type */ null);
Loading history...
28
29
        $supportedLanguages = new SupportedLanguages($inMemoryDictionaryProvider, new NullLogger());
30
31
        self::assertCount(2, $supportedLanguages->receive());
32
    }
33
34
    /**
35
     * @covers ::receive
36
     */
37
    public function testThrowExceptionWhenLanguagesIsNotReceived(): void
38
    {
39
        $this->expectException(NotFoundSupportedLanguagesException::class);
40
41
        $response = new SuccessApiResponse([]);
42
        $dictionaryLanguagesDto = new DictionaryLanguagesDto($response->body());
43
        $inMemoryDictionaryProvider = new InMemoryDictionaryAdapter($dictionaryLanguagesDto, null);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type App\Crossword\Features\C...Adapter\Dictionary\null expected by parameter $wordDto of App\Crossword\Infrastruc...yAdapter::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
        $inMemoryDictionaryProvider = new InMemoryDictionaryAdapter($dictionaryLanguagesDto, /** @scrutinizer ignore-type */ null);
Loading history...
44
45
        $supportedLanguages = new SupportedLanguages($inMemoryDictionaryProvider, new NullLogger());
46
        $supportedLanguages->receive();
47
    }
48
}
49