| 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 |
protected function assertSameVerbose($expected, $result) { |
|---|
| 33 |
|
|---|
| 34 |
try { |
|---|
| 35 |
$this->assertTrue($expected == $result); |
|---|
| 36 |
} catch(Exception $e) { |
|---|
| 37 |
$lf = php_sapi_name() == 'cli' ? "\n" : '<br>'; |
|---|
| 38 |
echo $lf . $lf; |
|---|
| 39 |
echo 'expected was: ' . htmlentities($expected) . $lf; |
|---|
| 40 |
echo 'result was: ' . htmlentities($result) . $lf . $lf; |
|---|
| 41 |
throw($e); |
|---|
| 42 |
} |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
static private $definitions = array( |
|---|
| 46 |
'default' => array( |
|---|
| 47 |
'name' => array('type' => 'String'), |
|---|
| 48 |
), |
|---|
| 49 |
'combobox' => array( |
|---|
| 50 |
'area' => array( |
|---|
| 51 |
'type' => 'Combobox', |
|---|
| 52 |
'attributes' => array( |
|---|
| 53 |
'values' => array( |
|---|
| 54 |
array( |
|---|
| 55 |
'label' => 'Very pretty area', |
|---|
| 56 |
'value' => 'a01', |
|---|
| 57 |
), |
|---|
| 58 |
), |
|---|
| 59 |
), |
|---|
| 60 |
), |
|---|
| 61 |
), |
|---|
| 62 |
'date' => array( |
|---|
| 63 |
'date' => array( |
|---|
| 64 |
'type' => 'Date', |
|---|
| 65 |
'attributes' => array( |
|---|
| 66 |
'display' => 'yes', |
|---|
| 67 |
'edit' => 'yes', |
|---|
| 68 |
'label' => 'date', |
|---|
| 69 |
'presets' => 'no', |
|---|
| 70 |
'dateformat' => 'Y-m-d' |
|---|
| 71 |
), |
|---|
| 72 |
), |
|---|
| 73 |
), |
|---|
| 74 |
'enum' => array( |
|---|
| 75 |
'area' => array( |
|---|
| 76 |
'type' => 'Enum', |
|---|
| 77 |
'attributes' => array( |
|---|
| 78 |
'values' => array( |
|---|
| 79 |
array( |
|---|
| 80 |
'label' => 'Very pretty area', |
|---|
| 81 |
'value' => 'a01', |
|---|
| 82 |
), |
|---|
| 83 |
), |
|---|
| 84 |
), |
|---|
| 85 |
), |
|---|
| 86 |
), |
|---|
| 87 |
'group' => array( |
|---|
| 88 |
'loginOptions' => array( |
|---|
| 89 |
'type' => 'Group', |
|---|
| 90 |
'attributes' => array( |
|---|
| 91 |
'display' => 'yes', |
|---|
| 92 |
), |
|---|
| 93 |
), |
|---|
| 94 |
), |
|---|
| 95 |
'hidden' => array( |
|---|
| 96 |
'area' => array( |
|---|
| 97 |
'type' => 'Hidden', |
|---|
| 98 |
'attributes' => array( |
|---|
| 99 |
'default' => 'a01', |
|---|
| 100 |
), |
|---|
| 101 |
), |
|---|
| 102 |
), |
|---|
| 103 |
'pool' => array( |
|---|
| 104 |
'mammalians' => array( |
|---|
| 105 |
'type' => 'Pool', |
|---|
| 106 |
'attributes' => array( |
|---|
| 107 |
'candidates' => array( |
|---|
| 108 |
array( |
|---|
| 109 |
'label' => 'Ant', |
|---|
| 110 |
'value' => 'and', |
|---|
| 111 |
), |
|---|
| 112 |
array( |
|---|
| 113 |
'label' => 'Bee', |
|---|
| 114 |
'value' => 'bee', |
|---|
| 115 |
), |
|---|
| 116 |
), |
|---|
| 117 |
), |
|---|
| 118 |
), |
|---|
| 119 |
), |
|---|
| 120 |
'radio' => array( |
|---|
| 121 |
'username' => array( |
|---|
| 122 |
'type' => 'Radio', |
|---|
| 123 |
'attributes' => array( |
|---|
| 124 |
'clicklabel' => 'yes', |
|---|
| 125 |
'value' => '51', |
|---|
| 126 |
'label' => 'Area 51', |
|---|
| 127 |
), |
|---|
| 128 |
), |
|---|
| 129 |
), |
|---|
| 130 |
'radiogroup' => array( |
|---|
| 131 |
'username' => array( |
|---|
| 132 |
'type' => 'RadioGroup', |
|---|
| 133 |
'attributes' => array( |
|---|
| 134 |
'clicklabel' => 'yes', |
|---|
| 135 |
'default' => 'a03', |
|---|
| 136 |
'values' => array( |
|---|
| 137 |
array( |
|---|
| 138 |
'label' => 'Very pretty area', |
|---|
| 139 |
'value' => 'a01', |
|---|
| 140 |
), |
|---|
| 141 |
array( |
|---|
| 142 |
'label' => 'No-nonsense area', |
|---|
| 143 |
'value' => 'a02', |
|---|
| 144 |
), |
|---|
| 145 |
), |
|---|
| 146 |
), |
|---|
| 147 |
), |
|---|
| 148 |
), |
|---|
| 149 |
'set' => array( |
|---|
| 150 |
'wishlist' => array( |
|---|
| 151 |
'type' => 'Set', |
|---|
| 152 |
'attributes' => array( |
|---|
| 153 |
'values' => array( |
|---|
| 154 |
array( |
|---|
| 155 |
'label' => 'More patForms elements', |
|---|
| 156 |
'value' => 'w1', |
|---|
| 157 |
), |
|---|
| 158 |
array( |
|---|
| 159 |
'label' => 'A tank', |
|---|
| 160 |
'value' => 'w7' |
|---|
| 161 |
), |
|---|
| 162 |
), |
|---|
| 163 |
), |
|---|
| 164 |
), |
|---|
| 165 |
), |
|---|
| 166 |
'switch' => array( |
|---|
| 167 |
'enable' => array( |
|---|
| 168 |
'type' => 'Switch', |
|---|
| 169 |
'attributes' => array( |
|---|
| 170 |
'value' => 'yes', |
|---|
| 171 |
), |
|---|
| 172 |
), |
|---|
| 173 |
), |
|---|
| 174 |
); |
|---|
| 175 |
} |
|---|
| 176 |
|
|---|
| 177 |
?> |
|---|