| 1 |
lars |
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 |
|
|
|
11 |
$app = 'frontend';
|
|
|
12 |
include dirname(__FILE__).'/../../bootstrap/functional.php';
|
|
|
13 |
include $configuration->getSymfonyLibDir().'/vendor/lime/lime.php';
|
|
|
14 |
|
|
|
15 |
$t = new lime_test(2);
|
|
|
16 |
|
|
|
17 |
// ->clean()
|
|
|
18 |
$t->diag('->clean()');
|
|
|
19 |
|
|
|
20 |
$validator = new sfValidatorPropelUnique(array('model' => 'Author', 'column' => 'name'));
|
|
|
21 |
|
|
|
22 |
$author = new Author();
|
|
|
23 |
$author->setName('==NAME==');
|
|
|
24 |
$author->save();
|
|
|
25 |
|
|
|
26 |
try
|
|
|
27 |
{
|
|
|
28 |
$validator->clean(array('name' => '==NAME=='));
|
|
|
29 |
$t->fail('->clean() throws an error on the column');
|
|
|
30 |
}
|
|
|
31 |
catch (sfValidatorErrorSchema $errors)
|
|
|
32 |
{
|
|
|
33 |
$t->is(isset($errors['name']), true, '->clean() throws an error on the column');
|
|
|
34 |
}
|
|
|
35 |
catch (Exception $e)
|
|
|
36 |
{
|
|
|
37 |
$t->fail('->clean() throws an error on the column');
|
|
|
38 |
$t->diag(' '.$e->getMessage());
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
$validator->setOption('field', 'author_name');
|
|
|
42 |
|
|
|
43 |
try
|
|
|
44 |
{
|
|
|
45 |
$validator->clean(array('author_name' => '==NAME=='));
|
|
|
46 |
$t->fail('->clean() throws an error on the field');
|
|
|
47 |
}
|
|
|
48 |
catch (sfValidatorErrorSchema $errors)
|
|
|
49 |
{
|
|
|
50 |
$t->is(isset($errors['author_name']), true, '->clean() throws an error on the field');
|
|
|
51 |
}
|
|
|
52 |
catch (Exception $e)
|
|
|
53 |
{
|
|
|
54 |
$t->fail('->clean() throws an error on the field');
|
|
|
55 |
$t->diag(' '.$e->getMessage());
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
$author->delete();
|