fix: indentations

This commit is contained in:
vnmedeiros 2021-04-09 11:20:17 -03:00
parent 4a35a8a960
commit a7ff08dbf6
1 changed files with 282 additions and 282 deletions

View File

@ -37,152 +37,152 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
$this->item = $i;
}
/**
* Teste da insercao de um metadado simples sem o tipo
*/
function test_add() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
/**
* Teste da insercao de um metadado simples sem o tipo
*/
function test_add() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'test',
'description' => 'No description',
),
true
);
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'test',
'description' => 'No description',
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$test = $Tainacan_Metadata->fetch($metadatum->get_id());
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste title',
'description' => 'item description',
'collection' => $collection
),
true
);
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$item = $Tainacan_Items->fetch($i->get_id());
$test = $Tainacan_Metadata->fetch($metadatum->get_id());
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste title',
'description' => 'item description',
'collection' => $collection
),
true
);
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$item = $Tainacan_Items->fetch($i->get_id());
$item_metadata = new Item_Metadata_Entity($item, $test);
$item_metadata->set_value('teste_value');
$item_metadata = new Item_Metadata_Entity($item, $test);
$item_metadata->set_value('teste_value');
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$this->assertEquals('teste_value', $item_metadata->get_value());
}
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$this->assertEquals('teste_value', $item_metadata->get_value());
}
/**
* Teste da insercao de um metadado simples com o tipo
*/
function test_required(){
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
/**
* Teste da insercao de um metadado simples com o tipo
*/
function test_required(){
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste',
'description' => 'No description',
),
true
);
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste',
'description' => 'No description',
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'required' => 'yes',
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'required' => 'yes',
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$test = $Tainacan_Metadata->fetch($metadatum->get_id());
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'status' => 'publish',
'description' => 'adasdasdsa',
'collection' => $collection
),
true
);
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$item = $Tainacan_Items->fetch($i->get_id());
$item_metadata = new Item_Metadata_Entity($item, $test);
// false because its required
$this->assertFalse($item_metadata->validate());
$item_metadata->set_value('teste_value');
$this->assertTrue($item_metadata->validate());
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$this->assertEquals('teste_value', $item_metadata->get_value());
}
function test_collection_key(){
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$test = $Tainacan_Metadata->fetch($metadatum->get_id());
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'status' => 'publish',
'description' => 'adasdasdsa',
'collection' => $collection
),
true
);
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$item = $Tainacan_Items->fetch($i->get_id());
$item_metadata = new Item_Metadata_Entity($item, $test);
// false because its required
$this->assertFalse($item_metadata->validate());
$item_metadata->set_value('teste_value');
$this->assertTrue($item_metadata->validate());
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$this->assertEquals('teste_value', $item_metadata->get_value());
}
function test_collection_key(){
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste',
'description' => 'No description',
),
true
);
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste',
'description' => 'No description',
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'collection_key' => 'yes',
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$metadatum = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'collection_key' => 'yes',
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'description' => 'adasdasdsa',
'collection' => $collection,
'status' => 'publish'
),
true
);
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'description' => 'adasdasdsa',
'collection' => $collection,
'status' => 'publish'
),
true
);
$i2 = $this->tainacan_entity_factory->create_entity(
'item',
@ -194,121 +194,121 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
),
true
);
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$value = 'teste_val';
$item_metadata = new Item_Metadata_Entity($i, $metadatum);
$item_metadata->set_value($value);
$value = 'teste_val';
$item_metadata = new Item_Metadata_Entity($i, $metadatum);
$item_metadata->set_value($value);
$this->assertTrue($item_metadata->validate());
$this->assertTrue($item_metadata->validate());
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$item_metadata->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata);
$n_item_metadata = new Item_Metadata_Entity($i, $metadatum);
$n_item_metadata->set_value($value);
$n_item_metadata = new Item_Metadata_Entity($i, $metadatum);
$n_item_metadata->set_value($value);
$this->assertTrue($n_item_metadata->validate(), 'trying to validate the same item with same value should be ok');
$n_item_metadata2 = new Item_Metadata_Entity($i2, $metadatum);
$n_item_metadata2->set_value($value);
$this->assertFalse($n_item_metadata2->validate(), 'Collection key should not validate another item metadatada with the same value');
}
function test_fetch(){
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
}
function test_fetch(){
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste',
'description' => 'No description',
),
true
);
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste',
'description' => 'No description',
),
true
);
$this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'status' => 'publish',
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
$this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadado',
'description' => 'descricao',
'collection' => $collection,
'status' => 'publish',
'metadata_type' => 'Tainacan\Metadata_Types\Text',
),
true
);
//$test = $Tainacan_Metadata->fetch($metadatum->get_id());
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'description' => 'adasdasdsa',
'collection' => $collection
),
true
);
//$test = $Tainacan_Metadata->fetch($metadatum->get_id());
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'description' => 'adasdasdsa',
'collection' => $collection
),
true
);
$item_metadatas = $Tainacan_Item_Metadata->fetch($i, 'OBJECT');
$item_metadatas = $Tainacan_Item_Metadata->fetch($i, 'OBJECT');
$names = [];
foreach ($item_metadatas as $item_metadata) {
$names[] = $item_metadata->get_metadatum()->get_name();
}
$this->assertTrue(is_array($item_metadatas));
$names = [];
foreach ($item_metadatas as $item_metadata) {
$names[] = $item_metadata->get_metadatum()->get_name();
}
$this->assertTrue(is_array($item_metadatas));
// notice for repository metadata
$this->assertEquals(3, sizeof($item_metadatas));
//first 2 metadata are repository metadata
$this->assertTrue( in_array('metadado', $names) );
// notice for repository metadata
$this->assertEquals(3, sizeof($item_metadatas));
//first 2 metadata are repository metadata
$this->assertTrue( in_array('metadado', $names) );
}
function test_metadata_text_textarea() {
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste'
),
true
$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
);
'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',
),
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',
),
true
);
$metadatum_textarea = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadadoTextarea',
'description' => 'descricao',
'collection_id' => $collection->get_id(),
'metadata_type' => 'Tainacan\Metadata_Types\Textarea',
),
true
'metadatum',
array(
'name' => 'metadadoTextarea',
'description' => 'descricao',
'collection_id' => $collection->get_id(),
'metadata_type' => 'Tainacan\Metadata_Types\Textarea',
),
true
);
$value_text = 'GOOGLE: www.google.com';
@ -335,87 +335,87 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
$this->assertEquals($item_metadata_textarea->get_value_as_html(), $badFormatted_HTML ."</p>");
}
/**
* @group test_item_metadata_has_value
*/
/**
* @group test_item_metadata_has_value
*/
function test_item_metadata_has_value() {
$test_value = 'has_value';
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste'
),
true
);
$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
);
$i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'item teste',
'description' => 'description',
'collection' => $collection,
'status' => 'publish'
),
true
);
$metadatum_textarea = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadadoTextarea',
'description' => 'descricao',
'collection_id' => $collection->get_id(),
'metadata_type' => 'Tainacan\Metadata_Types\Textarea',
),
true
);
$metadatum_textarea = $this->tainacan_entity_factory->create_entity(
'metadatum',
array(
'name' => 'metadadoTextarea',
'description' => 'descricao',
'collection_id' => $collection->get_id(),
'metadata_type' => 'Tainacan\Metadata_Types\Textarea',
),
true
);
$value_textarea = '';
$item_metadata_textarea = new Item_Metadata_Entity($i, $metadatum_textarea);
$item_metadata_textarea->set_value($value_textarea);
$value_textarea = '';
$item_metadata_textarea = new Item_Metadata_Entity($i, $metadatum_textarea);
$item_metadata_textarea->set_value($value_textarea);
$item_metadata_textarea->validate();
$item_metadata_textarea = $Tainacan_Item_Metadata->insert($item_metadata_textarea);
$item_metadata_textarea->validate();
$item_metadata_textarea = $Tainacan_Item_Metadata->insert($item_metadata_textarea);
$this->assertFalse($item_metadata_textarea->has_value());
$this->assertFalse($item_metadata_textarea->has_value());
$item_metadata_textarea->set_value($test_value);
$item_metadata_textarea->validate();
$item_metadata_textarea = $Tainacan_Item_Metadata->insert($item_metadata_textarea);
$item_metadata_textarea->set_value($test_value);
$item_metadata_textarea->validate();
$item_metadata_textarea = $Tainacan_Item_Metadata->insert($item_metadata_textarea);
$this->assertTrue($item_metadata_textarea->has_value());
$this->assertTrue($item_metadata_textarea->has_value());
$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
);
$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 Item_Metadata_Entity($i, $metadatum_text);
$item_metadata_text = new Item_Metadata_Entity($i, $metadatum_text);
$item_metadata_text->set_value([ $value_textarea ]);
$item_metadata_text->set_value([ $value_textarea ]);
$item_metadata_text->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata_text);
$item_metadata_text->validate();
$item_metadata = $Tainacan_Item_Metadata->insert($item_metadata_text);
$this->assertFalse($item_metadata->has_value());
$this->assertFalse($item_metadata->has_value());
$item_metadata_text->set_value([ $test_value ]);
$item_metadata_text->validate();
$item_metadata_text = $Tainacan_Item_Metadata->insert($item_metadata_text);
$item_metadata_text->validate();
$item_metadata_text = $Tainacan_Item_Metadata->insert($item_metadata_text);
$this->assertTrue($item_metadata_text->has_value());
}
$this->assertTrue($item_metadata_text->has_value());
}
function test_numeric_metadata_html() {
// Simple numeric metadata