Source for file ExceptionTest.php
Documentation is available at ExceptionTest.php
* "THE BEER-WARE LICENSE" (Revision 42):
* "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
* As long as you retain this notice you can do whatever you want with
* this stuff. If we meet some day, and you think this stuff is worth it,
* you can buy me a beer in return.
* @copyright Copyright (c) 2009 Sven Strittmatter
// Call Console_ApplicationTest::main() if this source file is executed directly.
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Console_ExceptionTest::main');
require_once(dirname(__FILE__ ) . '/../TestHelper.php');
require_once('Console/Exception.php');
* @copyright Copyright (c) 2009 Sven Strittmatter
* Runs the test methods of this class.
public static function main() {
require_once('PHPUnit/TextUI/TestRunner.php');
$suite = new PHPUnit_Framework_TestSuite("Console_ExceptionTest");
$result = PHPUnit_TextUI_TestRunner::run($suite);
* We expect a string like:
* Excpetion: EXCEPTION_MESSAGE [Code: EXCPETION_CODE]PHP_EOL;
array('message' => 'Testmessage', 'code' => 0),
array('message' => 'Another Message', 'code' => 5),
array('message' => 'Error occured', 'code' => - 4),
array('message' => 'Blaaa ', 'code' => null),
array('message' => 'Mor message', 'code' => false)
foreach ($parmeters as $parameter) {
$expectedString = "Excpetion: {$parameter['message']} [Code: " . (int) $parameter['code']. ']' . PHP_EOL;
$this->assertEquals($expectedString, $exception->__toString());
$this->assertEquals($expectedString, $exception . '');
// Call Console_ExceptionTest::main() if this source file is executed directly.
|