-
Notifications
You must be signed in to change notification settings - Fork 0
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
heartsentwined
committed
Sep 6, 2012
1 parent
11817ba
commit 693f83b
Showing
8 changed files
with
145 additions
and
28 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,10 @@ | ||
language: php | ||
php: | ||
- "5.3" | ||
- "5.4" | ||
before_script: composer install | ||
script: phpunit --configuration test/phpunit.xml | ||
notifications: | ||
email: | ||
on_success: always | ||
on_failure: always |
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
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
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
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,55 @@ | ||
<?php | ||
namespace Heartsentwined\Test\Browser; | ||
|
||
use Heartsentwined\Browser\Factory; | ||
use Heartsentwined\Browser\Exception; | ||
|
||
class BrowserTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
mkdir('tmp'); | ||
$factory = new Factory; | ||
$factory | ||
->setCookieDir('tmp') | ||
->setCookieLife(2) | ||
->setConnectTimeout(120); | ||
$this->browser = $factory->newInstance(); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
$handle = opendir('tmp'); | ||
while (($file = readdir($handle)) !== false) { | ||
unlink("tmp/$file"); | ||
} | ||
closedir($handle); | ||
rmdir('tmp'); | ||
} | ||
|
||
public function testGet() | ||
{ | ||
$body = $this->browser->get('http://google.com'); | ||
$this->assertNotEmpty($body); | ||
} | ||
|
||
public function testIndirectGet() | ||
{ | ||
$this->browser->setUri('http://google.com'); | ||
$body = $this->browser->get(); | ||
$this->assertNotEmpty($body); | ||
} | ||
|
||
public function testPost() | ||
{ | ||
$body = $this->browser->post('http://google.com', array()); | ||
$this->assertNotEmpty($body); | ||
} | ||
|
||
public function testIndirectPost() | ||
{ | ||
$this->browser->setUri('http://google.com'); | ||
$body = $this->browser->post('', array()); | ||
$this->assertNotEmpty($body); | ||
} | ||
} |
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,67 @@ | ||
<?php | ||
namespace Heartsentwined\Test\Browser; | ||
|
||
use Heartsentwined\Browser\Factory; | ||
|
||
class FactoryTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->factory = new Factory; | ||
} | ||
|
||
public function testCookie() | ||
{ | ||
mkdir('tmp'); | ||
$this->factory | ||
->setCookieDir('tmp') | ||
->newInstance(); | ||
|
||
$fileCount = 0; | ||
$handle = opendir('tmp'); | ||
while (($file = readdir($handle)) !== false) { | ||
unlink("tmp/$file"); | ||
$fileCount++; | ||
} | ||
closedir($handle); | ||
rmdir('tmp'); | ||
|
||
$this->assertSame(1, $fileCount); | ||
} | ||
|
||
public function testRemoveOldCookie() | ||
{ | ||
mkdir('tmp'); | ||
|
||
$fh = fopen('tmp/deleted', 'x+'); | ||
touch('tmp/deleted', time()-10*60); | ||
fclose($fh); | ||
|
||
$fh = fopen('tmp/remaining', 'x+'); | ||
touch('tmp/remaining', time()-5*60); | ||
fclose($fh); | ||
|
||
$this->factory | ||
->setCookieDir('tmp') | ||
->setCookieLife(10); | ||
unset($this->factory); //trigger destructor | ||
|
||
$deletedCount = 0; | ||
$remainingCount = 0; | ||
$handle = opendir('tmp'); | ||
while (($file = readdir($handle)) !== false) { | ||
if (strpos($file, 'deleted') !== false) { | ||
$deletedCount++; | ||
} | ||
if (strpos($file, 'remaining') !== false) { | ||
$remainingCount++; | ||
} | ||
unlink("tmp/$file"); | ||
} | ||
closedir($handle); | ||
rmdir('tmp'); | ||
|
||
$this->assertSame(0, $deletedCount); | ||
$this->assertSame(1, $remainingCount); | ||
} | ||
} |
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,3 @@ | ||
<?php | ||
$loader = require_once __DIR__ . '/../vendor/autoload.php'; | ||
$loader->add('Heartsentwined\Test', __DIR__); |
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,7 @@ | ||
<phpunit bootstrap="./bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite> | ||
<directory>./</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |