Extends
lithium\test\Unit
Tests that parameter validators are correctly applied to form data after the authentication
query has occurred.
Source
public function testParameterValidators() {
$subject = new Form(array(
'model' => __CLASS__,
'query' => 'validatorTest',
'validators' => array(
'password' => function($form, $data) {
return Password::check($form, $data);
},
'group' => function($form) {
return $form === 'editors';
}
)
));
$request = (object) array('data' => array(
'username' => 'Bob', 'password' => 's3cure', 'group' => 'editors'
));
$result = $subject->check($request);
$this->assertEqual(array_keys($request->data), array_keys($result));
$this->assertEqual('Bob', $result['username']);
$this->assertEqual('editors', $result['group']);
$this->assertTrue(Password::check('s3cure', $result['password']));
}