Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to disable Symfony's error handler.
PHPUnit has built in support for testing if PHP errors are thrown by looking for special exception classes: PHPUnit_Framework_Error PHPUnit_Framework_Warning PHPUnit_Framework_Notice This support is only enabled if no other error handlers are registered. The Symfony kernel registers an error handler by default, thus disabling PHPUnit's special PHP error exceptions if the kernel has been booted. This commit adds support for a new configuration parameter, error_handler.enable, which can prevent the Symfony error handler from registering if set to false. After this commit, by default the error handler will be disabled in the test environment. To enable it, add the following to your config_test.yml: parameters: error_handler.enable: true
- Loading branch information
Brandon Turner
committed
Jul 7, 2010
1 parent
b6799d0
commit 4b24544
Showing
5 changed files
with
57 additions
and
5 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
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,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Tests\Foundation\Debug; | ||
|
||
use Symfony\Foundation\Debug\ErrorHandler; | ||
|
||
class ErrorHandlerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @covers Symfony\Foundation\Debug\ErrorHandler::register | ||
*/ | ||
public function testRegister() | ||
{ | ||
$fakeHandler = function($errno, $errstr) | ||
{ | ||
die('Fake error handler triggered'); | ||
}; | ||
|
||
$oldHandler = set_error_handler($fakeHandler); | ||
restore_error_handler(); | ||
|
||
$handler = new ErrorHandler(); | ||
$handler->register(false); | ||
$newHandler = set_error_handler($fakeHandler); | ||
restore_error_handler(); | ||
$this->assertEquals($oldHandler, $newHandler); | ||
|
||
$handler = new ErrorHandler(); | ||
$handler->register(true); | ||
$newHandler = set_error_handler($fakeHandler); | ||
restore_error_handler(); | ||
$this->assertNotEquals($oldHandler, $newHandler); | ||
restore_error_handler(); | ||
} | ||
} |