add failing tests before fix addRule

This commit is contained in:
Marcos Neves 2013-08-20 21:25:14 -03:00
parent f0e08fbc06
commit 676e80dd8e

View File

@ -10,4 +10,26 @@ class StaticVsInstanceTest extends BaseTestCase
$this->assertEquals('ar', Validator::lang(),
'instance defined lang should not replace static global lang');
}
/**
* Rules messages added with Validator::addRule are replaced after creating validator instance
*/
public function testRuleMessagesReplacedAfterConstructor()
{
$customMessage = 'custom message';
$ruleName = 'foo';
Validator::addRule($ruleName, function() {}, $customMessage);
$prop = new ReflectionProperty('Valitron\Validator', '_ruleMessages');
$prop->setAccessible(true);
$messages = $prop->getValue();
$this->assertEquals($customMessage, $messages[$ruleName]);
new Validator(array(), array());
$messages = $prop->getValue();
$this->assertArrayHasKey($ruleName, $messages);
$this->assertEquals($customMessage, $messages[$ruleName]);
}
}