diff --git a/tests/kohana/ValidateTest.php b/tests/kohana/ValidateTest.php index 1325cd0de..eb0d09a3b 100644 --- a/tests/kohana/ValidateTest.php +++ b/tests/kohana/ValidateTest.php @@ -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'), ), ); } @@ -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()); }