PageRenderTime 186ms CodeModel.GetById 80ms app.highlight 9ms RepoModel.GetById 92ms app.codeStats 0ms

/plugins/sfFormExtraPlugin/test/validator/sfValidatorDefaultTest.php

https://bitbucket.org/Kudlaty/360kdw
PHP | 35 lines | 20 code | 7 blank | 8 comment | 0 complexity | 92b4a5838358108197afe3afe8aee679 MD5 | raw file
 1<?php
 2
 3/*
 4 * This file is part of the symfony package.
 5 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 6 *
 7 * For the full copyright and license information, please view the LICENSE
 8 * file that was distributed with this source code.
 9 */
10
11require_once dirname(__FILE__).'/../bootstrap.php';
12require_once dirname(__FILE__).'/../../lib/validator/sfValidatorDefault.class.php';
13
14$t = new lime_test(4);
15
16// ->clean()
17$t->diag('->clean()');
18
19$validator = new sfValidatorDefault(array(
20  'validator' => new sfValidatorString(),
21  'default'   => '==DEFAULT==',
22));
23$t->is($validator->clean('foo'), 'foo', '->clean() returns cleaned values');
24$t->is($validator->clean(null), '==DEFAULT==', '->clean() returns the default on validation failure');
25
26$validator = new sfValidatorDefault(array(
27  'validator' => new sfValidatorString(array('empty_value' => '==EMPTY==')),
28));
29$t->is($validator->clean(null), '==EMPTY==', '->clean() returns the validator empty value if no default value is set');
30
31$validator = new sfValidatorDefault(array(
32  'validator' => new sfValidatorString(array('empty_value' => '==EMPTY==')),
33  'default'   => '==DEFAULT==',
34));
35$t->is($validator->clean(null), '==DEFAULT==', '->clean() returns the default if both default and the embedded empty value are set');