|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Tests\Crossword\Features\Constructor; |
|
6
|
|
|
|
|
7
|
|
|
use App\Crossword\Features\Constructor\Dictionary\DictionaryWordDto; |
|
8
|
|
|
use App\Crossword\Features\Constructor\Dictionary\Word; |
|
9
|
|
|
use App\Crossword\Features\Constructor\Dictionary\WordSearchCriteria; |
|
10
|
|
|
use App\Crossword\Features\Constructor\WordFinder; |
|
11
|
|
|
use App\Crossword\Features\Constructor\WordFoundException; |
|
12
|
|
|
use App\Crossword\Infrastructure\Adapter\Dictionary\InMemoryDictionaryAdapter; |
|
13
|
|
|
use Psr\Log\NullLogger; |
|
|
|
|
|
|
14
|
|
|
use App\Tests\Crossword\CrosswordTestCase; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @coversDefaultClass \App\Crossword\Features\Constructor\WordFinder |
|
18
|
|
|
*/ |
|
19
|
|
|
final class WordFinderTest extends CrosswordTestCase |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @covers ::search |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testSuccessfullyFindWord(): void |
|
25
|
|
|
{ |
|
26
|
|
|
$dictionaryWordDto = new DictionaryWordDto([ |
|
27
|
|
|
'success' => true, |
|
28
|
|
|
'data' => [['word' => 'test', 'definition' => 'test test']] |
|
29
|
|
|
]); |
|
30
|
|
|
$inMemoryDictionaryProvider = new InMemoryDictionaryAdapter(null, $dictionaryWordDto); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
$wordFinder = new WordFinder($inMemoryDictionaryProvider, new NullLogger()); |
|
33
|
|
|
$word = $wordFinder->search(new WordSearchCriteria('en', '.*')); |
|
34
|
|
|
|
|
35
|
|
|
self::assertInstanceOf(Word::class, $word); |
|
36
|
|
|
self::assertSame($word->value(), 'test'); |
|
37
|
|
|
self::assertSame($word->definition(), 'test test'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @covers ::search |
|
42
|
|
|
*/ |
|
43
|
|
|
public function testThrowExceptionWhenWordIsNotFound(): void |
|
44
|
|
|
{ |
|
45
|
|
|
$this->expectException(WordFoundException::class); |
|
46
|
|
|
|
|
47
|
|
|
$dictionaryWordDto = new DictionaryWordDto([ |
|
48
|
|
|
'success' => false, |
|
49
|
|
|
]); |
|
50
|
|
|
$inMemoryDictionaryProvider = new InMemoryDictionaryAdapter(null, $dictionaryWordDto); |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
$wordFinder = new WordFinder($inMemoryDictionaryProvider, new NullLogger()); |
|
53
|
|
|
$wordFinder->search(new WordSearchCriteria('en', '.*')); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @covers ::search |
|
58
|
|
|
*/ |
|
59
|
|
|
public function testThrowExceptionWhenApiIsThrowException(): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->expectException(WordFoundException::class); |
|
62
|
|
|
|
|
63
|
|
|
$inMemoryDictionaryProvider = new InMemoryDictionaryAdapter(null, null); |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
$wordFinder = new WordFinder($inMemoryDictionaryProvider, new NullLogger()); |
|
66
|
|
|
$wordFinder->search(new WordSearchCriteria('en', '.*')); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths