create test to verify if has_value method returns true if an empty value exists for multi value metadata (#222)

This commit is contained in:
Eduardo Humberto 2019-04-12 16:32:33 -03:00
parent f74a40f25e
commit a57e2382c5
1 changed files with 49 additions and 0 deletions

View File

@ -304,4 +304,53 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
$this->assertEquals($item_metadata_text->get_value_as_html(), $response_text); $this->assertEquals($item_metadata_text->get_value_as_html(), $response_text);
$this->assertEquals($item_metadata_textarea->get_value_as_html(), $response_textarea); $this->assertEquals($item_metadata_textarea->get_value_as_html(), $response_textarea);
} }
/**
* @group test_item_metadata_multiple_has_value
*/
function test_item_metadata_multiple_has_value() {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste'
),
true
);
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'description' => 'description',
'collection' => $collection,
'status' => 'publish'
),
true
);
$metadatum_text = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadadoText',
'description' => 'descricao',
'collection_id' => $collection->get_id(),
'metadata_type' => 'Tainacan\Metadata_Types\Text',
'multiple' => 'yes'
),
true
);
$item_metadata_text = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatum_text);
$item_metadata_text->set_value([
''
]);
$item_metadata_text->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata_text);
$this->assertTrue($item_metadata->has_value());
}
} }