Skip to content

Commit

Permalink
Test against PHP 8 (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBizzle committed Dec 9, 2020
1 parent 60170b6 commit 6034e2b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4]
php: [5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0]

name: PHP:${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -16,7 +16,7 @@
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.5|^6.5"
"phpunit/phpunit": "^4.8|^5.5|^6.5|^9.4"
},
"autoload": {
"psr-4": {
Expand Down
22 changes: 11 additions & 11 deletions tests/UserAgentTest.php
Expand Up @@ -15,16 +15,10 @@

final class UserAgentTest extends TestCase
{
private $CrawlerDetect;

protected function setUp()
{
$this->CrawlerDetect = new CrawlerDetect();
}

/** @test */
public function user_agents_are_bots()
{
$this->CrawlerDetect = new CrawlerDetect();
$lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

foreach ($lines as $line) {
Expand All @@ -36,6 +30,7 @@ public function user_agents_are_bots()
/** @test */
public function user_agents_are_devices()
{
$this->CrawlerDetect = new CrawlerDetect();
$lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

foreach ($lines as $line) {
Expand All @@ -47,7 +42,8 @@ public function user_agents_are_devices()
/** @test */
public function it_returns_correct_matched_bot_name()
{
$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)');
$this->CrawlerDetect = new CrawlerDetect();
$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)');

$matches = $this->CrawlerDetect->getMatches();

Expand All @@ -57,7 +53,8 @@ public function it_returns_correct_matched_bot_name()
/** @test */
public function it_returns_full_matched_bot_name()
{
$test = $this->CrawlerDetect->isCrawler('somenaughtybot');
$this->CrawlerDetect = new CrawlerDetect();
$this->CrawlerDetect->isCrawler('somenaughtybot');

$matches = $this->CrawlerDetect->getMatches();

Expand All @@ -67,16 +64,18 @@ public function it_returns_full_matched_bot_name()
/** @test */
public function it_returns_null_when_no_bot_detected()
{
$test = $this->CrawlerDetect->isCrawler('nothing to see here');
$this->CrawlerDetect = new CrawlerDetect();
$this->CrawlerDetect->isCrawler('nothing to see here');

$matches = $this->CrawlerDetect->getMatches();

$this->assertEquals($this->CrawlerDetect->getMatches(), null, $matches);
$this->assertNull($this->CrawlerDetect->getMatches());
}

/** @test */
public function empty_user_agent()
{
$this->CrawlerDetect = new CrawlerDetect();
$test = $this->CrawlerDetect->isCrawler(' ');

$this->assertFalse($test);
Expand Down Expand Up @@ -113,6 +112,7 @@ public function http_from_header()
/** @test */
public function matches_does_not_persit_across_multiple_calls()
{
$this->CrawlerDetect = new CrawlerDetect();
$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)');
$matches = $this->CrawlerDetect->getMatches();
$this->assertEquals($this->CrawlerDetect->getMatches(), 'monitoring', $matches);
Expand Down

0 comments on commit 6034e2b

Please sign in to comment.