From 0f82378d28b21fde1f7e4acd3fb8aefdfe17ba3a Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Mon, 2 Jul 2012 22:43:01 +1000 Subject: [PATCH] Added functional tests. --- README.md | 2 +- .../suite/Eloquent/Asplode/FunctionalTest.php | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/suite/Eloquent/Asplode/FunctionalTest.php diff --git a/README.md b/README.md index 4dd10ff..5460a71 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ As an example, this type of logic: ```php 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); + } +}