getMessage() ); } } public function testSetAction() { $f = new testControllerController( 'testAction', new ezcMvcRequest() ); self::assertEquals( "testAction", $this->readAttribute( $f, 'action' ) ); } public function testGetNonExistingVariables() { $r = new ezcMvcRequest; $r->variables = array( 'var1' => 42, 'var42' => 'bansai!' ); $f = new testControllerController( 'testAction', $r ); try { $foo = $f->new; self::fail( 'Expected exception not thrown.' ); } catch ( ezcBasePropertyNotFoundException $e ) { self::assertEquals( "No such property name 'new'.", $e->getMessage() ); } } public function testSetVariables() { $r = new ezcMvcRequest; $r->variables = array( 'var1' => 42, 'var42' => 'bansai!' ); $f = new testControllerController( 'testAction', $r ); self::assertEquals( 42, $f->var1 ); self::assertEquals( 'bansai!', $f->var42 ); } public function testSetProperties() { $r = new ezcMvcRequest; $r->variables = array( 'var1' => 42, 'var42' => 'bansai!' ); $f = new testControllerController( 'testAction', $r ); try { $f->new = 'fail!'; self::fail( 'Expected exception not thrown.' ); } catch ( ezcBasePropertyPermissionException $e ) { self::assertEquals( "The property 'new' is read-only.", $e->getMessage() ); } try { $f->var = 'modified'; self::fail( 'Expected exception not thrown.' ); } catch ( ezcBasePropertyPermissionException $e ) { self::assertEquals( "The property 'var' is read-only.", $e->getMessage() ); } } public function testIssetProperties() { $r = new ezcMvcRequest; $r->variables = array( 'var1' => 42, 'var42' => 'bansai!' ); $f = new testControllerController( 'testAction', $r ); self::assertEquals( false, isset( $f->notSet ) ); self::assertEquals( true, isset( $f->var1 ) ); } public function testRoutingInformation() { $r = new ezcMvcRequest; $r->variables = array( 'var1' => 42, 'var42' => 'bansai!' ); $f = new testControllerController( 'testAction', $r ); $f->setRouter( new testSimpleRouter( $r ) ); self::assertEquals( new testSimpleRouter( $r ), $f->getRouter() ); } public function testCreateActionMethod() { $f = new testControllerController( 'test', new ezcMvcRequest() ); self::assertEquals( 'doTest', $f->testCreateActionMethod() ); $f = new testControllerController( 'test_action', new ezcMvcRequest() ); self::assertEquals( 'doTestAction', $f->testCreateActionMethod() ); $f = new testControllerController( 'testAction', new ezcMvcRequest() ); self::assertEquals( 'doTestAction', $f->testCreateActionMethod() ); $f = new testControllerController( 'test_with_more_than_OneWord', new ezcMvcRequest() ); self::assertEquals( 'doTestWithMoreThanOneWord', $f->testCreateActionMethod() ); } public static function suite() { return new PHPUnit_Framework_TestSuite( "ezcMvcToolsControllerTest" ); } } ?>