1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace App\Tests\Dictionary\Domain\Model; |
6
|
|
|
|
7
|
|
|
use App\Dictionary\Domain\Exception\SearchMaskIsShortException; |
8
|
|
|
use App\Dictionary\Domain\Model\Mask; |
9
|
|
|
use Generator; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @coversDefaultClass \App\Dictionary\Domain\Model\Mask |
14
|
|
|
*/ |
15
|
|
|
final class MaskTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @covers ::shiftLeft |
19
|
|
|
*/ |
20
|
|
|
public function testShiftLeft(): void |
21
|
|
|
{ |
22
|
|
|
$mask = new Mask('a.*{0,10}'); |
23
|
|
|
|
24
|
|
|
$newMask = $mask->shiftLeft(); |
25
|
|
|
|
26
|
|
|
self::assertInstanceOf(Mask::class, $newMask); |
27
|
|
|
|
28
|
|
|
self::assertSame($newMask->query(), 'a.*'); |
29
|
|
|
self::assertSame($newMask->limit(), '{0,9}'); |
30
|
|
|
|
31
|
|
|
self::assertSame($mask->query(), 'a.*'); |
32
|
|
|
self::assertSame($mask->limit(), '{0,10}'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @covers ::query |
37
|
|
|
* @covers ::limit |
38
|
|
|
*/ |
39
|
|
|
public function testThrowExceptionWhenMaskLimitIsShort(): void |
40
|
|
|
{ |
41
|
|
|
$this->expectException(SearchMaskIsShortException::class); |
42
|
|
|
|
43
|
|
|
new Mask('a.*{3,5}'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @covers ::query |
48
|
|
|
* @covers ::limit |
49
|
|
|
* |
50
|
|
|
* @dataProvider maskDataProvider |
51
|
|
|
*/ |
52
|
|
|
public function testExtractQueryAndLimit(string $template, string $query, string $limit): void |
53
|
|
|
{ |
54
|
|
|
$mask = new Mask($template); |
55
|
|
|
|
56
|
|
|
self::assertSame($mask->query(), $query); |
57
|
|
|
self::assertSame($mask->limit(), $limit); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function maskDataProvider(): Generator |
61
|
|
|
{ |
62
|
|
|
yield 'all symbols' => ['.*', '.*', '{0,100}']; |
63
|
|
|
yield 'with first letter' => ['a.*', 'a.*', '{0,100}']; |
64
|
|
|
yield 'with random letter' => ['t.a.', 't.a.', '{0,100}']; |
65
|
|
|
yield 'all symbols with limit' => ['.*{0,10}', '.*', '{0,10}']; |
66
|
|
|
yield 'with first letter with limit' => ['a.*{4,5}', 'a.*', '{4,5}']; |
67
|
|
|
yield 'with random letter with limit' => ['t.a.{10,20}', 't.a.', '{10,20}']; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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