Exemplo n.º 1
0
/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(17);
$v = new sfValidatorBoolean();
// ->clean()
$t->diag('->clean()');
// true values
$t->diag('true values');
foreach ($v->getOption('true_values') as $true_value) {
    $t->is($v->clean($true_value), true, '->clean() returns true if the value is in the true_values option');
}
// false values
$t->diag('false values');
foreach ($v->getOption('false_values') as $false_value) {
    $t->is($v->clean($false_value), false, '->clean() returns false if the value is in the false_values option');
}
// required is false by default
$t->is($v->clean(null), false, '->clean() returns false if the value is null');
try {
    $v->clean('astring');
    $t->fail('->clean() throws an error if the input value is not a true or a false value');
    $t->skip('', 1);
} catch (sfValidatorError $e) {
    $t->pass('->clean() throws an error if the input value is not a true or a false value');