Skip to content

Instantly share code, notes, and snippets.

@donaldducky
Created March 20, 2012 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donaldducky/2129601 to your computer and use it in GitHub Desktop.
Save donaldducky/2129601 to your computer and use it in GitHub Desktop.
Set template test
<?php
// tests/library/Respect/Validation/ValidatorTest.php
namespace Respect\Validation;
class ValidatorTest extends \PHPUnit_Framework_TestCase
{
function test_static_create_should_return_new_validator()
{
$this->assertInstanceOf('Respect\Validation\Validator', Validator::create());
}
function test_invalid_rule_class_should_throw_component_exception()
{
$this->setExpectedException('Respect\Validation\Exceptions\ComponentException');
Validator::iDoNotExistSoIShouldThrowException();
}
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());
}
}
}
@donaldducky
Copy link
Author

Respect/Validation#64

Ran this in the tests directory:
phpunit --filter test_set_template .

Assume it should use the "...is not tasty" template but it returns "...must be valid"

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