Completed
Push — master ( cace1c...4cd08d )
by Jan-Petter
02:34
created

NoindexTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 39
loc 39
rs 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace vipnytt\XRobotsTagParser\Tests;
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