Completed
Push — master ( 64491b...1f7f5f )
by Jan-Petter
30:57
created

MultiTest::testMultipleDirectives()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 41
rs 8.8571
cc 1
eloc 30
nc 1
nop 3
1
<?php
2
3
namespace vipnytt\XRobotsTagParser\Tests;
4
5
use vipnytt\XRobotsTagParser;
6
7
class MultiTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * Multi directives test
11
     *
12
     * @dataProvider generateDataForTest
13
     * @param string $url
14
     * @param string $bot
15
     * @param array $options
16
     */
17
    public function testMultipleDirectives($url, $bot, $options)
18
    {
19
        $parser = new XRobotsTagParser($url, $bot, $options);
20
        $this->assertInstanceOf('vipnytt\XRobotsTagParser', $parser);
21
22
        $this->assertTrue($parser->getRules(true)['all']);
23
        $this->assertTrue($parser->export()['']['all']);
24
        $this->assertTrue($parser->export()['googlebot']['all']);
25
26
        $this->assertTrue($parser->getRules(true)['noindex']);
27
        $this->assertTrue($parser->export()['']['noindex']);
28
        $this->assertTrue($parser->export()['googlebot']['noindex']);
29
30
        $this->assertTrue($parser->getRules(true)['nofollow']);
31
        $this->assertTrue($parser->export()['']['nofollow']);
32
        $this->assertTrue($parser->export()['googlebot']['nofollow']);
33
34
        $this->assertTrue($parser->getRules(true)['none']);
35
        $this->assertTrue($parser->export()['']['none']);
36
        $this->assertTrue($parser->export()['googlebot']['none']);
37
38
        $this->assertTrue($parser->getRules(true)['noarchive']);
39
        $this->assertTrue($parser->export()['']['noarchive']);
40
        $this->assertTrue($parser->export()['googlebot']['noarchive']);
41
42
        $this->assertTrue($parser->getRules(true)['nosnippet']);
43
        $this->assertTrue($parser->export()['']['nosnippet']);
44
        $this->assertTrue($parser->export()['googlebot']['nosnippet']);
45
46
        $this->assertTrue($parser->getRules(true)['noodp']);
47
        $this->assertTrue($parser->export()['']['noodp']);
48
        $this->assertTrue($parser->export()['googlebot']['noodp']);
49
50
        $this->assertTrue($parser->getRules(true)['notranslate']);
51
        $this->assertTrue($parser->export()['']['notranslate']);
52
        $this->assertTrue($parser->export()['googlebot']['notranslate']);
53
54
        $this->assertTrue($parser->getRules(true)['noimageindex']);
55
        $this->assertTrue($parser->export()['']['noimageindex']);
56
        $this->assertTrue($parser->export()['googlebot']['noimageindex']);
57
    }
58
59
    /**
60
     * Generate test data
61
     * @return array
62
     */
63
    public function generateDataForTest()
64
    {
65
        return [
66
            [
67
                'http://example.com/',
68
                'googlebot',
69
                ['headers' =>
70
                    [
71
                        'HTTP/1.1 200 OK',
72
                        'Date: Tue, 25 May 2010 21:42:43 GMT',
73
                        'X-Robots-Tag: all',
74
                        'X-Robots-Tag: noindex',
75
                        'X-Robots-Tag: nofollow',
76
                        'X-Robots-Tag: none',
77
                        'X-Robots-Tag: noarchive',
78
                        'X-Robots-Tag: nosnippet',
79
                        'X-Robots-Tag: noodp',
80
                        'X-Robots-Tag: notranslate',
81
                        'X-Robots-Tag: noimageindex',
82
                        'X-Robots-Tag: unavailable_after: Friday, 25 Jun 2010 15:00:00 PST',
83
                        'X-Robots-Tag: googlebot: all, none, nofollow,nosnippet,notranslate, unavailable_after: Friday, 25 Jun 2010 15:00:00 PST, noindex, noarchive, noodp,noimageindex'
84
                    ]
85
                ]
86
            ]
87
        ];
88
    }
89
}
90