tests: add test to cardinality equals 0

This commit is contained in:
vnmedeiros 2021-09-01 14:50:49 -03:00
parent 8765c458b2
commit ef5ba26f85
1 changed files with 23 additions and 0 deletions

View File

@ -787,5 +787,28 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
$item_metadata_numeric_mult->set_value([10,22,4,4]); $item_metadata_numeric_mult->set_value([10,22,4,4]);
$fail = $item_metadata_numeric_mult->validate(); $fail = $item_metadata_numeric_mult->validate();
$this->assertFalse($fail); $this->assertFalse($fail);
$metadatum_numeric_multiple = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'Numeric important meta',
'description' => 'and its description',
'collection_id' => $this->collection->get_id(),
'metadata_type' => 'Tainacan\Metadata_Types\Numeric',
'status' => 'publish',
'multiple' => 'yes',
'cardinality' => 0
),
true
);
$item_metadata_numeric_mult = new Item_Metadata_Entity($this->item, $metadatum_numeric_multiple);
$item_metadata_numeric_mult->set_value([10,22,4]);
$ok = $item_metadata_numeric_mult->validate();
$this->assertTrue($ok);
$item_metadata_numeric_mult->set_value([10,22,4,4]);
$fail = $item_metadata_numeric_mult->validate();
$this->assertTrue($fail);
} }
} }