1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TraitsTests; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use CommonTestClass; |
7
|
|
|
use kalanis\kw_files\Traits\TSubPart; |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
class SubPartTest extends CommonTestClass |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @param string[] $what |
14
|
|
|
* @param string[] $in |
15
|
|
|
* @param bool $result |
16
|
|
|
* @dataProvider subPartProvider |
17
|
|
|
*/ |
18
|
|
|
public function testProcess(array $what, array $in, bool $result): void |
19
|
|
|
{ |
20
|
|
|
$lib = new XSubPart(); |
21
|
|
|
$this->assertEquals($result, $lib->is($what, $in)); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function subPartProvider(): array |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
[[], [], true], |
28
|
|
|
[['foo'], [], true], |
29
|
|
|
[['foo'], ['foo'], true], |
30
|
|
|
[['foo', 'bar'], ['foo'], true], |
31
|
|
|
[['foo'], ['foo', 'bar'], true], |
32
|
|
|
[['baz'], ['bar'], false], |
33
|
|
|
[['baz', 'foo'], ['bar', 'foo'], false], |
34
|
|
|
[['foo', 'bar'], ['foo', 'baz'], false], |
35
|
|
|
[['foo', 'bar', 'baz'], ['foo', 'baz'], false], |
36
|
|
|
]; |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
class XSubPart |
42
|
|
|
{ |
43
|
|
|
use TSubPart; |
44
|
|
|
|
45
|
|
|
public function is(array $what, array $in): bool |
46
|
|
|
{ |
47
|
|
|
return $this->isSubPart($what, $in); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|