Now factories are used in all tests

This commit is contained in:
weryques 2017-12-04 16:20:49 -02:00
parent 0b00392f7a
commit 3b0d738fc2
6 changed files with 289 additions and 231 deletions

View File

@ -34,8 +34,10 @@ class Entity_Factory {
$this->entity_type = "\Tainacan\Entities\\$type"; $this->entity_type = "\Tainacan\Entities\\$type";
$type_size = strlen($type); $type_size = strlen($type);
if($type[$type_size-1] == 'y'){ if($type[$type_size-1] == 'y'){
$type[$type_size-1] = 'ies'; $type[$type_size-1] = 'i';
$this->repository_type = "\Tainacan\Repositories\\$type".'es';
} else { } else {
$this->repository_type = "\Tainacan\Repositories\\$type".'s'; $this->repository_type = "\Tainacan\Repositories\\$type".'s';
} }
@ -45,8 +47,14 @@ class Entity_Factory {
if (!empty($args) && $is_validated_and_in_db) { if (!empty($args) && $is_validated_and_in_db) {
foreach ($args as $attribute => $content) { foreach ($args as $attribute => $content) {
$set_ = 'set_'.$attribute; if($attribute == 'add_metadata'){
$this->entity->$set_($content); foreach ($content as $in){
$this->entity->$attribute($in[0], $in[1]);
}
} else {
$set_ = 'set_' . $attribute;
$this->entity->$set_( $content );
}
} }
if ($this->entity->validate()) { if ($this->entity->validate()) {
@ -57,15 +65,21 @@ class Entity_Factory {
} elseif (!empty($args) && !$is_validated_and_in_db){ } elseif (!empty($args) && !$is_validated_and_in_db){
foreach ($args as $attribute => $content) { foreach ($args as $attribute => $content) {
$set_ = 'set_'.$attribute; if($attribute == 'add_metadata'){
$this->entity->$set_($content); foreach ($content as $in){
$this->entity->$attribute($in[0], $in[1]);
}
} else {
$set_ = 'set_' . $attribute;
$this->entity->$set_( $content );
}
} }
} elseif (empty($args) && !$is_validated_and_in_db) { } elseif (empty($args) && !$is_validated_and_in_db) {
try { try {
$this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only for test' ); $this->entity->set_description( 'It is only for test' );
} catch (\Error $exception){ } catch (\Exception $exception){
$this->entity->set_title( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_title( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only for test' ); $this->entity->set_description( 'It is only for test' );
} }
@ -74,7 +88,7 @@ class Entity_Factory {
try { try {
$this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_name( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only for test' ); $this->entity->set_description( 'It is only for test' );
} catch (\Error $exception){ } catch (\Exception $exception){
$this->entity->set_title( "$type" . random_int( 0, 10000 ) . " for test" ); $this->entity->set_title( "$type" . random_int( 0, 10000 ) . " for test" );
$this->entity->set_description( 'It is only for test' ); $this->entity->set_description( 'It is only for test' );
} }
@ -89,7 +103,7 @@ class Entity_Factory {
} else { } else {
throw new \InvalidArgumentException( __( 'One or more arguments are invalid.', 'tainacan' ) ); throw new \InvalidArgumentException( __( 'One or more arguments are invalid.', 'tainacan' ) );
} }
} catch (\Error $exception){ } catch (\Exception $exception){
echo($exception->getMessage()); echo($exception->getMessage());
echo($exception->getTraceAsString()); echo($exception->getTraceAsString());
} }

View File

@ -193,7 +193,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
$type = $this->tainacan_field_factory->create_field('text'); $type = $this->tainacan_field_factory->create_field('text');
$metadata = $this->tainacan_entity_factory->create_entity( $this->tainacan_entity_factory->create_entity(
'metadata', 'metadata',
array( array(
'name' => 'metadado', 'name' => 'metadado',

View File

@ -8,96 +8,128 @@ namespace Tainacan\Tests;
* @package Test_Tainacan * @package Test_Tainacan
*/ */
use Tainacan\Entities\Entity; use Tainacan\Entities;
/** /**
* Sample test case. * Sample test case.
*/ */
class Items extends \WP_UnitTestCase { class Items extends TAINACAN_UnitTestCase {
function teste_query(){ function teste_query(){
global $Tainacan_Collections, $Tainacan_Metadatas, $Tainacan_Item_Metadata; $type = $this->tainacan_field_factory->create_field('text');
$type = new \Tainacan\Field_Types\Text(); $collection = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'teste',
'status' => 'publish'
),
true
);
$collection = new \Tainacan\Entities\Collection(); $collection2 = $this->tainacan_entity_factory->create_entity(
$collection2 = new \Tainacan\Entities\Collection(); 'collection',
array(
'name' => 'teste2',
'status' => 'publish'
),
true
);
$collection->set_name('teste'); $metadata = $this->tainacan_entity_factory->create_entity(
$collection->set_status('publish'); 'metadata',
$collection->validate(); array(
$collection = $Tainacan_Collections->insert($collection); 'name' => 'metadado',
$collection2->set_name('teste2'); 'status' => 'publish',
$collection2->set_status('publish'); 'collection' => $collection,
$collection2->validate(); 'field_type_object' => $type
$collection2 = $Tainacan_Collections->insert($collection2); ),
true
);
$metadata = new \Tainacan\Entities\Metadata(); $metadata2 = $this->tainacan_entity_factory->create_entity(
$metadata2 = new \Tainacan\Entities\Metadata(); 'metadata',
$metadata3 = new \Tainacan\Entities\Metadata(); array(
'name' => 'metadado2',
'status' => 'publish',
'collection' => $collection,
'field_type_object' => $type
),
true
);
$metadata->set_name('metadado'); $metadata3 = $this->tainacan_entity_factory->create_entity(
$metadata->set_collection( $collection ); 'metadata',
$metadata->set_status('publish'); array(
$metadata->set_field_type_object( $type ); 'name' => 'metadado3',
$metadata->validate(); 'status' => 'publish',
$metadata = $Tainacan_Metadatas->insert($metadata); 'collection' => $collection,
$metadata2->set_name('metadado2'); 'field_type_object' => $type
$metadata2->set_collection( $collection2 ); ),
$metadata2->set_status('publish'); true
$metadata2->set_field_type_object( $type ); );
$metadata2->validate();
$metadata2 = $Tainacan_Metadatas->insert($metadata2);
$metadata3->set_name('metadado3');
$metadata3->set_collection( $collection2 );
$metadata3->set_status('publish');
$metadata3->set_field_type_object( $type );
$metadata3->validate();
$metadata3 = $Tainacan_Metadatas->insert($metadata3);
global $Tainacan_Items; global $Tainacan_Items;
$i = new \Tainacan\Entities\Item();
$i->set_title('orange');
$i->set_collection($collection);
$i->add_metadata($metadata, 'value_1');
$i->validate();
/**
* @var \Tainacan\Entities\Item $item
*/
$item = $Tainacan_Items->insert($i);
$item = $Tainacan_Items->fetch($item->get_id()); $i = $this->tainacan_entity_factory->create_entity(
'item',
array(
'title' => 'orange',
'collection' => $collection,
'add_metadata' => [
[$metadata, 'value_1']
]
),
true
);
$item = $Tainacan_Items->fetch($i->get_id());
$meta_test = $item->get_metadata(); $meta_test = $item->get_metadata();
$this->assertTrue( isset($meta_test[$metadata->get_id()]) ); $this->assertTrue( isset($meta_test[$metadata->get_id()]) );
$this->assertTrue( $meta_test[$metadata->get_id()] instanceof \Tainacan\Entities\Item_Metadata_Entity ); $this->assertTrue( $meta_test[$metadata->get_id()] instanceof Entities\Item_Metadata_Entity );
$this->assertEquals( 'value_1', $meta_test[$metadata->get_id()]->get_value()); $this->assertEquals( 'value_1', $meta_test[$metadata->get_id()]->get_value());
$i = new \Tainacan\Entities\Item(); $this->tainacan_entity_factory->create_entity(
$i->set_title('apple'); 'item',
$i->set_collection($collection2); array(
$i->add_metadata($metadata2, 'value_2'); 'title' => 'apple',
$i->add_metadata($metadata3, 'value_2'); 'collection' => $collection2,
$i->validate(); 'add_metadata' => [
$item = $Tainacan_Items->insert($i); [$metadata2, 'value_2'],
[$metadata3, 'value_2']
]
),
true
);
$i = new \Tainacan\Entities\Item(); $this->tainacan_entity_factory->create_entity(
$i->set_title('lemon'); 'item',
$i->set_collection($collection2); array(
$i->add_metadata($metadata2, 'value_2'); 'title' => 'lemon',
$i->add_metadata($metadata2, 'value_3'); // if we set twice, value is overridden 'collection' => $collection2,
$i->add_metadata($metadata3, 'value_3'); 'add_metadata' => [
$i->validate(); [$metadata2, 'value_2'],
$item = $Tainacan_Items->insert($i); [$metadata2, 'value_3'],
[$metadata3, 'value_3']
]
),
true
);
$i = new \Tainacan\Entities\Item(); $this->tainacan_entity_factory->create_entity(
$i->set_title('pinapple'); 'item',
$i->set_collection($collection2); array(
$i->add_metadata($metadata2, 'value_3'); 'title' => 'pineapple',
$i->add_metadata($metadata3, 'value_6'); 'collection' => $collection2,
$i->validate(); 'add_metadata' => [
$item = $Tainacan_Items->insert($i); [$metadata2, 'value_3'],
[$metadata3, 'value_6']
]
),
true
);
// should return all 4 items // should return all 4 items
$test_query = $Tainacan_Items->fetch([]); $test_query = $Tainacan_Items->fetch([]);
@ -116,15 +148,15 @@ class Items extends \WP_UnitTestCase {
$this->assertEquals(1,$test_query->post_count); $this->assertEquals(1,$test_query->post_count);
$test_query->the_post(); $test_query->the_post();
$item = new \Tainacan\Entities\Item( get_the_ID() ); $item1 = new Entities\Item( get_the_ID() );
$this->assertEquals('orange', $item->get_title() ); $this->assertEquals('orange', $item1->get_title() );
$test_query = $Tainacan_Items->fetch(['title' => 'orange']); $test_query = $Tainacan_Items->fetch(['title' => 'orange']);
$test_query->the_post(); $test_query->the_post();
$item = new \Tainacan\Entities\Item( get_the_ID() ); $item2 = new Entities\Item( get_the_ID() );
$this->assertEquals(1, $test_query->post_count); $this->assertEquals(1, $test_query->post_count);
$this->assertEquals('orange', $item->get_title()); $this->assertEquals('orange', $item2->get_title());
// should return the other 3 items // should return the other 3 items
$test_query = $Tainacan_Items->fetch([], $collection2); $test_query = $Tainacan_Items->fetch([], $collection2);
@ -132,16 +164,10 @@ class Items extends \WP_UnitTestCase {
$test_query = $Tainacan_Items->fetch(['title' => 'apple']); $test_query = $Tainacan_Items->fetch(['title' => 'apple']);
$test_query->the_post(); $test_query->the_post();
$item = new \Tainacan\Entities\Item( get_the_ID() ); $item3 = new Entities\Item( get_the_ID() );
$this->assertEquals(1, $test_query->post_count); $this->assertEquals(1, $test_query->post_count);
$this->assertEquals('apple', $item->get_title()); $this->assertEquals('apple', $item3->get_title());
$apple_meta = $item->get_metadata();
$this->assertEquals(2, sizeof( $apple_meta ));
$apple_meta_values = [];
foreach ($apple_meta as $am) {
$this->assertEquals('value_2', $am->get_value());
}
// should return 1 item // should return 1 item
$test_query = $Tainacan_Items->fetch([ $test_query = $Tainacan_Items->fetch([

View File

@ -2,7 +2,6 @@
namespace Tainacan\Tests; namespace Tainacan\Tests;
use Tainacan\Entities\Log; use Tainacan\Entities\Log;
use Tainacan\Entities\Collection;
/** /**
* Class TestCollections * Class TestCollections
@ -13,7 +12,7 @@ use Tainacan\Entities\Collection;
/** /**
* Sample test case. * Sample test case.
*/ */
class Logs extends \WP_UnitTestCase { class Logs extends TAINACAN_UnitTestCase {
/** /**
@ -22,19 +21,18 @@ class Logs extends \WP_UnitTestCase {
function test_add() { function test_add() {
global $Tainacan_Logs; global $Tainacan_Logs;
$log = new Log(); $log = $this->tainacan_entity_factory->create_entity(
'log',
//setando os valores na classe do tainacan array(
$log->set_title('blame someone'); 'title' => 'blame someone',
$log->set_description('someone did that'); 'description' => 'someone did that'
),
true
);
$user_id = get_current_user_id(); $user_id = get_current_user_id();
$blog_id = get_current_blog_id(); $blog_id = get_current_blog_id();
//inserindo
$log->validate();
$log = $Tainacan_Logs->insert($log);
//retorna a taxonomia //retorna a taxonomia
$test = $Tainacan_Logs->fetch($log->get_id()); $test = $Tainacan_Logs->fetch($log->get_id());
@ -43,14 +41,17 @@ class Logs extends \WP_UnitTestCase {
$this->assertEquals( $user_id, $test->get_user_id() ); $this->assertEquals( $user_id, $test->get_user_id() );
$this->assertEquals( $blog_id, $test->get_blog_id() ); $this->assertEquals( $blog_id, $test->get_blog_id() );
$value = new Collection(); $value = $this->tainacan_entity_factory->create_entity(
$value->set_name('testeLogs'); 'collection',
$value->set_description('adasdasdsa123'); array(
$value->set_default_order('DESC'); 'name' => 'testeLogs',
'description' => 'adasdasdsa123',
'default_order' => 'DESC'
),
true
);
global $Tainacan_Collections; global $Tainacan_Collections;
$value->validate();
$value = $Tainacan_Collections->insert($value);
$value->set_name('new_testeLogs'); $value->set_name('new_testeLogs');
$value->validate(); $value->validate();

View File

@ -11,63 +11,68 @@ namespace Tainacan\Tests;
/** /**
* Metadata test case. * Metadata test case.
*/ */
class Metadata extends \WP_UnitTestCase { class Metadata extends TAINACAN_UnitTestCase {
/** /**
* Test insert a regular metadata with type * Test insert a regular metadata with type
*/ */
function test_add() { function test_add() {
global $Tainacan_Collections, $Tainacan_Metadatas; global $Tainacan_Metadatas;
$collection = new \Tainacan\Entities\Collection(); $collection = $this->tainacan_entity_factory->create_entity(
$metadata = new \Tainacan\Entities\Metadata(); 'collection',
$type = new \Tainacan\Field_Types\Text(); array(
'name' => 'teste'
),
true
);
$collection->set_name('teste'); $type = $this->tainacan_field_factory->create_field('text');
$collection->validate();
$collection = $Tainacan_Collections->insert($collection);
//setando os valores na classe do metadado $metadata = $this->tainacan_entity_factory->create_entity(
$metadata->set_name('metadado'); 'metadata',
$metadata->set_description('descricao'); array(
$metadata->set_collection( $collection ); 'name' => 'metadado',
$metadata->set_field_type_object( $type ); 'description' => 'descricao',
'collection' => $collection,
//inserindo o metadado 'field_type_object' => $type
$metadata->validate(); ),
$metadata = $Tainacan_Metadatas->insert($metadata); true
);
$test = $Tainacan_Metadatas->fetch($metadata->get_id()); $test = $Tainacan_Metadatas->fetch($metadata->get_id());
$this->assertEquals($test->get_name(), 'metadado'); $this->assertEquals($test->get_name(), 'metadado');
$this->assertEquals($test->get_description(), 'descricao'); $this->assertEquals($test->get_description(), 'descricao');
$this->assertEquals($test->get_collection_id(), $collection->get_id()); $this->assertEquals($test->get_collection_id(), $collection->get_id());
} }
/** /**
* Test insert a regular metadata with type * Test insert a regular metadata with type
*/ */
function test_add_type(){ function test_add_type(){
global $Tainacan_Collections, $Tainacan_Metadatas; global $Tainacan_Metadatas;
$collection = new \Tainacan\Entities\Collection(); $collection = $this->tainacan_entity_factory->create_entity(
$metadata = new \Tainacan\Entities\Metadata(); 'collection',
$type = new \Tainacan\Field_Types\Text(); array(
'name' => 'teste'
),
true
);
$collection->set_name('teste'); $type = $this->tainacan_field_factory->create_field('text');
$collection->validate();
$collection = $Tainacan_Collections->insert($collection);
//setando os valores na classe do metadado $metadata = $this->tainacan_entity_factory->create_entity(
$metadata->set_name('metadado'); 'metadata',
$metadata->set_collection_id( $collection->get_id() ); array(
$metadata->set_field_type_object( $type ); 'name' => 'metadado',
'description' => 'descricao',
'collection_id' => $collection->get_id(),
//inserindo o metadado 'field_type_object' => $type
$metadata->validate(); ),
$metadata = $Tainacan_Metadatas->insert($metadata); true
);
$test = $Tainacan_Metadatas->fetch($metadata->get_id()); $test = $Tainacan_Metadatas->fetch($metadata->get_id());
@ -79,73 +84,84 @@ class Metadata extends \WP_UnitTestCase {
function test_hierarchy_metadata(){ function test_hierarchy_metadata(){
global $Tainacan_Collections, $Tainacan_Metadatas; global $Tainacan_Metadatas;
$metadata_default = new \Tainacan\Entities\Metadata(); $type = $this->tainacan_field_factory->create_field('text');
$collection_grandfather = new \Tainacan\Entities\Collection();
$metadata_grandfather = new \Tainacan\Entities\Metadata();
$collection_father = new \Tainacan\Entities\Collection();
$metadata_father = new \Tainacan\Entities\Metadata();
$collection_son = new \Tainacan\Entities\Collection();
$metadata_son = new \Tainacan\Entities\Metadata();
$type = new \Tainacan\Field_Types\Text();
//creating metadata default $this->tainacan_entity_factory->create_entity(
$metadata_default->set_name('metadata default'); 'metadata',
$metadata_default->set_collection_id( $Tainacan_Metadatas->get_default_metadata_attribute() ); array(
$metadata_default->set_field_type_object( $type ); 'name' => 'metadata default',
$metadata_default->set_status('publish'); 'collection_id' => $Tainacan_Metadatas->get_default_metadata_attribute(),
$metadata_default->validate(); 'field_type_object' => $type,
$Tainacan_Metadatas->insert($metadata_default); 'status' => 'publish'
),
true
);
//creating collection grandfather $collection_grandfather = $this->tainacan_entity_factory->create_entity(
$collection_grandfather->set_name('collection grandfather'); 'collection',
$collection_grandfather->validate(); array(
$collection_grandfather = $Tainacan_Collections->insert($collection_grandfather); 'name' => 'collection grandfather'
),
true
);
//creating metadata grandfather $this->tainacan_entity_factory->create_entity(
$metadata_grandfather->set_name('metadata grandfather'); 'metadata',
$metadata_grandfather->set_collection_id( $collection_grandfather->get_id() ); array(
$metadata_grandfather->set_field_type_object( $type ); 'name' => 'metadata grandfather',
$metadata_grandfather->set_status('publish'); 'collection_id' => $collection_grandfather->get_id(),
$metadata_grandfather->validate(); 'field_type_object' => $type,
$Tainacan_Metadatas->insert($metadata_grandfather); 'status' => 'publish'
),
true
);
//creating collection father $collection_father = $this->tainacan_entity_factory->create_entity(
$collection_father->set_name('collection father'); 'collection',
$collection_father->set_parent( $collection_grandfather->get_id() ); array(
$collection_father->validate(); 'name' => 'collection father',
$collection_father = $Tainacan_Collections->insert( $collection_father ); 'parent' => $collection_grandfather->get_id()
),
true
);
$this->tainacan_entity_factory->create_entity(
'metadata',
array(
'name' => 'metadata father',
'collection_id' => $collection_father->get_id(),
'field_type_object' => $type,
'status' => 'publish'
),
true
);
$collection_son = $this->tainacan_entity_factory->create_entity(
'collection',
array(
'name' => 'collection son',
'parent' => $collection_father->get_id()
),
true
);
$this->assertEquals( $collection_grandfather->get_id(), $collection_father->get_parent() ); $this->assertEquals( $collection_grandfather->get_id(), $collection_father->get_parent() );
//creating metadata father
$metadata_father->set_name('metadata father');
$metadata_father->set_collection_id( $collection_father->get_id() );
$metadata_father->set_field_type_object( $type );
$metadata_father->set_status('publish');
$metadata_father->validate();
$Tainacan_Metadatas->insert($metadata_father);
//creating collection son
$collection_son->set_name('collection son');
$collection_son->set_parent( $collection_father->get_id() );
$collection_son->validate();
$collection_son = $Tainacan_Collections->insert($collection_son);
$this->assertEquals( $collection_father->get_id(), $collection_son->get_parent() ); $this->assertEquals( $collection_father->get_id(), $collection_son->get_parent() );
//creating metadata son $this->tainacan_entity_factory->create_entity(
$metadata_son->set_name('metadata son'); 'metadata',
$metadata_son->set_collection_id( $collection_son->get_id() ); array(
$metadata_son->set_field_type_object( $type ); 'name' => 'metadata son',
$metadata_son->set_status('publish'); 'collection_id' => $collection_son->get_id(),
$metadata_son->validate(); 'field_type_object' => $type,
$Tainacan_Metadatas->insert($metadata_son); 'status' => 'publish'
),
true
);
$retrieve_metadata = $Tainacan_Metadatas->fetch_by_collection( $collection_son, [], 'OBJECT' ); $retrieve_metadata = $Tainacan_Metadatas->fetch_by_collection( $collection_son, [], 'OBJECT' );
$this->assertEquals( 4, sizeof( $retrieve_metadata ) ); $this->assertEquals( 4, sizeof( $retrieve_metadata ) );
} }
} }

View File

@ -11,7 +11,7 @@ namespace Tainacan\Tests;
/** /**
* Sample test case. * Sample test case.
*/ */
class Taxonomies extends \WP_UnitTestCase { class Taxonomies extends TAINACAN_UnitTestCase {
/** /**
@ -20,17 +20,15 @@ class Taxonomies extends \WP_UnitTestCase {
function test_add() { function test_add() {
global $Tainacan_Taxonomies; global $Tainacan_Taxonomies;
$taxonomy = new \Tainacan\Entities\Taxonomy(); $taxonomy = $this->tainacan_entity_factory->create_entity(
'taxonomy',
//setando os valores na classe do tainacan array(
$taxonomy->set_name('genero'); 'name' => 'genero',
$taxonomy->set_description('tipos de musica'); 'description' => 'tipos de musica',
$taxonomy->set_allow_insert('yes'); 'allow_insert' => 'yes'
),
//inserindo true
$taxonomy->validate(); );
$taxonomy = $Tainacan_Taxonomies->insert($taxonomy);
//retorna a taxonomia //retorna a taxonomia
$test = $Tainacan_Taxonomies->fetch($taxonomy->get_id()); $test = $Tainacan_Taxonomies->fetch($taxonomy->get_id());
@ -43,27 +41,30 @@ class Taxonomies extends \WP_UnitTestCase {
function test_add_term_taxonomy(){ function test_add_term_taxonomy(){
global $Tainacan_Taxonomies, $Tainacan_Terms; global $Tainacan_Taxonomies, $Tainacan_Terms;
$taxonomy = new \Tainacan\Entities\Taxonomy();
$term = new \Tainacan\Entities\Term();
//setando os valores na classe de taxonomia $taxonomy = $this->tainacan_entity_factory->create_entity(
$taxonomy->set_name('genero'); 'taxonomy',
array(
//insere a taxonomia 'name' => 'genero',
$taxonomy->validate(); ),
$taxonomy = $Tainacan_Taxonomies->insert($taxonomy); true
);
//retorna a taxonomia //retorna a taxonomia
$taxonomy_test = $Tainacan_Taxonomies->fetch($taxonomy->get_id()); $taxonomy_test = $Tainacan_Taxonomies->fetch($taxonomy->get_id());
//insere um termo na taxonomia $term = $this->tainacan_entity_factory->create_entity(
$term->set_taxonomy( $taxonomy_test->get_db_identifier() ); 'term',
$term->set_name('Rock'); array(
$term->set_user(56); 'taxonomy' => $taxonomy_test->get_db_identifier(),
$term_id = $Tainacan_Terms->insert( $term ) ; 'name' => 'Rock',
'user' => 56
),
true
);
//retorna um objeto da classe Tainacan_Term //retorna um objeto da classe Tainacan_Term
$test = $Tainacan_Terms->fetch($term_id, $taxonomy_test); $test = $Tainacan_Terms->fetch($term, $taxonomy_test);
$this->assertEquals( $test->get_name(), 'Rock' ); $this->assertEquals( $test->get_name(), 'Rock' );
$this->assertEquals( $test->get_user(), 56 ); $this->assertEquals( $test->get_user(), 56 );
} }