Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Commit

Permalink
Added functional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin Millard committed Jul 2, 2012
1 parent 989ec90 commit 0f82378
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ As an example, this type of logic:
```php
<?php

$fp = fopen('/path/to/foo', 'r');
$fp = fopen('/path/to/foo', 'r'); // this throws a PHP warning if the file is not found

if ($fp === false)
{
Expand Down
58 changes: 58 additions & 0 deletions test/suite/Eloquent/Asplode/FunctionalTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the Asplode package.
*
* Copyright © 2012 Erin Millard
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

class FunctionalTest extends \Eloquent\Asplode\Test\TestCase
{
/**
* Test one line installation.
*/
public function testOneLineInstallation()
{
\Eloquent\Asplode\Asplode::instance()->install();
$actual = set_error_handler(function() {});
restore_error_handler();
restore_error_handler();

$this->assertTrue(is_array($actual));
$this->assertSame(array(0, 1), array_keys($actual));
$this->assertInstanceOf('Eloquent\Asplode\Asplode', $actual[0]);
$this->assertSame('handleError', $actual[1]);
$this->assertTrue(is_callable($actual));
}

/**
* Test legacy PHP error example.
*/
public function testLegacyPhpError()
{
$this->setExpectedException('PHPUnit_Framework_Error_Warning');
$fp = fopen(uniqid(), 'r');
}

/**
* Test Asplode error handling.
*/
public function testAsplodeHandling()
{
\Eloquent\Asplode\Asplode::instance()->install();
$caught = false;
try
{
$fp = fopen(uniqid(), 'r');
}
catch (ErrorException $e)
{
$caught = true;
}

$this->assertTrue($caught);
}
}

0 comments on commit 0f82378

Please sign in to comment.