@@ -11,55 +11,55 @@ |
||
| 11 | 11 | |
| 12 | 12 | class UserAgentTest extends PHPUnit_Framework_TestCase |
| 13 | 13 | { |
| 14 | - protected $CrawlerDetect; |
|
| 14 | + protected $CrawlerDetect; |
|
| 15 | 15 | |
| 16 | - public function setUp() |
|
| 17 | - { |
|
| 18 | - $this->CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect(); |
|
| 19 | - } |
|
| 16 | + public function setUp() |
|
| 17 | + { |
|
| 18 | + $this->CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function testBots() |
|
| 22 | - { |
|
| 23 | - $lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 21 | + public function testBots() |
|
| 22 | + { |
|
| 23 | + $lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 24 | 24 | |
| 25 | - foreach ($lines as $line) { |
|
| 26 | - $test = $this->CrawlerDetect->isCrawler($line); |
|
| 27 | - $this->assertEquals($test, true, $line); |
|
| 28 | - } |
|
| 29 | - } |
|
| 25 | + foreach ($lines as $line) { |
|
| 26 | + $test = $this->CrawlerDetect->isCrawler($line); |
|
| 27 | + $this->assertEquals($test, true, $line); |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function testDevices() |
|
| 32 | - { |
|
| 33 | - $lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 31 | + public function testDevices() |
|
| 32 | + { |
|
| 33 | + $lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 34 | 34 | |
| 35 | - foreach ($lines as $line) { |
|
| 36 | - $test = $this->CrawlerDetect->isCrawler($line); |
|
| 37 | - $this->assertEquals($test, false, $line); |
|
| 38 | - } |
|
| 39 | - } |
|
| 35 | + foreach ($lines as $line) { |
|
| 36 | + $test = $this->CrawlerDetect->isCrawler($line); |
|
| 37 | + $this->assertEquals($test, false, $line); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function testReturnsCorrectMatchedBotName() |
|
| 42 | - { |
|
| 43 | - $test = $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)'); |
|
| 41 | + public function testReturnsCorrectMatchedBotName() |
|
| 42 | + { |
|
| 43 | + $test = $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)'); |
|
| 44 | 44 | |
| 45 | - $matches = $this->CrawlerDetect->getMatches(); |
|
| 45 | + $matches = $this->CrawlerDetect->getMatches(); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals($this->CrawlerDetect->getMatches(), 'Yahoo Ad monitoring', $matches); |
|
| 48 | - } |
|
| 47 | + $this->assertEquals($this->CrawlerDetect->getMatches(), 'Yahoo Ad monitoring', $matches); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function testForRegexCollision() |
|
| 51 | - { |
|
| 52 | - $crawlers = $this->CrawlerDetect->getCrawlers(); |
|
| 50 | + public function testForRegexCollision() |
|
| 51 | + { |
|
| 52 | + $crawlers = $this->CrawlerDetect->getCrawlers(); |
|
| 53 | 53 | |
| 54 | - foreach ($crawlers as $regex) { |
|
| 55 | - foreach ($crawlers as $compare) { |
|
| 56 | - // Dont check this regex against itself |
|
| 57 | - if ($regex != $compare) { |
|
| 58 | - preg_match('/'.$regex.'/i', stripslashes($compare), $matches); |
|
| 54 | + foreach ($crawlers as $regex) { |
|
| 55 | + foreach ($crawlers as $compare) { |
|
| 56 | + // Dont check this regex against itself |
|
| 57 | + if ($regex != $compare) { |
|
| 58 | + preg_match('/'.$regex.'/i', stripslashes($compare), $matches); |
|
| 59 | 59 | |
| 60 | - $this->assertEmpty($matches, $regex.' collided with '.$compare); |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 60 | + $this->assertEmpty($matches, $regex.' collided with '.$compare); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | } |