Passed
Push — master ( 03ea78...8fc551 )
by Harry
10:08
created

TableFilterableTest::filterData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 27
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\Sprout\Test\Unit\Parser;
4
5
use Graze\Sprout\Parser\TableFilterer;
6
use Graze\Sprout\Test\TestCase;
7
8
class TableFilterableTest extends TestCase
9
{
10
    /**
11
     * @dataProvider filterData
12
     *
13
     * @param string[] $tables
14
     * @param string[] $excludes
15
     * @param string[] $expected
16
     */
17
    public function testFilter(array $tables, array $excludes, array $expected)
18
    {
19
        $tableFilterer = new TableFilterer();
20
21
        $output = $tableFilterer->filter($tables, $excludes);
22
23
        $this->assertEquals($expected, $output);
24
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function filterData()
30
    {
31
        return [
32
            [ // test standard string matching
33
              ['table1', 'table2', 'table3'],
34
              ['table1'],
35
              ['table2', 'table3'],
36
            ],
37
            [ // test simple regex
38
              ['table1', 'table2', 'table3'],
39
              ['table[23]'],
40
              ['table1'],
41
            ],
42
            [ // test multiple excludes
43
              ['table1', 'table2', 'table3'],
44
              ['table2', 'table3'],
45
              ['table1'],
46
            ],
47
            [ // test multiple regex
48
              ['table1', 'table2', 'table11', 'table12'],
49
              ['table\d', 'table[1]{2}'],
50
              ['table12'],
51
            ],
52
            [ // test complex regex
53
              ['table1', 'Table2', 'table11', 'table1s'],
54
              ['/^table\d{1}(?!\d)/i'],
55
              ['table11'],
56
            ],
57
        ];
58
    }
59
}
60