Completed
Push — develop ( 183c36...cfc9ab )
by Stéphane
02:42
created

Rules::provide()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
/**
3
 * This file is part of the beebot package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @copyright Bee4 2016
8
 * @author    Stephane HULARD <[email protected]>
9
 */
10
11
namespace Bee4\RobotsTxt\Test\Integration;
12
13
use mageekguy\atoum;
14
use Bee4\RobotsTxt as LUT;
15
16
/**
17
 * Robots.txt integration test
18
 * @tags integration
19
 * @namespace  \Test\Integration
20
 */
21
class Rules extends atoum
22
{
23
    public function provide()
24
    {
25
        $data = [];
26
        $files = glob(__DIR__.'/samples/*-rules.ini');
27
        foreach ($files as $file) {
28
            $rules = parse_ini_file($file, true);
29
            $tmp = [
30
                file_get_contents(__DIR__.'/samples/'.basename($file, '-rules.ini').'.txt'),
31
                $rules
32
            ];
33
            $data[] = $tmp;
34
        }
35
36
        return $data;
37
    }
38
39
    /**
40
     * @dataProvider provide
41
     */
42
    public function testIntegration($content, array $rules)
43
    {
44
        $sut = LUT\Parser::parse($content);
45
46
        foreach ($rules as $rule) {
47
            $this
48
                ->when($matched = $sut->match($rule['ua'], $rule['url']))
49
                ->then
50
                    ->boolean($rule['mode'] === 'allow')
51
                        ->isEqualTo($matched);
52
        }
53
    }
54
}
55