2017-11-09 11:01:11 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Class TestCollections
|
|
|
|
*
|
|
|
|
* @package Test_Tainacan
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sample test case.
|
|
|
|
*/
|
2017-11-13 16:03:04 +00:00
|
|
|
class Test_Metadata extends WP_UnitTestCase {
|
2017-11-09 11:01:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Teste da insercao de um metadado simples sem o tipo
|
|
|
|
*/
|
|
|
|
function test_add() {
|
2017-11-13 16:03:04 +00:00
|
|
|
global $Tainacan_Collections, $Tainacan_Metadatas;
|
2017-11-09 11:01:11 +00:00
|
|
|
|
2017-11-13 16:03:04 +00:00
|
|
|
$collection = new Tainacan_Collection();
|
2017-11-09 11:01:11 +00:00
|
|
|
$metadata = new Tainacan_Metadata();
|
|
|
|
|
|
|
|
$collection->set_name('teste');
|
2017-11-13 16:03:04 +00:00
|
|
|
$collection = $Tainacan_Collections->insert($collection);
|
2017-11-09 11:01:11 +00:00
|
|
|
|
|
|
|
//setando os valores na classe do metadado
|
2017-11-09 15:51:16 +00:00
|
|
|
$metadata->set_name('metadado');
|
|
|
|
$metadata->set_description('descricao');
|
2017-11-12 23:14:47 +00:00
|
|
|
$metadata->set_collection( $collection );
|
2017-11-09 11:01:11 +00:00
|
|
|
|
|
|
|
//inserindo o metadado
|
2017-11-12 23:14:47 +00:00
|
|
|
$metadata = $Tainacan_Metadatas->insert($metadata);
|
2017-11-09 11:01:11 +00:00
|
|
|
|
2017-11-12 23:14:47 +00:00
|
|
|
$test = $Tainacan_Metadatas->get_metadata_by_id($metadata->get_id());
|
2017-11-09 11:01:11 +00:00
|
|
|
|
2017-11-09 15:51:16 +00:00
|
|
|
$this->assertEquals($test->get_name(), 'metadado');
|
|
|
|
$this->assertEquals($test->get_description(), 'descricao');
|
2017-11-12 23:14:47 +00:00
|
|
|
$this->assertEquals($test->get_collection_id(), $collection->get_id());
|
2017-11-09 11:01:11 +00:00
|
|
|
|
|
|
|
}
|
2017-11-09 15:51:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Teste da insercao de um metadado simples com o tipo
|
|
|
|
*/
|
|
|
|
function teste_add_type(){
|
2017-11-13 16:03:04 +00:00
|
|
|
global $Tainacan_Collections, $Tainacan_Metadatas;
|
2017-11-09 15:51:16 +00:00
|
|
|
|
2017-11-13 16:03:04 +00:00
|
|
|
$collection = new Tainacan_Collection();
|
2017-11-09 15:51:16 +00:00
|
|
|
$metadata = new Tainacan_Metadata();
|
|
|
|
$type = new Tainacan_Text_Field_Type();
|
|
|
|
|
|
|
|
$collection->set_name('teste');
|
2017-11-13 16:03:04 +00:00
|
|
|
$collection = $Tainacan_Collections->insert($collection);
|
2017-11-09 15:51:16 +00:00
|
|
|
|
|
|
|
//setando os valores na classe do metadado
|
|
|
|
$metadata->set_name('metadado');
|
2017-11-12 23:14:47 +00:00
|
|
|
$metadata->set_collection_id( $collection->get_id() );
|
2017-11-14 18:44:04 +00:00
|
|
|
$metadata->set_field_type_object( $type );
|
2017-11-09 15:51:16 +00:00
|
|
|
|
2017-11-12 23:14:47 +00:00
|
|
|
|
2017-11-09 15:51:16 +00:00
|
|
|
//inserindo o metadado
|
2017-11-12 23:14:47 +00:00
|
|
|
$metadata = $Tainacan_Metadatas->insert($metadata);
|
2017-11-09 15:51:16 +00:00
|
|
|
|
2017-11-12 23:14:47 +00:00
|
|
|
$test = $Tainacan_Metadatas->get_metadata_by_id($metadata->get_id());
|
2017-11-09 15:51:16 +00:00
|
|
|
|
|
|
|
$this->assertEquals($test->get_name(), 'metadado');
|
2017-11-12 23:14:47 +00:00
|
|
|
$this->assertEquals($test->get_collection_id(), $collection->get_id());
|
2017-11-14 18:44:04 +00:00
|
|
|
$this->assertEquals($test->get_field_type(), 'Tainacan_Text_Field_Type');
|
|
|
|
$this->assertEquals($test->get_field_type_object(), $type);
|
2017-11-09 15:51:16 +00:00
|
|
|
}
|
2017-11-09 11:01:11 +00:00
|
|
|
}
|