refactor repositories fetch method

This commit is contained in:
Eduardo humberto 2017-11-29 16:06:22 -02:00
parent 75d609e2b7
commit 57b3e5586b
16 changed files with 355 additions and 152 deletions

View File

@ -221,7 +221,7 @@ class Collection extends Entity {
*/ */
function get_metadata() { function get_metadata() {
$Tainacan_Metadatas = new \Tainacan\Repositories\Metadatas(); $Tainacan_Metadatas = new \Tainacan\Repositories\Metadatas();
return $Tainacan_Metadatas->fetch($this); return $Tainacan_Metadatas->fetch_by_collection( $this );
} }
/** /**

View File

@ -75,7 +75,7 @@ class Item_Metadata_Entity extends Entity {
return $this->value; return $this->value;
global $Tainacan_Item_Metadata; global $Tainacan_Item_Metadata;
return $Tainacan_Item_Metadata->fetch($this); return $Tainacan_Item_Metadata->get_value($this);
} }
/** /**
@ -167,7 +167,7 @@ class Item_Metadata_Entity extends Entity {
] ]
]); ]);
if (!empty($test)) { if ($test->have_posts()) {
$this->add_error('key_exists', $metadata->get_name() . ' is a collection key and there is another item with the same value'); $this->add_error('key_exists', $metadata->get_name() . ' is a collection key and there is another item with the same value');
return false; return false;
} }

View File

@ -119,13 +119,15 @@ class Item extends Entity {
* @return Array || Metadata * @return Array || Metadata
*/ */
function get_metadata() { function get_metadata() {
global $Tainacan_Metadatas;
if (isset($this->metadata)) if (isset($this->metadata))
return $this->metadata; return $this->metadata;
$collection = $this->get_collection(); $collection = $this->get_collection();
$all_metadata = []; $all_metadata = [];
if ($collection) { if ($collection) {
$meta_list = $collection->get_metadata(); $meta_list = $Tainacan_Metadatas->fetch_by_collection( $collection );
foreach ($meta_list as $meta) { foreach ($meta_list as $meta) {
$all_metadata[$meta->get_id()] = new Item_Metadata_Entity($this, $meta); $all_metadata[$meta->get_id()] = new Item_Metadata_Entity($this, $meta);

View File

@ -156,31 +156,28 @@ class Collections extends Repository {
} }
/** /**
* Obtém um coleção específica pelo ID ou várias coleções * fetch collection based on ID or WP_Query args
* *
* @param array $object || int $object * Collections are stored as posts. Check WP_Query docs
* @return Array || Collection * to learn all args accepted in the $args parameter
*
* @param array $args WP_Query args || int $args the collection id
* @return \WP_Query an instance of wp query
*/ */
public function fetch($object = []){ public function fetch($args = []){
if(is_numeric($object)){ if(is_numeric( $args )){
return new Entities\Collection($object); return new Entities\Collection($args);
} elseif(is_array($object)) { } elseif(is_array($args)) {
$args = array_merge([ $args = array_merge([
'post_type' => Entities\Collection::get_post_type(),
'posts_per_page' => -1, 'posts_per_page' => -1,
'post_status' => 'publish', 'post_status' => 'publish',
], $object); ], $args);
$posts = get_posts($args); $args['post_type'] = Entities\Collection::get_post_type();
$collections = [];
foreach ($posts as $post) {
$collections[] = new Entities\Collection($post);
}
// TODO: Pegar coleções registradas via código // TODO: Pegar coleções registradas via código
return $collections; return new \WP_Query($args);
} }
} }
} }

View File

@ -134,52 +134,100 @@ class Filters extends Repository {
} }
public function fetch($object = [], $args = []){ /**
* fetch filter based on ID or WP_Query args
*
* Filters are stored as posts. Check WP_Query docs
* to learn all args accepted in the $args parameter
*
* @param array $args WP_Query args || int $args the filter id
* @rreturn new \WP_Query($args);
*/
public function fetch($args = []){
/** /**
* Se for numérico retorna o objeto filtro * Se for numérico retorna o objeto filtro
* Se não, mas se valor em $object e $args retorna filtro de coleção especifica * Se não, mas se valor em $object e $args retorna filtro de coleção especifica
* Se não, mas se for string retorna os filtros pelo tipo de metadado * Se não, mas se for string retorna os filtros pelo tipo de metadado
* Se não, retorna todos os filtros * Se não, retorna todos os filtros
*/ */
if(is_numeric($object)){ if( is_numeric($args) ){
return new Entities\Filter($object); return new Entities\Filter($args);
} elseif (!empty($object) && !empty($args)) { } elseif (!empty($args)) {
// TODO: get filters from parent collections // TODO: get filters from parent collections
$collection_id = ( is_object( $object ) ) ? $object->get_id() : $object;
$args = array_merge([ $args = array_merge([
'post_type' => Entities\Filter::get_post_type(),
'posts_per_page' => -1, 'posts_per_page' => -1,
'post_status' => 'publish', 'post_status' => 'publish'
'meta_key' => 'collection_id',
'meta_value' => $collection_id
], $args); ], $args);
$wp_query = new \WP_Query($args); $args['post_type'] = Entities\Filter::get_post_type();
return $wp_query; return new \WP_Query($args);;
} elseif(is_string($object)) {
$filters = array();
$filters_type = $this->fetch();
foreach ( $filters_type as $filter_type ){
if( in_array( $object, $filter_type->get_supported_types() ) ){
$filters[] = $filter_type;
}
}
return $filters;
} else {
$filters = array();
foreach (get_declared_classes() as $class) {
if (is_subclass_of($class, '\Tainacan\Filter_Types\Filter_Type')){
$filters[] = new $class();
}
}
return $filters;
} }
// elseif(is_string($object)) {
// $filters = array();
// $filters_type = $this->fetch();
//
// foreach ( $filters_type as $filter_type ){
// if( in_array( $object, $filter_type->get_supported_types() ) ){
// $filters[] = $filter_type;
// }
// }
//
// return $filters;
// } else {
// $filters = array();
//
// foreach (get_declared_classes() as $class) {
// if (is_subclass_of($class, '\Tainacan\Filter_Types\Filter_Type')){
// $filters[] = new $class();
// }
// }
//
// return $filters;
// }
}
/**
* fetch all declared filter type classes
*
* @return Array of Entities\Filter_Types\Filter_Type objects
*/
public function fetch_filter_types(){
$filters = array();
foreach (get_declared_classes() as $class) {
if (is_subclass_of($class, '\Tainacan\Filter_Types\Filter_Type')){
$filters[] = new $class();
}
}
return $filters;
}
/**
* fetch only supported filters for the type specified
*
* @param ( string || array ) $types Primitve types of metadata ( float, string, int)
* @return array Filters supported by the primitive types passed in $types
*/
public function fetch_supported_filter_types($types){
$filter_types = $this->fetch_filter_types();
$supported_filter_types = [];
foreach ( $filter_types as $filter_type){
$filter = new $filter_type();
if( ( is_array( $types ) )){
foreach ( $types as $single_type ) {
if( in_array( $single_type ,$filter->get_supported_types() )){
$supported_filter_types[] = $filter;
}
}
}else if( in_array( $types ,$filter->get_supported_types() )){
$supported_filter_types[] = $filter;
}
}
return $supported_filter_types;
} }
} }

View File

@ -38,6 +38,12 @@ class Item_Metadata extends Repository {
} }
/**
* Fetch Item Metadata objects related to an Item
*
* @param Entities\Item $object
* @return array
*/
public function fetch($object){ public function fetch($object){
if($object instanceof Entities\Item){ if($object instanceof Entities\Item){
global $Tainacan_Items, $Tainacan_Metadatas; global $Tainacan_Items, $Tainacan_Metadatas;
@ -48,7 +54,7 @@ class Item_Metadata extends Repository {
return []; return [];
} }
$meta_list = $Tainacan_Metadatas->fetch($collection); $meta_list = $Tainacan_Metadatas->fetch_by_collection($collection);
$return = []; $return = [];
@ -59,13 +65,22 @@ class Item_Metadata extends Repository {
} }
return $return; return $return;
} elseif($object instanceof Entities\Item_Metadata_Entity){ }else{
// Retorna o valor do metadado return [];
$unique = ! $object->is_multiple();
return get_post_meta($object->item->get_id(), $object->metadata->get_id(), $unique);
} }
} }
/**
* Get the value for a Item metadata.
*
* @param Entities\Item_Metadata_Entity $item_metadata
* @return mixed
*/
public function get_value(Entities\Item_Metadata_Entity $item_metadata) {
$unique = ! $item_metadata->is_multiple();
return get_post_meta($item_metadata->item->get_id(), $item_metadata->metadata->get_id(), $unique);
}
public function register_post_type() { } public function register_post_type() { }
} }

View File

@ -53,6 +53,9 @@ class Items extends Repository {
} }
public function insert($item) { public function insert($item) {
global $Tainacan_Metadatas;
$map = $this->get_map(); $map = $this->get_map();
// get collection to determine post type // get collection to determine post type
@ -110,28 +113,47 @@ class Items extends Repository {
return new Entities\Item($item->WP_Post); return new Entities\Item($item->WP_Post);
} }
public function fetch($args = [], $object = []){ /**
* fetch items based on ID or WP_Query args
*
* Items are stored as posts. Check WP_Query docs
* to learn all args accepted in the $args parameter
*
* The second paramater specifies from which collections item should be fetched.
* You can pass the Collection ID or object, or an Array of IDs or collection objects
*
* @param array $args WP_Query args || int $args the item id
* @param array $collections Array Entities\Collection || Array int collections IDs || int collection id || Entities\Collection collection object
* @return \WP_Query an instance of wp query
*/
public function fetch($args = [],$collections = []){
global $Tainacan_Collections; global $Tainacan_Collections;
if(is_numeric($args)){ if(is_numeric($args)){
return new Entities\Item($args); return new Entities\Item($args);
} }
if (empty($object)) { if (empty($collections)){
$object = $Tainacan_Collections->fetch(); $wp_query = $Tainacan_Collections->fetch();
if( $wp_query->have_posts() ){
while ( $wp_query->have_posts() ){
$wp_query->the_post();
$collections[] = new Entities\Collection( get_the_ID() );
}
}
} }
if (is_numeric($object)){ if (is_numeric($collections)){
$object = $Tainacan_Collections->fetch($collection); $collections = $Tainacan_Collections->fetch($collections);
} }
if ($object instanceof Entities\Collection) { if ($collections instanceof Entities\Collection) {
$cpt = $object->get_db_identifier(); $cpt = $collections->get_db_identifier();
} elseif (is_array($object)) { } elseif (is_array($collections)) {
$cpt = []; $cpt = [];
foreach ($object as $collection) { foreach ($collections as $collection) {
if (is_numeric($collection)){ if (is_numeric($collection)){
$collection = $Tainacan_Collections->fetch($collection); $collection = $Tainacan_Collections->fetch($collection);
} }
@ -139,30 +161,24 @@ class Items extends Repository {
$cpt[] = $collection->get_db_identifier(); $cpt[] = $collection->get_db_identifier();
} }
} }
} else { } else {
return []; return [];
} }
if (empty($cpt)){ if (empty($cpt)){
return []; return [];
} }
//TODO: get collection order and order by options
$args = array_merge([ $args = array_merge([
'post_type' => $cpt,
'posts_per_page' => -1,
'post_status' => 'publish', 'post_status' => 'publish',
], $args); ], $args);
$posts = get_posts($args); $args['post_type'] = $cpt;
$return = []; return new \WP_Query($args);
foreach ($posts as $post) {
$return[] = new Entities\Item($post);
}
return $return;
} }
public function update($object){ public function update($object){
@ -217,7 +233,7 @@ class Items extends Repository {
$collections = !empty($args['collections']) ? $args['collections'] : []; $collections = !empty($args['collections']) ? $args['collections'] : [];
unset($args['collections']); unset($args['collections']);
return $this->fetch($args, $collections); return $this->fetch($args, $collections);
### TODO I think its better if we return a WP_Query object. easier for loop and debugging ### TODO I think its better if we return a WP_Query object. easier for loop and debugging
} }

View File

@ -107,16 +107,26 @@ class Logs extends Repository {
); );
register_post_type(Entities\Log::get_post_type(), $args); register_post_type(Entities\Log::get_post_type(), $args);
} }
public function fetch($object = []){
if(is_numeric($object)){ /**
return new Entities\Log($object); * fetch logs based on ID or WP_Query args
*
* Logs are stored as posts. Check WP_Query docs
* to learn all args accepted in the $args parameter
*
* @param array $args WP_Query args || int $args the log id
* @return Array of Entities\Log objects || Entities\Log
*/
public function fetch($args = []){
if(is_numeric($args)){
return new Entities\Log($args);
} else { } else {
$args = array_merge([ $args = array_merge([
'post_type' => Entities\Log::get_post_type(),
'posts_per_page' => -1,
'post_status' => 'publish', 'post_status' => 'publish',
], $object); ], $args);
$args['post_type'] = Entities\Log::get_post_type();
$posts = get_posts($args); $posts = get_posts($args);
@ -125,7 +135,7 @@ class Logs extends Repository {
foreach ($posts as $post) { foreach ($posts as $post) {
$logs[] = new Entities\Log($post); $logs[] = new Entities\Log($post);
} }
// TODO: Pegar coleções registradas via código
return $logs; return $logs;
} }
} }

View File

@ -117,33 +117,62 @@ class Metadatas extends Repository {
register_post_type(Entities\Metadata::get_post_type(), $args); register_post_type(Entities\Metadata::get_post_type(), $args);
} }
public function fetch($object, $args = []){
// TODO: get metadata from parent collections /**
if(is_numeric($object)){ * fetch metadata based on ID or WP_Query args
return new Entities\Metadata($object); *
} else { * metadata are stored as posts. Check WP_Query docs
$collection_id = ( is_object( $object ) ) ? $object->get_id() : $object; * to learn all args accepted in the $args parameter
*
* @param array $args WP_Query args || int $args the metadata id
* @return \WP_Query an instance of wp query
*/
public function fetch( $args ) {
if( is_numeric($args) ){
return new Entities\Metadata($args);
} elseif (!empty($args)) {
$args = array_merge([ $args = array_merge([
'post_type' => Entities\Metadata::get_post_type(),
'posts_per_page' => -1, 'posts_per_page' => -1,
'post_status' => 'publish', 'post_status' => 'publish'
'meta_key' => 'collection_id',
'meta_value' => $collection_id
], $args); ], $args);
$posts = get_posts($args); $args['post_type'] = Entities\Metadata::get_post_type();
$return = []; return new \WP_Query($args);
foreach ($posts as $post) {
$return[] = new Entities\Metadata($post);
}
return $return;
} }
} }
/**
* fetch metadata by collection
*
* @param Entities\Collection $collection
* @param array $args
* @return Array Entities\Metadata
*/
public function fetch_by_collection(Entities\Collection $collection, $args = []){
$metadata = [];
$collection_id = $collection->get_id();
$args = array_merge([
'meta_key' => 'collection_id',
'meta_value' => $collection_id
], $args);
$wp_query = $this->fetch($args);
if ( $wp_query->have_posts() ){
while ( $wp_query->have_posts() ) {
$wp_query->the_post();
$metadata[] = new Entities\Metadata( get_the_ID() );
}
}
return $metadata;
}
public function update($object){ public function update($object){
} }

View File

@ -70,10 +70,28 @@ abstract class Repository {
// return a brand new object // return a brand new object
return new $this->entities_type($obj->WP_Post); return new $this->entities_type($obj->WP_Post);
} }
/**
* @param $object
* @return mixed
*/
public abstract function delete($object); public abstract function delete($object);
public abstract function fetch($object);
/**
* @param $args
* @return mixed
*/
public abstract function fetch($args);
/**
* @param $object
* @return mixed
*/
public abstract function update($object); public abstract function update($object);
/**
* @return mixed
*/
public abstract function register_post_type(); public abstract function register_post_type();
} }

View File

@ -139,8 +139,30 @@ class Taxonomies extends Repository {
register_taxonomy( $taxonomy_name, array( ), $args ); register_taxonomy( $taxonomy_name, array( ), $args );
} }
public function fetch($object) { /**
return new Entities\Taxonomy($object); * fetch taxonomies based on ID or WP_Query args
*
* Taxonomies are stored as posts. Check WP_Query docs
* to learn all args accepted in the $args parameter
*
* @param array $args WP_Query args || int $args the taxonomy id
* @return Array of Entities\Taxonomy objects || Entities\Taxonomy
*/
public function fetch( $args ) {
if( is_numeric($args) ){
return new Entities\Taxonomy($args);
} elseif (!empty($args)) {
$args = array_merge([
'posts_per_page' => -1,
'post_status' => 'publish'
], $args);
$args['post_type'] = Entities\Taxonomy::get_post_type();
return new \WP_Query($args);;
}
} }
public function update($object){ public function update($object){

View File

@ -69,23 +69,58 @@ class Terms extends Repository {
} }
/** /**
* Get a term or all terms * fetch terms based on ID or get terms args
* *
* @param string || Array $object1 * Terms are stored as terms. Check get_terms() docs
* @param string || Array || interger $object2 * to learn all args accepted in the $args parameter
* @param string $object3 *
* @return Array of WP_Term || WP_Term * The second paramater specifies from which taxonomies should be fetched.
* You can pass the Taxonomy ID or object, or an Array of IDs or taxonomies objects
*
* @param array $args WP_Query args || int $args the term id
* @param array $taxonomies Array Entities\Taxonomy || Array int terms IDs || int collection id || Entities\Taxonomy taxonomy object
* @return Array of Entities\Term objects || Entities\Term
*/ */
public function fetch( $object1 = '', $object2 = '', $object3 = ''){ public function fetch( $args = [], $taxonomies = []){
if(!empty($object1) && !empty($object2) && empty($object3)){
return get_terms( $object1, $object2 );
} elseif(!empty($object1) && !empty($object2) && !empty($object3)){
$wp_term = get_term_by($object1, $object2, $object3);
global $Tainacan_Taxonomies;
if ( $taxonomies instanceof Entities\Taxonomy ) {
$cpt = $taxonomies->get_db_identifier();
} elseif (is_array( $taxonomies )) {
$cpt = [];
foreach ($taxonomies as $taxonomy) {
if (is_numeric($taxonomy)){
$taxonomy = $Tainacan_Taxonomies->fetch( $taxonomy );
}
if ($taxonomy instanceof Entities\Taxonomy){
$cpt[] = $taxonomy->get_db_identifier();
}
}
} else {
return [];
}
if(is_array( $args ) && !empty( $cpt ) ){ // if an array of arguments is
$terms = get_terms( $cpt, $args );
$return = [];
foreach ($terms as $term) {
$tainacan_term = new Entities\Term( $term );
$tainacan_term->set_user( get_term_meta($tainacan_term->get_id() , 'user', true ) );
$return[] = $tainacan_term;
}
return $return;
} elseif( is_numeric($args) && !empty($cpt) && !is_array( $cpt ) ){ // if an id is passed taxonomy cannot be an array
$wp_term = get_term_by('id', $args, $cpt);
$tainacan_term = new Entities\Term( $wp_term ); $tainacan_term = new Entities\Term( $wp_term );
$tainacan_term->set_user( get_term_meta($tainacan_term->get_id() , 'user', true ) ); $tainacan_term->set_user( get_term_meta($tainacan_term->get_id() , 'user', true ) );
return $tainacan_term; return $tainacan_term;
}else{
return [];
} }
} }

View File

@ -63,9 +63,9 @@ class Collections extends \WP_UnitTestCase {
$i->set_collection($collection); $i->set_collection($collection);
global $Tainacan_Items; global $Tainacan_Items;
$item = $Tainacan_Items->insert($i); $item = $Tainacan_Items->insert( $i );
$item = $Tainacan_Items->fetch($item->get_id()); $item = $Tainacan_Items->fetch( $item->get_id() );
$this->assertEquals($item->get_title(), 'item teste'); $this->assertEquals($item->get_title(), 'item teste');
$this->assertEquals($item->get_description(), 'adasdasdsa'); $this->assertEquals($item->get_description(), 'adasdasdsa');

View File

@ -84,10 +84,10 @@ class Filters extends \WP_UnitTestCase {
function test_get_filters_type(){ function test_get_filters_type(){
global $Tainacan_Filters; global $Tainacan_Filters;
$all_filter_types = $Tainacan_Filters->fetch(); $all_filter_types = $Tainacan_Filters->fetch_filter_types();
$this->assertEquals( 2, count( $all_filter_types ) ); $this->assertEquals( 2, count( $all_filter_types ) );
$float_filters = $Tainacan_Filters->fetch('float'); $float_filters = $Tainacan_Filters->fetch_supported_filter_types('float');
$this->assertTrue( count( $float_filters ) > 0 ); $this->assertTrue( count( $float_filters ) > 0 );
} }
} }

View File

@ -8,6 +8,8 @@ namespace Tainacan\Tests;
* @package Test_Tainacan * @package Test_Tainacan
*/ */
use Tainacan\Entities\Entity;
/** /**
* Sample test case. * Sample test case.
*/ */
@ -77,29 +79,39 @@ class Items extends \WP_UnitTestCase {
// should return all 4 items // should return all 4 items
$test_query = $Tainacan_Items->query([]); $test_query = $Tainacan_Items->query([]);
$this->assertEquals(4, sizeof($test_query)); $this->assertEquals(4, $test_query->post_count );
// should also return all 4 items // should also return all 4 items
$test_query = $Tainacan_Items->query(['collections' => [$collection, $collection2]]); $test_query = $Tainacan_Items->query(['collections' => [$collection, $collection2]]);
$this->assertEquals(4, sizeof($test_query)); $this->assertEquals(4, $test_query->post_count);
// should return only the first item // should return only the first item
$test_query = $Tainacan_Items->query(['collections' => $collection]); $test_query = $Tainacan_Items->query(['collections' => $collection]);
$this->assertEquals(1, sizeof($test_query)); $this->assertEquals(1,$test_query->post_count);
$this->assertEquals('orange', $test_query[0]->get_title());
$test_query->the_post();
$item = new \Tainacan\Entities\Item( get_the_ID() );
$this->assertEquals('orange', $item->get_title() );
$test_query = $Tainacan_Items->query(['title' => 'orange']); $test_query = $Tainacan_Items->query(['title' => 'orange']);
$this->assertEquals(1, sizeof($test_query)); $test_query->the_post();
$this->assertEquals('orange', $test_query[0]->get_title()); $item = new \Tainacan\Entities\Item( get_the_ID() );
$this->assertEquals(1, $test_query->post_count);
$this->assertEquals('orange', $item->get_title());
// should return the other 3 items // should return the other 3 items
$test_query = $Tainacan_Items->query(['collections' => $collection2]); $test_query = $Tainacan_Items->query(['collections' => $collection2]);
$this->assertEquals(3, sizeof($test_query)); $this->assertEquals(3,$test_query->post_count);
$test_query = $Tainacan_Items->query(['title' => 'apple']); $test_query = $Tainacan_Items->query(['title' => 'apple']);
$this->assertEquals(1, sizeof($test_query)); $test_query->the_post();
$this->assertEquals('apple', $test_query[0]->get_title()); $item = new \Tainacan\Entities\Item( get_the_ID() );
$apple_meta = $test_query[0]->get_metadata();
$this->assertEquals(2, sizeof($apple_meta)); $this->assertEquals(1, $test_query->post_count);
$this->assertEquals('apple', $item->get_title());
$apple_meta = $item->get_metadata();
$this->assertEquals(2, sizeof( $apple_meta ));
$apple_meta_values = []; $apple_meta_values = [];
foreach ($apple_meta as $am) { foreach ($apple_meta as $am) {
$this->assertEquals('value_2', $am->get_value()); $this->assertEquals('value_2', $am->get_value());
@ -115,7 +127,7 @@ class Items extends \WP_UnitTestCase {
] ]
] ]
]); ]);
$this->assertEquals(1, sizeof($test_query)); $this->assertEquals(1, $test_query->post_count);
// should return 2 items // should return 2 items
$test_query = $Tainacan_Items->query([ $test_query = $Tainacan_Items->query([
@ -127,7 +139,7 @@ class Items extends \WP_UnitTestCase {
] ]
] ]
]); ]);
$this->assertEquals(2, sizeof($test_query)); $this->assertEquals(2, $test_query->post_count);
// should return 2 item // should return 2 item
$test_query = $Tainacan_Items->query([ $test_query = $Tainacan_Items->query([
@ -140,7 +152,7 @@ class Items extends \WP_UnitTestCase {
] ]
] ]
]); ]);
$this->assertEquals(2, sizeof($test_query)); $this->assertEquals(2, $test_query->post_count);
} }
} }

View File

@ -60,8 +60,7 @@ class Taxonomies extends \WP_UnitTestCase {
$term_id = $Tainacan_Terms->insert( $term ) ; $term_id = $Tainacan_Terms->insert( $term ) ;
//retorna um objeto da classe Tainacan_Term //retorna um objeto da classe Tainacan_Term
$test = $Tainacan_Terms->fetch('id', $term_id, $taxonomy_test->get_db_identifier()); $test = $Tainacan_Terms->fetch($term_id, $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 );
} }