From d7637bde12b9181f83ecd551790984239dd5e4eb Mon Sep 17 00:00:00 2001 From: Rodrigo de Oliveira Date: Tue, 6 Apr 2021 09:41:32 -0300 Subject: [PATCH] finishes first tests for taxonomy meta html --- .../taxonomy/class-tainacan-taxonomy.php | 3 +-- tests/__test-bulkedit.php | 12 ------------ tests/test-category-metadatum-types.php | 8 -------- tests/test-item-metadata.php | 16 +++++++++++++++- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php b/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php index 031ca13c2..d777d08e0 100644 --- a/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php +++ b/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php @@ -323,7 +323,6 @@ class Taxonomy extends Metadata_Type { } return $valid; - } /** @@ -332,7 +331,7 @@ class Taxonomy extends Metadata_Type { * @return string The HTML representation of the value, containing one or multiple terms, separated by comma, linked to term page */ public function get_value_as_html(Item_Metadata_Entity $item_metadata) { - $value = $item_metadata->get_value(); + $value = $item_metadata->get_value(); $return = ''; if ( $item_metadata->is_multiple() ) { diff --git a/tests/__test-bulkedit.php b/tests/__test-bulkedit.php index 3db4df885..c30e15080 100644 --- a/tests/__test-bulkedit.php +++ b/tests/__test-bulkedit.php @@ -1154,8 +1154,6 @@ class BulkEdit extends TAINACAN_UnitApiTestCase { ]); $this->assertEquals(7, $bulk->count_posts()); - - } /** @@ -1206,8 +1204,6 @@ class BulkEdit extends TAINACAN_UnitApiTestCase { $item_id = $bulk->get_item_id_by_index(30); $this->assertFalse($item_id); - - } function test_set_multiple_tax_meta() { @@ -1228,14 +1224,8 @@ class BulkEdit extends TAINACAN_UnitApiTestCase { 'collection_id' => $this->collection->get_id() ]); - - - $bulk->set_value($this->category, ['super', 'dooper']); - - - $items = $Tainacan_Items->fetch([ 'tax_query' => [ [ @@ -1342,6 +1332,4 @@ class BulkEdit extends TAINACAN_UnitApiTestCase { $this->assertEquals(5, $items->found_posts); } - - } diff --git a/tests/test-category-metadatum-types.php b/tests/test-category-metadatum-types.php index b0de80955..37c7d7bef 100644 --- a/tests/test-category-metadatum-types.php +++ b/tests/test-category-metadatum-types.php @@ -79,10 +79,6 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase { true ); - - - - $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -237,10 +233,6 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase { ); $this->assertContains($tax3->get_db_identifier(), get_object_taxonomies($collection->get_db_identifier()), 'Taxonommy used by repository level metadatum must be assigned to all collections post types'); - - - - } function test_relate_taxonomy_match() { diff --git a/tests/test-item-metadata.php b/tests/test-item-metadata.php index 75c1a1356..5bafc6353 100644 --- a/tests/test-item-metadata.php +++ b/tests/test-item-metadata.php @@ -671,7 +671,16 @@ class Item_Metadata extends TAINACAN_UnitTestCase { true ); - $meta = $this->tainacan_entity_factory->create_entity( + $term = $this->tainacan_entity_factory->create_entity( + 'term', + array( + 'taxonomy' => $taxonomy->get_db_identifier(), + 'name' => 'first term from my tax', + ), + true + ); + + $taxonomy_meta = $this->tainacan_entity_factory->create_entity( 'metadatum', array( 'name' => 'My tax meta', @@ -684,5 +693,10 @@ class Item_Metadata extends TAINACAN_UnitTestCase { ), true ); + + $item_taxonomy_metadata = new \Tainacan\Entities\Item_Metadata_Entity($this->item, $taxonomy_meta); + $item_taxonomy_metadata->set_value($term); + $item_taxonomy_metadata->validate(); + $this->assertEquals($item_taxonomy_metadata->get_value_as_html(), "first term from my tax"); } } \ No newline at end of file