/** * test that validateErrors works with any old model. * * @return void */ public function testValidateErrorsOnArbitraryModels() { $TestController = new TestController(); $Post = new ControllerPost(); $Post->validate = array('title' => 'notEmpty'); $Post->set('title', ''); $result = $TestController->validateErrors($Post); $expected = array('title' => array('This field cannot be left blank')); $this->assertEquals($expected, $result); }
/** * testValidateErrors method * * @access public * @return void */ function testValidateErrors() { $TestController = new TestController(); $TestController->constructClasses(); $this->assertFalse($TestController->validateErrors()); $this->assertEqual($TestController->validate(), 0); $TestController->ControllerComment->invalidate('some_field', 'error_message'); $TestController->ControllerComment->invalidate('some_field2', 'error_message2'); $comment = new ControllerComment(); $comment->set('someVar', 'data'); $result = $TestController->validateErrors($comment); $expected = array('some_field' => 'error_message', 'some_field2' => 'error_message2'); $this->assertIdentical($result, $expected); $this->assertEqual($TestController->validate($comment), 2); }