fail( "Expected exception was not thrown" ); } catch ( ezcExecutionException $e ) { $this->assertEquals( ezcExecutionException::NOT_INITALIZED, $e->getCode() ); } } public function testCallbackExists() { ezcExecution::reset(); try { @ezcExecution::init( 'ezcExecutionDoesNotExist' ); $this->fail( "Expected exception was not thrown" ); } catch ( ezcExecutionException $e ) { $this->assertEquals( ezcExecutionException::INVALID_CALLBACK, $e->getCode() ); } } public function testAlreadyInitialized() { ezcExecution::reset(); try { ezcExecution::init( 'ExecutionTest2' ); ezcExecution::init( 'ExecutionTest2' ); $this->fail( "Expected exception was not thrown" ); } catch ( ezcExecutionException $e ) { $this->assertEquals( ezcExecutionException::ALREADY_INITALIZED, $e->getCode() ); } } public function testReset() { ezcExecution::reset(); ezcExecution::init( 'ExecutionTest2' ); ezcExecution::reset(); ezcExecution::init( 'ExecutionTest2' ); } public function testInvalidCallbackClass() { ezcExecution::reset(); try { ezcExecution::init( 'ExecutionTest1' ); $this->fail( "Expected exception was not thrown" ); } catch ( ezcExecutionException $e ) { $this->assertEquals( ezcExecutionException::WRONG_CLASS, $e->getCode() ); } } public function testCleanExitInitialized() { ezcExecution::reset(); ezcExecution::init( 'ExecutionTest2' ); ezcExecution::cleanExit(); } /** * Unfortunately this test is unable to work, because when the uncaught * exception would have been run, PHP aborts. So let's leave the test * commented out! * public function testUncaughtException() { ezcExecution::reset(); ezcExecution::init( 'ezcExecutionBasicErrorHandler' ); throw new Exception(); ezcExecution::reset(); } */ /** * This test would leave a warning when the unit test frameworks ends. As * there is no other way of testing this, please leave the test commented * out! * public function testUncleanExit() { ezcExecution::reset(); ezcExecution::init( 'ezcExecutionBasicErrorHandler' ); } */ public static function suite() { return new ezcTestSuite( "ezcExecutionInitDefinition" ); } } ?>