diff --git a/.gitignore b/.gitignore index f21b2c6..a7d0ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /_devel_/ /js/*.js +/clover.xml # Composer stuff /auth.json diff --git a/lib/.gitignore b/lib/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/lib/Frs/FieldDefinition.php b/lib/Frs/FieldDefinition.php new file mode 100644 index 0000000..011efdc --- /dev/null +++ b/lib/Frs/FieldDefinition.php @@ -0,0 +1,39 @@ +field_data = json_decode($field_data_json, true); + } + + public function getFieldData() + { + return $this->field_data; + } + + public function getGroups() + { + $by_group = array(); + foreach ($this->field_data['groups'] as $id=>$group) { + $by_group[$group] = array( + 'group_name' => $group, + 'fields' => array(), + ); + } + return $by_group; + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..3ed1fba --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,27 @@ + + + + + + ./ + ./lib/ + + ./tests/ + ./vendor + + + + + + + + + + ./tests/ + + + diff --git a/prep_form.php b/prep_form.php index 2edeee0..e0e964f 100644 --- a/prep_form.php +++ b/prep_form.php @@ -1,5 +1,7 @@ $group) { - $by_group[$group] = array( - 'group_name' => $group, - 'fields' => array(), - ); -} +$fd = new FieldDefinition($action); +$field_data = $fd->getFieldData(); +$by_group = $fd->getGroups(); // Assign fields to groups, fill in (default) values foreach ($field_data['fields'] as $key=>$meta) { diff --git a/prep_mail.php b/prep_mail.php index c59561a..82740d6 100644 --- a/prep_mail.php +++ b/prep_mail.php @@ -1,5 +1,7 @@ getFieldData(); $fields = array(); diff --git a/tests/FieldDefinitionTest.php b/tests/FieldDefinitionTest.php new file mode 100644 index 0000000..17730cf --- /dev/null +++ b/tests/FieldDefinitionTest.php @@ -0,0 +1,13 @@ +assertTrue(true); + } +}