Code Duplication    Length = 39-41 lines in 3 locations

tests/getRulesTest.php 1 location

@@ 6-46 (lines=41) @@
3
4
use vipnytt\XRobotsTagParser;
5
6
class GetRulesTest extends \PHPUnit_Framework_TestCase
7
{
8
    /**
9
     * Get rules
10
     *
11
     * @dataProvider generateDataForTest
12
     * @param string $url
13
     * @param string $bot
14
     * @param array $options
15
     */
16
    public function testGetRules($url, $bot, $options)
17
    {
18
        $parser = new XRobotsTagParser($url, $bot, $options);
19
        $this->assertInstanceOf('vipnytt\XRobotsTagParser', $parser);
20
21
        $this->assertTrue($parser->getRules(true)['noindex']);
22
        $this->assertTrue($parser->getRules(true)['noarchive']);
23
        $this->assertTrue($parser->getRules(true)['noodp']);
24
    }
25
26
    /**
27
     * Generate test data
28
     * @return array
29
     */
30
    public function generateDataForTest()
31
    {
32
        return [
33
            [
34
                'http://example.com/',
35
                'googlebot',
36
                ['headers' =>
37
                    [
38
                        'X-Robots-Tag: googlebot: noindex, noarchive',
39
                        'X-Robots-Tag: bingbot: noindex, noodp',
40
                        'X-Robots-Tag: noindex, noodp'
41
                    ]
42
                ]
43
            ]
44
        ];
45
    }
46
}
47

tests/NoindexTest.php 1 location

@@ 6-44 (lines=39) @@
3
4
use vipnytt\XRobotsTagParser;
5
6
class NoindexTest extends \PHPUnit_Framework_TestCase
7
{
8
    /**
9
     * noindex test
10
     *
11
     * @dataProvider generateDataForTest
12
     * @param string $url
13
     * @param string $bot
14
     * @param array $options
15
     */
16
    public function testNoIndex($url, $bot, $options)
17
    {
18
        $parser = new XRobotsTagParser($url, $bot, $options);
19
        $this->assertInstanceOf('vipnytt\XRobotsTagParser', $parser);
20
21
        $this->assertTrue($parser->getRules(true)['noindex']);
22
        $this->assertTrue($parser->getRules(false)['noindex']);
23
        $this->assertTrue($parser->getRules(false)['noarchive']);
24
    }
25
26
    /**
27
     * Generate test data
28
     * @return array
29
     */
30
    public function generateDataForTest()
31
    {
32
        return [
33
            [
34
                'http://example.com/',
35
                'googlebot',
36
                ['headers' =>
37
                    [
38
                        'X-Robots-Tag: noindex'
39
                    ]
40
                ]
41
            ]
42
        ];
43
    }
44
}
45

tests/NoneTest.php 1 location

@@ 6-44 (lines=39) @@
3
4
use vipnytt\XRobotsTagParser;
5
6
class NoneTest extends \PHPUnit_Framework_TestCase
7
{
8
    /**
9
     * none test
10
     *
11
     * @dataProvider generateDataForTest
12
     * @param string $url
13
     * @param string $bot
14
     * @param array $options
15
     */
16
    public function testNone($url, $bot, $options)
17
    {
18
        $parser = new XRobotsTagParser($url, $bot, $options);
19
        $this->assertInstanceOf('vipnytt\XRobotsTagParser', $parser);
20
21
        $this->assertTrue($parser->getRules(true)['none']);
22
        $this->assertTrue($parser->getRules(false)['noindex']);
23
        $this->assertTrue($parser->getRules(false)['nofollow']);
24
    }
25
26
    /**
27
     * Generate test data
28
     * @return array
29
     */
30
    public function generateDataForTest()
31
    {
32
        return [
33
            [
34
                'http://example.com/',
35
                'googlebot',
36
                ['headers' =>
37
                    [
38
                        'X-Robots-Tag: none'
39
                    ]
40
                ]
41
            ]
42
        ];
43
    }
44
}
45