diff --git a/tests/unit/e107_user_extendedTest.php b/tests/unit/e107_user_extendedTest.php index d5db6ea56..f1fda85fc 100644 --- a/tests/unit/e107_user_extendedTest.php +++ b/tests/unit/e107_user_extendedTest.php @@ -12,6 +12,8 @@ class e107_user_extendedTest extends \Codeception\Test\Unit { + private $typeArray; + /** @var e107_user_extended */ protected $ue; @@ -31,7 +33,7 @@ $this->ue->__construct(); - $typeArray = array( + $this->typeArray = array( 'text' => EUF_TEXT, 'radio' => EUF_RADIO, 'dropdown' => EUF_DROPDOWN, @@ -50,7 +52,7 @@ // Add a field of each type. - foreach($typeArray as $k=>$v) + foreach($this->typeArray as $k=>$v) { $this->ue->user_extended_add($k, ucfirst($k), $v ); } @@ -63,260 +65,25 @@ public function testGetStructure() { $result = $this->ue->getStructure(); - $expected = - array ( - 'user_text' => - array ( - 'user_extended_struct_id' => '1', - 'user_extended_struct_name' => 'text', - 'user_extended_struct_text' => 'Text', - 'user_extended_struct_type' => '1', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '0', - 'user_extended_struct_parent' => '0', - ), - 'user_radio' => - array ( - 'user_extended_struct_id' => '2', - 'user_extended_struct_name' => 'radio', - 'user_extended_struct_text' => 'Radio', - 'user_extended_struct_type' => '2', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '1', - 'user_extended_struct_parent' => '0', - ), - 'user_dropdown' => - array ( - 'user_extended_struct_id' => '3', - 'user_extended_struct_name' => 'dropdown', - 'user_extended_struct_text' => 'Dropdown', - 'user_extended_struct_type' => '3', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '2', - 'user_extended_struct_parent' => '0', - ), - 'user_db field' => - array ( - 'user_extended_struct_id' => '4', - 'user_extended_struct_name' => 'db field', - 'user_extended_struct_text' => 'Db field', - 'user_extended_struct_type' => '4', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '3', - 'user_extended_struct_parent' => '0', - ), - 'user_textarea' => - array ( - 'user_extended_struct_id' => '5', - 'user_extended_struct_name' => 'textarea', - 'user_extended_struct_text' => 'Textarea', - 'user_extended_struct_type' => '5', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '4', - 'user_extended_struct_parent' => '0', - ), - 'user_integer' => - array ( - 'user_extended_struct_id' => '6', - 'user_extended_struct_name' => 'integer', - 'user_extended_struct_text' => 'Integer', - 'user_extended_struct_type' => '6', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '5', - 'user_extended_struct_parent' => '0', - ), - 'user_date' => - array ( - 'user_extended_struct_id' => '7', - 'user_extended_struct_name' => 'date', - 'user_extended_struct_text' => 'Date', - 'user_extended_struct_type' => '7', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '6', - 'user_extended_struct_parent' => '0', - ), - 'user_language' => - array ( - 'user_extended_struct_id' => '8', - 'user_extended_struct_name' => 'language', - 'user_extended_struct_text' => 'Language', - 'user_extended_struct_type' => '8', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '7', - 'user_extended_struct_parent' => '0', - ), - 'user_list' => - array ( - 'user_extended_struct_id' => '9', - 'user_extended_struct_name' => 'list', - 'user_extended_struct_text' => 'List', - 'user_extended_struct_type' => '9', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '8', - 'user_extended_struct_parent' => '0', - ), - 'user_checkbox' => - array ( - 'user_extended_struct_id' => '10', - 'user_extended_struct_name' => 'checkbox', - 'user_extended_struct_text' => 'Checkbox', - 'user_extended_struct_type' => '10', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '9', - 'user_extended_struct_parent' => '0', - ), - 'user_predefined' => - array ( - 'user_extended_struct_id' => '11', - 'user_extended_struct_name' => 'predefined', - 'user_extended_struct_text' => 'Predefined', - 'user_extended_struct_type' => '11', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '10', - 'user_extended_struct_parent' => '0', - ), - 'user_addon' => - array ( - 'user_extended_struct_id' => '12', - 'user_extended_struct_name' => 'addon', - 'user_extended_struct_text' => 'Addon', - 'user_extended_struct_type' => '12', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '11', - 'user_extended_struct_parent' => '0', - ), - 'user_country' => - array ( - 'user_extended_struct_id' => '13', - 'user_extended_struct_name' => 'country', - 'user_extended_struct_text' => 'Country', - 'user_extended_struct_type' => '13', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '12', - 'user_extended_struct_parent' => '0', - ), - 'user_richtextarea' => - array ( - 'user_extended_struct_id' => '14', - 'user_extended_struct_name' => 'richtextarea', - 'user_extended_struct_text' => 'Richtextarea', - 'user_extended_struct_type' => '14', - 'user_extended_struct_parms' => '', - 'user_extended_struct_values' => '', - 'user_extended_struct_default' => '', - 'user_extended_struct_read' => '0', - 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', - 'user_extended_struct_signup' => '0', - 'user_extended_struct_applicable' => '0', - 'user_extended_struct_order' => '13', - 'user_extended_struct_parent' => '0', - ), - ); - $this->assertEquals($expected, $result); + foreach($this->typeArray as $k=>$v) + { + $key = 'user_'.$k; + $this->assertArrayHasKey($key,$result); + $this->assertEquals($k, $result[$key]['user_extended_struct_name']); + + } } - +/* public function testGetFieldList() { $list = $this->ue->getFieldList(); } - +*/ public function testGetFieldType() { $result = $this->ue->getFieldType('user_radio');