mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
add failing tests before fix addRule
This commit is contained in:
parent
f0e08fbc06
commit
676e80dd8e
@ -10,4 +10,26 @@ class StaticVsInstanceTest extends BaseTestCase
|
|||||||
$this->assertEquals('ar', Validator::lang(),
|
$this->assertEquals('ar', Validator::lang(),
|
||||||
'instance defined lang should not replace static global 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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user