Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

setTemplate doesn't work? #64

donaldducky opened this Issue Mar 20, 2012 · 5 comments


None yet
3 participants

I made a test similar to the one in here:

function test_set_template() {
  try {
    Validator::callback('is_int')->setTemplate('{{name}} is not tasty')->assert('something');
  } catch (\Exception $e) {
    $this->assertEquals('"something" is not tasty', $e->getMainMessage());

But it fails the test. It seems it's using the default one.

Maybe I'm not using it correctly?


augustohp commented Mar 20, 2012

  • Could you put a gist so it is easier for us to test?
  • The test you mentioned changed a lot and does not work like this anymore, I'm not the best person to answer you, but sure I can try. It seems to me you want to do something similar to test/livrary/Respect/Validation/Exceptions/ValidationExceptionTest.php. This is what you want?

I just added that to any of the unittests: https://gist.github.com/2129601

And ran it like so:

cd tests
phpunit --filter test_set_template .

I was looking into it a bit earlier, it looks like when the exception is created, it checks if the template is there, but it comes back as null, that's why it uses the default template.

See: https://github.com/Respect/Validation/blob/develop/library/Respect/Validation/Rules/AbstractRule.php#L59


alganet commented Mar 20, 2012


I'm marking this as a bug, gonna check as soon as I got some time. Thanks for reporting =D

alganet added a commit that referenced this issue Mar 23, 2012

alganet added a commit that referenced this issue Mar 23, 2012

@alganet alganet closed this in b364382 Mar 23, 2012


alganet commented Mar 23, 2012

Hey @donaldducky, this issue has been fixed! Thanks again for reporting this and contributing with the test. Let us know if there's anything else we could help you out.

Very cool! Glad I could help.
Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment