Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding test case for #2969, message return value replacement
  • Loading branch information
zombor committed Jun 23, 2010
1 parent da528fe commit 5feadbb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/kohana/ValidateTest.php
Expand Up @@ -787,15 +787,17 @@ public function provider_check()
return array(
array(
array('foo' => 'bar'),
array('foo' => 'not_empty'),
array('foo' => array('not_empty', NULL)),
array('foo' => array($this, 'unit_test_callback')),
TRUE,
array(),
),
array(
array('unit' => 'test'),
array('foo' => 'not_empty'),
array('foo' => array('not_empty', NULL), 'unit' => array('min_length', 6)),
array(),
FALSE,
array('foo' => 'foo must not be empty', 'unit' => 'unit must be at least 6 characters long'),
),
);
}
Expand All @@ -809,22 +811,28 @@ public function provider_check()
* @covers Validate::callback
* @covers Validate::rule
* @covers Validate::rules
* @covers Validate::errors
* @covers Validate::error
* @dataProvider provider_check
* @param string $url The url to test
* @param boolean $expected Is it valid?
*/
public function test_check($array, $rules, $callbacks, $expected)
public function test_check($array, $rules, $callbacks, $expected, $expected_errors)
{
$validate = Validate::factory($array);
foreach ($rules as $field => $rule)
$validate->rule($field, $rule);
$validate->rule($field, $rule[0], array($rule[1]));
foreach ($callbacks as $field => $callback)
$validate->callback($field, $callback);
$this->assertSame($expected, $validate->check());

$status = $validate->check();
$errors = $validate->errors(TRUE);
$this->assertSame($expected, $status);
$this->assertSame($expected_errors, $errors);

$validate = Validate::factory($array);
foreach ($rules as $field => $rule)
$validate->rules($field, array($rule => NULL));
$validate->rules($field, array($rule[0] => array($rule[1])));
$this->assertSame($expected, $validate->check());
}

Expand Down

0 comments on commit 5feadbb

Please sign in to comment.