diff --git a/src/classes/repositories/class-tainacan-metadatas.php b/src/classes/repositories/class-tainacan-metadatas.php index df0c67d8c..1dbb16674 100644 --- a/src/classes/repositories/class-tainacan-metadatas.php +++ b/src/classes/repositories/class-tainacan-metadatas.php @@ -13,16 +13,7 @@ class Metadatas extends Repository { public $entities_type = '\Tainacan\Entities\Metadata'; protected $default_metadata = 'default'; - public $field_types = [ - '\Tainacan\Filter_Types\Checkbox', - '\Tainacan\Filter_Types\Date', - '\Tainacan\Filter_Types\Numeric', - '\Tainacan\Filter_Types\Radio', - '\Tainacan\Filter_Types\Relationship', - '\Tainacan\Filter_Types\Selectbox', - '\Tainacan\Filter_Types\Text', - '\Tainacan\Filter_Types\Textatrea', - ]; + public $field_types = []; public function get_map() { return apply_filters('tainacan-get-map', [ @@ -309,7 +300,7 @@ class Metadatas extends Repository { /** * fetch all registered field type classes * - * @return Array of Entities\Filter_Types\Filter_Type objects + * @return array of Entities\Field_Types\Field_Type objects */ public function fetch_field_types(){ diff --git a/src/classes/tainacan-creator.php b/src/classes/tainacan-creator.php index 5a45824b1..2a7d3b798 100644 --- a/src/classes/tainacan-creator.php +++ b/src/classes/tainacan-creator.php @@ -60,6 +60,16 @@ $Tainacan_Item_Metadata = new \Tainacan\Repositories\Item_Metadata(); global $Tainacan_Metadatas; $Tainacan_Metadatas = new \Tainacan\Repositories\Metadatas(); +//register field types +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Text'); +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Textarea'); +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Date'); +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Numeric'); +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Selectbox'); +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Relationship'); +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Radio'); +$Tainacan_Metadatas->register_field_type('\Tainacan\Field_type\Checkbox'); + global $Tainacan_Filters; $Tainacan_Filters = new \Tainacan\Repositories\Filters(); diff --git a/tests/test-metadata.php b/tests/test-metadata.php index 4d7f46e5e..710454734 100644 --- a/tests/test-metadata.php +++ b/tests/test-metadata.php @@ -1,7 +1,6 @@ assertEquals($test->get_field_type_object(), $type); } - + /** + * test if parent metadata are visible for children collection + */ function test_hierarchy_metadata(){ global $Tainacan_Metadatas; @@ -164,4 +165,21 @@ class Metadata extends TAINACAN_UnitTestCase { $retrieve_metadata = $Tainacan_Metadatas->fetch_by_collection( $collection_son, [], 'OBJECT' ); $this->assertEquals( 4, sizeof( $retrieve_metadata ) ); } + + /** + * test if the defaults types are registered + */ + function test_metadata_field_type(){ + global $Tainacan_Metadatas; + $this->assertEquals( 8, sizeof( $Tainacan_Metadatas->fetch_field_types() ) ); + } + + /** + * test if the defaults types are registered + */ +// function test_metadata_field_type_insert(){ +// global $Tainacan_Metadatas; +// $class = new \; +// $this->assertEquals( 9, sizeof( $Tainacan_Metadatas->fetch_field_types() ) ); +// } } \ No newline at end of file