Errors in I18n\Validation
ValerchikV opened this issue · comments
I override default kohana Validation class with I18n\Validation and got this errors after run kohana tests:
1) Kohana_ValidationTest::test_check with data set #1 (array('test'), array(array(array('not_empty', NULL)), array(array('min_length', array(':value', 6)))), array(), false, array('foo must not be empty', 'unit must be at least 6 characters long'))
Failed asserting that Array (
'foo' => '1.foo.not_empty'
'unit' => 'unit must be at least 6 characters long'
) is identical to Array (
'foo' => 'foo must not be empty'
'unit' => 'unit must be at least 6 characters long'
).
/mnt/hgfs/ipnew/system/tests/kohana/ValidationTest.php:305
2) Kohana_ValidationTest::test_check with data set #3 (array(array('test', 'data')), array(array(array('in_array', array('kohana', ':value')))), array(), false, array('foo must be one of the available options'))
Failed asserting that Array (
'foo' => '1.foo.in_array'
) is identical to Array (
'foo' => 'foo must be one of the available options'
).
/mnt/hgfs/ipnew/system/tests/kohana/ValidationTest.php:305
3) Kohana_ValidationTest::test_translated_errors with data set #0 (array(''), array(array(array('not_empty', NULL))), array('Español must not be empty'), array('Spanish must not be empty'))
Failed asserting that Array (
'Spanish' => 'Spanish must not be empty'
) is identical to Array (
'Spanish' => 'Español must not be empty'
).
/mnt/hgfs/ipnew/system/tests/kohana/ValidationTest.php:461
4) Kohana_ValidationTest::test_parameter_labels
Failed asserting that Array (
'foo' => 'foo must equal Spanish'
) is identical to Array (
'foo' => 'foo must equal Español'
).
/mnt/hgfs/ipnew/system/tests/kohana/ValidationTest.php:493
After comparing general code from original and I18n\Validation::errors()
methods looks like code changed in 3.3
First 2 errors appear because in I18n\Validation::errors()
below block not exist
...
elseif ($message = Kohana::message('validation', $error) AND is_string($message))
{
// Found a default message for this error
}
...
Last 2 errors appear because now kohana translate labels. And I18n\Validation::errors()
not.
I propose to rewrite this function completly using latest kohana code.
I don't think the test is implemented correctly. It's actually trying to test Kohana_Validation
class, but it uses Validation
instance for this, which is another class!