Passed
Push — master ( 79545d...728467 )
by Petr
02:28
created

SubPartTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A subPartProvider() 0 12 1
A testProcess() 0 4 1
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