| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) 2004-2006 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 = 'backend';
|
|
|
12 |
$fixtures = 'fixtures';
|
|
|
13 |
require_once(dirname(__FILE__).'/../bootstrap/functional.php');
|
|
|
14 |
|
|
|
15 |
$t = new lime_test(41);
|
|
|
16 |
|
|
|
17 |
$t->diag("Test that these models don't generate forms or filters classes");
|
|
|
18 |
$noFormsOrFilters = array('UserGroup', 'UserPermission', 'GroupPermission');
|
|
|
19 |
foreach ($noFormsOrFilters as $model)
|
|
|
20 |
{
|
|
|
21 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/'.$model.'Form.class.php'), false);
|
|
|
22 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/base/Base'.$model.'Form.class.php'), false);
|
|
|
23 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/'.$model.'FormFilter.class.php'), false);
|
|
|
24 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/base/Base'.$model.'FormFilter.class.php'), false);
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
$t->diag('FormGeneratorTest model should generate forms but not filters');
|
|
|
28 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/FormGeneratorTestForm.class.php'), true);
|
|
|
29 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/base/BaseFormGeneratorTestForm.class.php'), true);
|
|
|
30 |
|
|
|
31 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/FormGeneratorTestFormFilter.class.php'), false);
|
|
|
32 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/base/BaseFormGeneratorTestFormFilter.class.php'), false);
|
|
|
33 |
|
|
|
34 |
$t->diag('FormGeneratorTest2 model should generate filters but not forms');
|
|
|
35 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/FormGeneratorTest2Form.class.php'), false);
|
|
|
36 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/base/BaseFormGeneratorTest2Form.class.php'), false);
|
|
|
37 |
|
|
|
38 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/FormGeneratorTest2FormFilter.class.php'), true);
|
|
|
39 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/base/BaseFormGeneratorTest2FormFilter.class.php'), true);
|
|
|
40 |
|
|
|
41 |
$t->diag('FormGeneratorTest3 model should not generate forms or filters');
|
|
|
42 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/FormGeneratorTest3Form.class.php'), false);
|
|
|
43 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/base/BaseFormGeneratorTest3Form.class.php'), false);
|
|
|
44 |
|
|
|
45 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/FormGeneratorTest3FormFilter.class.php'), false);
|
|
|
46 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/base/BaseFormGeneratorTest3FormFilter.class.php'), false);
|
|
|
47 |
|
|
|
48 |
$t->diag('FormGeneratorTest3Translation not generate forms or filters');
|
|
|
49 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/FormGeneratorTest3TranslationForm.class.php'), false);
|
|
|
50 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/form/doctrine/base/BaseFormGeneratorTest3TranslationForm.class.php'), false);
|
|
|
51 |
|
|
|
52 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/FormGeneratorTest3TranslationFormFilter.class.php'), false);
|
|
|
53 |
$t->is(file_exists(sfConfig::get('sf_lib_dir').'/filter/doctrine/base/BaseFormGeneratorTest3TranslationFormFilter.class.php'), false);
|
|
|
54 |
|
|
|
55 |
$t->diag('Check form generator generates forms with correct inheritance');
|
|
|
56 |
$test = new AuthorInheritanceForm();
|
|
|
57 |
$t->is(is_subclass_of($test, 'AuthorForm'), true);
|
|
|
58 |
|
|
|
59 |
$test = new AuthorInheritanceFormFilter();
|
|
|
60 |
$t->is(is_subclass_of($test, 'AuthorFormFilter'), true);
|
|
|
61 |
|
|
|
62 |
$t->diag('Check form generator adds columns to concrete inheritance forms');
|
|
|
63 |
$test = new AuthorForm();
|
|
|
64 |
$t->ok(!isset($test['additional']));
|
|
|
65 |
|
|
|
66 |
$test = new AuthorInheritanceConcreteForm();
|
|
|
67 |
$t->ok(isset($test['additional']));
|
|
|
68 |
|
|
|
69 |
$test = new AuthorFormFilter();
|
|
|
70 |
$t->ok(!isset($test['additional']));
|
|
|
71 |
$t->ok(!array_key_exists('additional', $test->getFields()));
|
|
|
72 |
|
|
|
73 |
$test = new AuthorInheritanceConcreteFormFilter();
|
|
|
74 |
$t->ok(isset($test['additional']));
|
|
|
75 |
$t->ok(array_key_exists('additional', $test->getFields()));
|
|
|
76 |
|
|
|
77 |
$t->diag('Check form generator respects relations tweaked by inheritance');
|
|
|
78 |
$test = new BlogArticleForm();
|
|
|
79 |
$t->is($test->getWidget('author_id')->getOption('model'), 'BlogAuthor');
|
|
|
80 |
$t->is($test->getValidator('author_id')->getOption('model'), 'BlogAuthor');
|
|
|
81 |
|
|
|
82 |
$test = new BlogArticleFormFilter();
|
|
|
83 |
$t->is($test->getWidget('author_id')->getOption('model'), 'BlogAuthor');
|
|
|
84 |
$t->is($test->getValidator('author_id')->getOption('model'), 'BlogAuthor');
|
|
|
85 |
|
|
|
86 |
$t->diag('Check enum primary keys');
|
|
|
87 |
try
|
|
|
88 |
{
|
|
|
89 |
$test = new ResourceTypeForm();
|
|
|
90 |
$t->pass('enum primary key widgets work');
|
|
|
91 |
}
|
|
|
92 |
catch (InvalidArgumentException $e)
|
|
|
93 |
{
|
|
|
94 |
$t->fail('enum primary key widgets work');
|
|
|
95 |
$t->diag(' '.$e->getMessage());
|
|
|
96 |
}
|