| Revision 260,
3.0 KB
checked in by sfuchs, 8 years ago
(diff) |
|
re-commit: element unittests and testpages
|
| Line | |
|---|
| 1 | <? |
|---|
| 2 | |
|---|
| 3 | class Element_Base extends PHPUnit2_Framework_TestCase { |
|---|
| 4 | |
|---|
| 5 | public function setUp() { |
|---|
| 6 | |
|---|
| 7 | $_GET = array(); |
|---|
| 8 | $_POST = array(); |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | protected function createForm($args) { |
|---|
| 12 | |
|---|
| 13 | extract($args); |
|---|
| 14 | if (!isset($formname)) $formname = 'default'; |
|---|
| 15 | if (!isset($namespace)) $namespace = ''; |
|---|
| 16 | |
|---|
| 17 | $form = patForms::createForm(self::$definitions[$formname]); |
|---|
| 18 | $form->setSubmitted(true); |
|---|
| 19 | $form->setNamespace($namespace); |
|---|
| 20 | |
|---|
| 21 | $renderer = patForms::createRenderer("Array"); |
|---|
| 22 | $form->setRenderer($renderer); |
|---|
| 23 | |
|---|
| 24 | return $form; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | protected function stripElementId($element) { |
|---|
| 28 | |
|---|
| 29 | return preg_replace('!id="pfo[a-zA-Z0-9]*" ?!', '', $element); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | static private $definitions = array( |
|---|
| 33 | 'default' => array( |
|---|
| 34 | 'name' => array('type' => 'String'), |
|---|
| 35 | ), |
|---|
| 36 | 'combobox' => array( |
|---|
| 37 | 'area' => array( |
|---|
| 38 | 'type' => 'Combobox', |
|---|
| 39 | 'attributes' => array( |
|---|
| 40 | 'values' => array( |
|---|
| 41 | array( |
|---|
| 42 | 'label' => 'Very pretty area', |
|---|
| 43 | 'value' => 'a01', |
|---|
| 44 | ), |
|---|
| 45 | ), |
|---|
| 46 | ), |
|---|
| 47 | ), |
|---|
| 48 | ), |
|---|
| 49 | 'enum' => array( |
|---|
| 50 | 'area' => array( |
|---|
| 51 | 'type' => 'Enum', |
|---|
| 52 | 'attributes' => array( |
|---|
| 53 | 'values' => array( |
|---|
| 54 | array( |
|---|
| 55 | 'label' => 'Very pretty area', |
|---|
| 56 | 'value' => 'a01', |
|---|
| 57 | ), |
|---|
| 58 | ), |
|---|
| 59 | ), |
|---|
| 60 | ), |
|---|
| 61 | ), |
|---|
| 62 | 'group' => array( |
|---|
| 63 | 'loginOptions' => array( |
|---|
| 64 | 'type' => 'Group', |
|---|
| 65 | 'attributes' => array( |
|---|
| 66 | 'display' => 'yes', |
|---|
| 67 | ), |
|---|
| 68 | ), |
|---|
| 69 | ), |
|---|
| 70 | 'hidden' => array( |
|---|
| 71 | 'area' => array( |
|---|
| 72 | 'type' => 'Hidden', |
|---|
| 73 | 'attributes' => array( |
|---|
| 74 | 'default' => 'a01', |
|---|
| 75 | ), |
|---|
| 76 | ), |
|---|
| 77 | ), |
|---|
| 78 | 'pool' => array( |
|---|
| 79 | 'mammalians' => array( |
|---|
| 80 | 'type' => 'Pool', |
|---|
| 81 | 'attributes' => array( |
|---|
| 82 | 'candidates' => array( |
|---|
| 83 | array( |
|---|
| 84 | 'label' => 'Ant', |
|---|
| 85 | 'value' => 'and', |
|---|
| 86 | ), |
|---|
| 87 | array( |
|---|
| 88 | 'label' => 'Bee', |
|---|
| 89 | 'value' => 'bee', |
|---|
| 90 | ), |
|---|
| 91 | ), |
|---|
| 92 | ), |
|---|
| 93 | ), |
|---|
| 94 | ), |
|---|
| 95 | 'radio' => array( |
|---|
| 96 | 'username' => array( |
|---|
| 97 | 'type' => 'Radio', |
|---|
| 98 | 'attributes' => array( |
|---|
| 99 | 'clicklabel' => 'yes', |
|---|
| 100 | 'value' => '51', |
|---|
| 101 | 'label' => 'Area 51', |
|---|
| 102 | ), |
|---|
| 103 | ), |
|---|
| 104 | ), |
|---|
| 105 | 'radiogroup' => array( |
|---|
| 106 | 'username' => array( |
|---|
| 107 | 'type' => 'RadioGroup', |
|---|
| 108 | 'attributes' => array( |
|---|
| 109 | 'clicklabel' => 'yes', |
|---|
| 110 | 'default' => 'a03', |
|---|
| 111 | 'values' => array( |
|---|
| 112 | array( |
|---|
| 113 | 'label' => 'Very pretty area', |
|---|
| 114 | 'value' => 'a01', |
|---|
| 115 | ), |
|---|
| 116 | array( |
|---|
| 117 | 'label' => 'No-nonsense area', |
|---|
| 118 | 'value' => 'a02', |
|---|
| 119 | ), |
|---|
| 120 | ), |
|---|
| 121 | ), |
|---|
| 122 | ), |
|---|
| 123 | ), |
|---|
| 124 | 'set' => array( |
|---|
| 125 | 'wishlist' => array( |
|---|
| 126 | 'type' => 'Set', |
|---|
| 127 | 'attributes' => array( |
|---|
| 128 | 'values' => array( |
|---|
| 129 | array( |
|---|
| 130 | 'label' => 'More patForms elements', |
|---|
| 131 | 'value' => 'w1', |
|---|
| 132 | ), |
|---|
| 133 | array( |
|---|
| 134 | 'label' => 'A tank', |
|---|
| 135 | 'value' => 'w7' |
|---|
| 136 | ), |
|---|
| 137 | ), |
|---|
| 138 | ), |
|---|
| 139 | ), |
|---|
| 140 | ), |
|---|
| 141 | 'switch' => array( |
|---|
| 142 | 'enable' => array( |
|---|
| 143 | 'type' => 'Switch', |
|---|
| 144 | 'attributes' => array( |
|---|
| 145 | 'value' => 'yes', |
|---|
| 146 | ), |
|---|
| 147 | ), |
|---|
| 148 | ), |
|---|
| 149 | ); |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | ?> |
|---|
Note: See
TracBrowser
for help on using the repository browser.