Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

matrix:
allow_failures:
- php: nightly

cache:
directories:
- $HOME/.composer/cache
- vendor

install:
- composer install
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
}
],
"require": {
"php": ">=5.3.0"
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5"
},
"autoload": {
"psr-0": {
"Sail": "src/"
"psr-4": {
"Sail\\": "src/Sail/"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Useragent Test Suite">
<directory>tests/Useragent/</directory>
<directory>tests/UserAgent/</directory>
</testsuite>
</testsuites>

Expand Down
36 changes: 21 additions & 15 deletions tests/UserAgent/UserAgentTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

use Sail\UserAgent;
use Sail\Parser\Simple;
namespace Sail;

class Sail_UserAgentTest extends PHPUnit_Framework_TestCase {
use Sail\Useragent;
use Sail\Parser\Simple;
use PHPUnit\Framework\TestCase;

class UserAgentTest extends TestCase
{
// ua obj
protected $ua;

Expand All @@ -22,15 +25,17 @@ class Sail_UserAgentTest extends PHPUnit_Framework_TestCase {
'browser' => 'Safari 3.2',
'version' => '3.2',
),

);

public function setup(){
protected function setup()
{
$this->ua = new UserAgent();
$this->ua->pushParser(new Simple());
}

public function testGetUA(){

public function testGetUA()
{
$ua = $this->useragent['Chrome'];
$this->ua->setUA($ua['string']);
$this->assertTrue($this->ua->getUA() == $ua['string']);
Expand All @@ -40,7 +45,8 @@ public function testGetUA(){
$this->assertTrue($this->ua->getUA() == $ua['string']);
}

public function testGetBrowser() {
public function testGetBrowser()
{
$ua = $this->useragent['Chrome'];
$this->ua->setUA($ua['string']);
$this->assertTrue($this->ua->getBrowser()['name'] == $ua['browser']);
Expand All @@ -49,20 +55,21 @@ public function testGetBrowser() {
$this->ua->setUA($ua['string']);
$this->assertTrue($this->ua->getBrowser()['name'] == $ua['browser']);
}
public function testGetBrowserVersion() {

public function testGetBrowserVersion()
{
$ua = $this->useragent['Chrome'];
$this->ua->setUA($ua['string']);
$this->assertTrue($this->ua->getBrowser()['version'] == $ua['version']);

$ua = $this->useragent['Safari'];
$this->ua->setUA($ua['string']);

$this->assertTrue($this->ua->getBrowser()['version'] == $ua['version']);
}

public function testGetOS() {

public function testGetOS()
{
$ua = $this->useragent['Chrome'];
$this->ua->setUA($ua['string']);
$this->assertTrue($this->ua->getOS()['name'] == $ua['os']);
Expand All @@ -71,5 +78,4 @@ public function testGetOS() {
$this->ua->setUA($ua['string']);
$this->assertTrue($this->ua->getOS()['name'] == $ua['os']);
}

}
7 changes: 1 addition & 6 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<?php

$base_dir = dirname( dirname ( dirname(__DIR__) ) );

$loader = require $base_dir . '/autoload.php';
$loader->add('AppName', __DIR__.'/../src/');


require_once __DIR__ . '/../vendor/autoload.php';