-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c19ff7
commit 562eb82
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
namespace WhichBrowserTest; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use WhichBrowser\Analyser; | ||
use WhichBrowser\Model\Main; | ||
|
||
/** | ||
* @covers WhichBrowser\Parser | ||
*/ | ||
class AnalyserTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testCreatingAnalyserGetData() | ||
{ | ||
$analyser = new Analyser("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; InfoPath.1)"); | ||
|
||
$this->assertTrue($analyser instanceof \WhichBrowser\Analyser); | ||
|
||
$analyser->analyse(); | ||
|
||
$data = $analyser->getData(); | ||
|
||
$this->assertTrue($data instanceof \WhichBrowser\Model\Main); | ||
} | ||
|
||
public function testCreatingAnalyserSetData() | ||
{ | ||
$analyser = new Analyser("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; InfoPath.1)"); | ||
|
||
$this->assertTrue($analyser instanceof \WhichBrowser\Analyser); | ||
|
||
$input = new Main(); | ||
|
||
$this->assertTrue($input instanceof \WhichBrowser\Model\Main); | ||
|
||
$analyser->setData($input); | ||
|
||
$analyser->analyse(); | ||
|
||
$output = $analyser->getData(); | ||
|
||
$this->assertTrue($output instanceof \WhichBrowser\Model\Main); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
namespace WhichBrowserTest; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use WhichBrowser\Parser; | ||
|
||
/** | ||
* @covers WhichBrowser\Parser | ||
*/ | ||
class ParserTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testCreatingParserWithString() | ||
{ | ||
$parser = new Parser("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; InfoPath.1)"); | ||
|
||
$this->assertTrue($parser instanceof \WhichBrowser\Parser); | ||
|
||
$this->assertTrue($parser->isBrowser('Internet Explorer', '=', '6.0')); | ||
} | ||
|
||
public function testCreatingParserWithHeaders() | ||
{ | ||
$parser = new Parser([ | ||
'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; InfoPath.1)' | ||
]); | ||
|
||
$this->assertTrue($parser instanceof \WhichBrowser\Parser); | ||
|
||
$this->assertTrue($parser->isBrowser('Internet Explorer', '=', '6.0')); | ||
} | ||
|
||
public function testCreatingParserWithOptions() | ||
{ | ||
$parser = new Parser([ | ||
'headers' => [ | ||
'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; InfoPath.1)' | ||
] | ||
]); | ||
|
||
$this->assertTrue($parser instanceof \WhichBrowser\Parser); | ||
|
||
$this->assertTrue($parser->isBrowser('Internet Explorer', '=', '6.0')); | ||
} | ||
} |