Completed
Pull Request — master (#189)
by Mark
20:14
created

UserAgentTest::current_visitor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 8
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Crawler Detect - the web crawler detection library.
5
 *
6
 * (c) Mark Beech <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
use Jaybizzle\CrawlerDetect\CrawlerDetect;
13
use Jaybizzle\CrawlerDetect\Fixtures\Crawlers;
14
15
class UserAgentTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
16
{
17
    protected $CrawlerDetect;
18
19
    public function setUp()
20
    {
21
        $this->CrawlerDetect = new CrawlerDetect();
22
    }
23
24
    /** @test */
25
    public function user_agents_are_bots()
26
    {
27
        $lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
28
29
        foreach ($lines as $line) {
30
            $test = $this->CrawlerDetect->agent($line)->isCrawler();
31
            $this->assertEquals($test, true, $line);
32
        }
33
    }
34
35
    /** @test */
36
    public function user_ips_are_bots()
37
    {
38
        $test = $this->CrawlerDetect->ip('80.140.2.2')->isCrawler();
39
        $this->assertEquals($test, true);
40
    }
41
}
42