<?

	class Element_Base extends PHPUnit2_Framework_TestCase {

		public function setUp() {

			$_GET = array();
			$_POST = array();
		}

		protected function createForm($args) {

			extract($args);
			if (!isset($formname)) $formname = 'default';
			if (!isset($namespace)) $namespace = '';

			$form = patForms::createForm(self::$definitions[$formname]);
			$form->setSubmitted(true);
			$form->setNamespace($namespace);

			$renderer = patForms::createRenderer("Array");
			$form->setRenderer($renderer);

			return $form;
		}

		protected function stripElementId($element) {

			return preg_replace('!id="pfo[a-zA-Z0-9]*" ?!', '', $element);
		}

		static private $definitions = array(
			'default' => array(
				'name' => array('type' => 'String'),
			),
			'combobox' => array(
				'area' => array(
					'type' => 'Combobox',
					'attributes' => array(
						'values' => array(
							array(
								'label'	=> 'Very pretty area',
								'value'	=> 'a01',
							),
						),
					),
				),
			),
			'enum' => array(
				'area' => array(
					'type' => 'Enum',
					'attributes' => array(
						'values' => array(
							array(
								'label'	=> 'Very pretty area',
								'value'	=> 'a01',
							),
						),
					),
				),
			),
			'group' => array(
				'loginOptions' => array(
					'type' => 'Group',
					'attributes' => array(
						'display' => 'yes',
					),
				),
			),
			'hidden' => array(
				'area' => array(
					'type' => 'Hidden',
					'attributes' => array(
						'default'	=>	'a01',
					),
				),
			),
			'pool' => array(
				'mammalians' => array(
					'type' => 'Pool',
					'attributes' => array(
						'candidates' => array(
							array(
								'label'	=> 'Ant',
								'value'	=> 'and',
							),
							array(
								'label'	=> 'Bee',
								'value'	=> 'bee',
							),
						),
					),
				),
			),
			'radio' => array(
				'username' => array(
					'type' => 'Radio',
					'attributes' => array(
						'clicklabel'	=>	'yes',
						'value'			=>	'51',
						'label'			=>	'Area 51',
					),
				),
			),
			'radiogroup' => array(
				'username' => array(
					'type' => 'RadioGroup',
					'attributes' => array(
						'clicklabel'	=>	'yes',
						'default'		=>	'a03',
						'values'		=>	array(
							array(
								'label'	=>	'Very pretty area',
								'value'	=>	'a01',
							),
							array(
								'label'	=>	'No-nonsense area',
								'value'	=>	'a02',
							),
						),
					),
				),
			),
			'set' => array(
				'wishlist' => array(
					'type' => 'Set',
					'attributes' => array(
						'values' => array(
							array(
								'label'	=> 'More patForms elements',
								'value'	=> 'w1',
							),
							array(
								'label'	=> 'A tank',
								'value'	=> 'w7'
							),
						),
					),
				),
			),
			'switch' => array(
				'enable' => array(
					'type' => 'Switch',
					'attributes' => array(
						'value'			=> 'yes',
					),
				),
			),
		);
	}

?>