First try

This commit is contained in:
andre2ar 2018-03-20 13:04:02 -03:00
parent 28a4eccc99
commit 7555878a8f
44 changed files with 228 additions and 115 deletions

View File

@ -28,7 +28,7 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_REST_Controller {
* Initialize objects after post_type register
*/
public function init_objects() {
$this->collections_repository = new Repositories\Collections();
$this->collections_repository = Repositories\Collections::getInstance();
$this->collection = new Entities\Collection();
}

View File

@ -80,7 +80,7 @@ class TAINACAN_REST_Field_Types_Controller extends TAINACAN_REST_Controller {
* @return WP_Error|WP_REST_Response
*/
public function get_items( $request ) {
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$field_types = $Tainacan_Fields->fetch_field_types('NAME');

View File

@ -23,10 +23,10 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
* @throws Exception
*/
public function init_objects() {
$this->field_repository = new Repositories\Fields();
$this->item_metadata_repository = new Repositories\Item_Metadata();
$this->item_repository = new Repositories\Items();
$this->collection_repository = new Repositories\Collections();
$this->field_repository = Repositories\Fields::getInstance();
$this->item_metadata_repository = Repositories\Item_Metadata::getInstance();
$this->item_repository = Repositories\Items::getInstance();
$this->collection_repository = Repositories\Collections::getInstance();
}
/**

View File

@ -65,7 +65,7 @@ class TAINACAN_REST_Filter_Types_Controller extends TAINACAN_REST_Controller {
* @return WP_Error|WP_REST_Response
*/
public function get_items( $request ) {
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$filter_types = $Tainacan_Filters->fetch_filter_types('NAME');

View File

@ -28,11 +28,11 @@ class TAINACAN_REST_Filters_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->collection = new Entities\Collection();
$this->collection_repository = new Repositories\Collections();
$this->collection_repository = Repositories\Collections::getInstance();
$this->field_repository = new Repositories\Fields();
$this->field_repository = Repositories\Fields::getInstance();
$this->filter_repository = new Repositories\Filters();
$this->filter_repository = Repositories\Filters::getInstance();
}
public function register_routes() {

View File

@ -23,10 +23,10 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->field = new Entities\Field();
$this->field_repository = new Repositories\Fields();
$this->item_metadata_repository = new Repositories\Item_Metadata();
$this->item_repository = new Repositories\Items();
$this->collection_repository = new Repositories\Collections();
$this->field_repository = Repositories\Fields::getInstance();
$this->item_metadata_repository = Repositories\Item_Metadata::getInstance();
$this->item_repository = Repositories\Items::getInstance();
$this->collection_repository = Repositories\Collections::getInstance();
}
/**

View File

@ -30,10 +30,10 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller {
* Initialize objects after post_type register
*/
public function init_objects() {
$this->items_repository = new Repositories\Items();
$this->items_repository = Repositories\Items::getInstance();
$this->item = new Entities\Item();
$this->item_metadata = new Repositories\Item_Metadata();
$this->collections_repository = new Repositories\Collections();
$this->item_metadata = Repositories\Item_Metadata::getInstance();
$this->collections_repository = Repositories\Collections::getInstance();
}
/**

View File

@ -20,7 +20,7 @@ class TAINACAN_REST_Logs_Controller extends TAINACAN_REST_Controller {
}
public function init_objects(){
$this->logs_repository = new Repositories\Logs();
$this->logs_repository = Repositories\Logs::getInstance();
$this->log = new Entities\Log();
}

View File

@ -23,7 +23,7 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->taxonomy = new Entities\Taxonomy();
$this->taxonomy_repository = new Repositories\Taxonomies();
$this->taxonomy_repository = Repositories\Taxonomies::getInstance();
}
public function register_routes() {

View File

@ -25,9 +25,9 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->term = new Entities\Term();
$this->terms_repository = new Repositories\Terms();
$this->terms_repository = Repositories\Terms::getInstance();
$this->taxonomy = new Entities\Taxonomy();
$this->taxonomy_repository = new Repositories\Taxonomies();
$this->taxonomy_repository = Repositories\Taxonomies::getInstance();
}
public function register_routes() {

View File

@ -381,7 +381,7 @@ class Capabilities {
}
}
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
foreach ($collections as $collection) {
$this->set_items_capabilities($collection, $defaults_caps);

View File

@ -91,7 +91,7 @@ class Item_Metadata_Entity extends Entity {
if (isset($this->value))
return $this->value;
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
return $Tainacan_Item_Metadata->get_value($this);
}

View File

@ -268,7 +268,7 @@ class Item extends Entity {
* @return array Array of ItemMetadata objects
*/
function get_fields() {
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
return $Tainacan_Item_Metadata->fetch( $this, 'OBJECT' );

View File

@ -211,7 +211,7 @@ class Log extends Entity {
throw new \Exception('msn or new_value is need to log');
}
global $Tainacan_Logs;
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
if ($log->validate()) {
return $Tainacan_Logs->insert($log);

View File

@ -46,7 +46,7 @@ class Category extends Field_Type {
if (empty($this->get_option('taxonomy_id')))
return ['taxonomy_id' => __('Please select a category', 'tainacan')];
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$category_fields = $Tainacan_Fields->fetch([
'collection_id' => $field->get_collection_id(),

View File

@ -12,10 +12,25 @@ use Tainacan\Entities\Collection;
class Collections extends Repository {
public $entities_type = '\Tainacan\Entities\Collection';
public function __construct() {
parent::__construct();
add_filter( 'map_meta_cap', array( $this, 'map_meta_cap' ), 10, 4 );
}
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
/**
* Collections constructor.
*/
protected function __construct() {
parent::__construct();
add_filter( 'map_meta_cap', array( $this, 'map_meta_cap' ), 10, 4 );
}
/**
* {@inheritDoc}
@ -206,7 +221,7 @@ class Collections extends Repository {
* @see \Tainacan\Repositories\Repository::insert()
*/
public function insert( $collection ) {
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$this->pre_update_moderators( $collection );
$new_collection = parent::insert( $collection );

View File

@ -20,10 +20,23 @@ class Fields extends Repository {
'Tainacan\Field_Types\Core_Title',
'Tainacan\Field_Types\Core_Description'
];
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
/**
* Register specific hooks for field repository
*/
function __construct() {
protected function __construct() {
parent::__construct();
add_filter('pre_trash_post', array( &$this, 'disable_delete_core_fields' ), 10, 2 );
add_filter('pre_delete_post', array( &$this, 'force_delete_core_fields' ), 10, 3 );
@ -423,7 +436,7 @@ class Fields extends Repository {
* @see \Tainacan\Repositories\Repository::insert()
*/
public function insert($field){
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$this->pre_update_category_field($field);
$new_field = parent::insert($field);

View File

@ -9,7 +9,24 @@ use \Respect\Validation\Validator as v;
class Filters extends Repository {
public $entities_type = '\Tainacan\Entities\Filter';
public $filters_types = [];
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
protected function __construct()
{
parent::__construct();
}
public function get_map() {
return apply_filters('tainacan-get-map-'.$this->get_name(), [
'name' => [

View File

@ -6,8 +6,26 @@ use Tainacan\Entities;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Item_Metadata extends Repository {
public $entities_type = '\Tainacan\Entities\Item_Metadata_Entity';
protected function __construct()
{
parent::__construct();
}
public $entities_type = '\Tainacan\Entities\Item_Metadata_Entity';
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
public function insert($item_metadata) {
$unique = !$item_metadata->is_multiple();
@ -56,7 +74,7 @@ class Item_Metadata extends Repository {
$value = $item_metadata->get_value();
$item->$set_method( is_array( $value ) ? $value[0] : $value );
if ($item->validate_core_fields()) {
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Items->insert($item);
} else {
throw new \Exception('Item metadata should be validated beforehand');

View File

@ -10,7 +10,24 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Items extends Repository {
public $entities_type = '\Tainacan\Entities\Item';
public function get_map() {
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
protected function __construct()
{
parent::__construct();
}
public function get_map() {
return apply_filters( 'tainacan-get-map-' . $this->get_name(), [
'title' => [
'map' => 'post_title',
@ -204,7 +221,7 @@ class Items extends Repository {
*/
public function fetch( $args = [], $collections = [], $output = null ) {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
if ( is_numeric( $args ) ) {
$existing_post = get_post( $args );

View File

@ -13,8 +13,20 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
*/
class Logs extends Repository {
public $entities_type = '\Tainacan\Entities\Log';
public function __construct() {
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
protected function __construct() {
parent::__construct();
add_action('tainacan-insert', array($this, 'log_inserts'));
}

View File

@ -15,7 +15,7 @@ abstract class Repository {
/**
* Register hooks
*/
function __construct() {
protected function __construct() {
add_action( 'init', array( &$this, 'register_post_type' ) );
add_filter( 'tainacan-get-map-' . $this->get_name(), array( $this, 'get_default_properties' ) );
}
@ -334,7 +334,7 @@ abstract class Repository {
* @return array[]
*/
public static function get_collections_db_identifier() {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collections = $Tainacan_Collections->fetch( [], 'OBJECT' );
$cpts = [];
foreach ( $collections as $col ) {
@ -417,7 +417,7 @@ abstract class Repository {
// its is a collection Item?
if ( $prefix == Entities\Collection::$db_identifier_prefix ) {
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
return $Tainacan_Items;
} else {

View File

@ -12,8 +12,20 @@ use \Respect\Validation\Validator as v;
*/
class Taxonomies extends Repository {
public $entities_type = '\Tainacan\Entities\Taxonomy';
public function __construct() {
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
protected function __construct() {
parent::__construct();
add_action('tainacan-taxonomy-removed-from-collection', array($this, 'removed_collection'), 10, 2);
add_action('tainacan-taxonomy-added-to-collection', array($this, 'added_collection'), 10, 2);

View File

@ -12,7 +12,24 @@ use \Respect\Validation\Validator as v;
class Terms extends Repository {
public $entities_type = '\Tainacan\Entities\Term';
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
protected function __construct()
{
parent::__construct();
}
public function get_map() {
return apply_filters('tainacan-get-map-'.$this->get_name(), [
'term_id' => [
@ -120,7 +137,7 @@ class Terms extends Repository {
*/
public function fetch( $args = [], $taxonomies = []){
global $Tainacan_Taxonomies;
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
if ( $taxonomies instanceof Entities\Taxonomy ) {
$cpt = $taxonomies->get_db_identifier();

View File

@ -74,14 +74,11 @@ function tainacan_autoload($class_name){
}
}
global $Tainacan_Collections;
$Tainacan_Collections = new \Tainacan\Repositories\Collections();
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = new \Tainacan\Repositories\Item_Metadata();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
global $Tainacan_Fields;
$Tainacan_Fields = new \Tainacan\Repositories\Fields();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
//register field types
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Text');
@ -92,8 +89,7 @@ $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Selectbox');
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Relationship');
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Category');
global $Tainacan_Filters;
$Tainacan_Filters = new \Tainacan\Repositories\Filters();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
//register filter type
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Custom_Interval');
@ -105,16 +101,12 @@ $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategoryTaginput'
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategoryCheckbox');
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategorySelectbox');
global $Tainacan_Taxonomies;
$Tainacan_Taxonomies = new \Tainacan\Repositories\Taxonomies();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
global $Tainacan_Items;
$Tainacan_Items = new \Tainacan\Repositories\Items();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
global $Tainacan_Terms;
$Tainacan_Terms = new \Tainacan\Repositories\Terms();
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
global $Tainacan_Logs;
$Tainacan_Logs = new \Tainacan\Repositories\Logs();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
?>

View File

@ -31,7 +31,7 @@ trait Entity_Collection_Relation {
return $this->collection;
if (is_numeric($this->get_collection_id())) {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$this->collection = $Tainacan_Collections->fetch($this->get_collection_id());
return $this->collection;

View File

@ -16,7 +16,7 @@ trait Entity_Collections_Relation {
return $this->collections;
if (is_array($this->get_collections_ids()) && !empty($this->get_collections_ids())) {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$this->collections = [];

View File

@ -94,7 +94,7 @@ class DevInterface {
}
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
foreach ($collections as $col) {
@ -121,23 +121,23 @@ class DevInterface {
}
function properties_metabox_Collections() {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$this->properties_metabox($Tainacan_Collections);
}
function properties_metabox_Filters() {
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$this->properties_metabox($Tainacan_Filters);
}
function properties_metabox_Logs() {
global $Tainacan_Logs;
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$this->properties_metabox($Tainacan_Logs);
}
function properties_metabox_Fields() {
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$this->properties_metabox($Tainacan_Fields);
}
function properties_metabox_Taxonomies() {
global $Tainacan_Taxonomies;
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$this->properties_metabox($Tainacan_Taxonomies);
}
@ -356,7 +356,7 @@ class DevInterface {
function field_type_dropdown($id,$selected) {
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$class = ( class_exists( $selected ) ) ? new $selected() : '';
@ -383,7 +383,7 @@ class DevInterface {
function filter_type_dropdown($id,$selected) {
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$class = ( class_exists( $selected ) ) ? new $selected() : '';
@ -414,7 +414,7 @@ class DevInterface {
}
function collections_checkbox_list($selected) {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
$selected = json_decode($selected);
?>

View File

@ -12,7 +12,7 @@ use Tainacan\Entities;
* @param string $name_field (optional) default 'tnc_prop_collections_id'
*/
public static function collections_dropdown($selected, $name_field = 'tnc_prop_collection_id'){
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
?>
<select name="<?php echo $name_field ?>">
@ -30,7 +30,7 @@ use Tainacan\Entities;
* @param string $name_field (optional) default 'tnc_prop_collections_ids[]'
*/
public static function collections_checkbox_list($selected,$name_field = 'tnc_prop_collections_ids[]') {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
$selected = json_decode($selected);
?>
@ -51,7 +51,7 @@ use Tainacan\Entities;
* @param array $args (optional) filter the field list
*/
public static function metadata_dropdown( $collection , $selected, $name_field = 'tnc_prop_field_id', $args = []){
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection = ( is_numeric( $collection ) ) ? new Entities\Collection( $collection ) : $collection;
$field = $Tainacan_Fields->fetch_by_collection( $collection, $args, 'OBJECT');
?>
@ -74,7 +74,7 @@ use Tainacan\Entities;
* @param array $args (optional) filter the field list
*/
public static function metadata_checkbox_list( $collection , $selected,$name_field = 'tnc_prop_tnc_field_ids[]', $args = []) {
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection = ( is_numeric( $collection ) ) ? new Entities\Collection( $collection ) : $collection;
$field = $Tainacan_Fields->fetch_by_collection( $collection, $args, 'OBJECT');
$selected = ( is_array( $selected) ) ? $selected : json_decode($selected);

View File

@ -32,7 +32,7 @@ class Entity_Factory {
public function create_entity($type, $args = [], $is_validated_and_in_db = false, $publish = false){
ini_set('display_errors', 1);
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
try {
if(empty($type)){

View File

@ -6,7 +6,7 @@ class Item_Metadata_Factory {
private $item_metadata;
public function create_item_metadata(\Tainacan\Entities\Item $item, \Tainacan\Entities\Field $field, $value = ''){
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $field);
if (!empty($value))

View File

@ -15,7 +15,7 @@ class TAINACAN_REST_Field_Types_Controller extends TAINACAN_UnitApiTestCase {
$data = $ftype_response->get_data();
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$field_types = $Tainacan_Fields->fetch_field_types('NAME');

View File

@ -15,7 +15,7 @@ class TAINACAN_REST_Filter_Types_Controller extends TAINACAN_UnitApiTestCase {
$data = $ftype_response->get_data();
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$filter_types = $Tainacan_Filters->fetch_filter_types('NAME');

View File

@ -94,7 +94,7 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$this->assertEquals(200, $response->get_status());
$data = $response->get_data();
$this->assertEquals( 'pending', $data['status'] );
global $Tainacan_Logs;
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$query = $Tainacan_Logs->fetch(['post_status' => 'pending']);
$log = false;
@ -155,7 +155,7 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$this->assertEquals(200, $response->get_status());
$data = $response->get_data();
$this->assertEquals( 'pending', $data['status'] );
global $Tainacan_Logs;
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$query = $Tainacan_Logs->fetch(['post_status' => 'pending']);
$log = false;

View File

@ -143,7 +143,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
}
public function test_get_item_and_collection_metadata(){
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
@ -405,7 +405,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
}
public function test_fetch_all_field_values(){
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',

View File

@ -66,7 +66,7 @@ class Collections extends TAINACAN_UnitTestCase {
$collection_test->add_moderator_id($current_user_id);
$collection_test->validate();
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collection_test = $Tainacan_Collections->insert($collection_test);
@ -146,7 +146,7 @@ class Collections extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$this->assertEquals('Tainacan\Entities\Collection', get_class($x));
@ -210,7 +210,7 @@ class Collections extends TAINACAN_UnitTestCase {
$this->assertEquals($x->get_slug(), $y->get_slug());
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$x->set_status('publish');
$x->validate();
$x = $Tainacan_Collections->insert($x);
@ -233,7 +233,7 @@ class Collections extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$collection = $Tainacan_Collections->fetch($x->get_id());
$i = $this->tainacan_entity_factory->create_entity(
@ -247,7 +247,7 @@ class Collections extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$item = $Tainacan_Items->fetch( $i->get_id() );
$this->assertEquals($item->get_title(), 'item test');
@ -281,7 +281,7 @@ class Collections extends TAINACAN_UnitTestCase {
}
function test_hooks() {
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$this->assertTrue(has_action('init', array($Tainacan_Collections, 'register_post_type')) !== false, 'Collections Init is not registred!');
}

View File

@ -18,7 +18,7 @@ class Fields extends TAINACAN_UnitTestCase {
* Test insert a regular field with type
*/
function test_add() {
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
@ -52,7 +52,7 @@ class Fields extends TAINACAN_UnitTestCase {
* Test insert a regular field with type
*/
function test_add_type(){
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
@ -85,7 +85,7 @@ class Fields extends TAINACAN_UnitTestCase {
* test if parent field are visible for children collection
*/
function test_hierarchy_metadata(){
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$this->tainacan_entity_factory->create_entity(
'field',
@ -170,7 +170,7 @@ class Fields extends TAINACAN_UnitTestCase {
* test remove core fields
*/
function test_core_fields(){
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection_grandfather = $this->tainacan_entity_factory->create_entity(
'collection',
@ -193,7 +193,7 @@ class Fields extends TAINACAN_UnitTestCase {
* test if the defaults types are registered
*/
function test_metadata_field_type(){
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$this->assertEquals( 7, sizeof( $Tainacan_Fields->fetch_field_types() ) );
}
@ -321,7 +321,7 @@ class Fields extends TAINACAN_UnitTestCase {
$this->assertEquals($x->get_slug(), $y->get_slug());
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$x->set_status('publish');
$x->validate();
$x = $Tainacan_Fields->insert($x);
@ -334,7 +334,7 @@ class Fields extends TAINACAN_UnitTestCase {
}
function test_validation_of_field_types() {
global $Tainacan_Fields;
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',

View File

@ -15,7 +15,7 @@ class Filters extends TAINACAN_UnitTestCase {
function teste_add(){
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
@ -43,7 +43,7 @@ class Filters extends TAINACAN_UnitTestCase {
}
function test_add_with_metadata_and_type(){
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',
@ -96,7 +96,7 @@ class Filters extends TAINACAN_UnitTestCase {
}
function test_get_filters_type(){
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$all_filter_types = $Tainacan_Filters->fetch_filter_types();
$this->assertEquals( 8, count( $all_filter_types ) );
@ -109,7 +109,7 @@ class Filters extends TAINACAN_UnitTestCase {
* @group filter
*/
function test_validate_supported_filters(){
global $Tainacan_Filters;
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',

View File

@ -52,7 +52,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$item = $Tainacan_Items->fetch($i->get_id());
@ -103,7 +103,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$item = $Tainacan_Items->fetch($i->get_id());
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $test);
@ -157,7 +157,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$item = $Tainacan_Items->fetch($i->get_id());
@ -178,7 +178,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
}
function teste_fetch(){
global $Tainacan_Item_Metadata;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collection = $this->tainacan_entity_factory->create_entity(
'collection',

View File

@ -125,7 +125,7 @@ class Items extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$i = $this->tainacan_entity_factory->create_entity(
'item',

View File

@ -19,7 +19,7 @@ class Logs extends TAINACAN_UnitTestCase {
* Teste da insercao de um log simples apenas se criar o dado bruto
*/
function test_add() {
global $Tainacan_Logs;
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$log = $this->tainacan_entity_factory->create_entity(
'log',
@ -51,7 +51,7 @@ class Logs extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$value->set_name('new_testeLogs');
$value->validate();

View File

@ -78,7 +78,7 @@ class Objects extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$i = $this->tainacan_entity_factory->create_entity(
'item',
@ -125,7 +125,7 @@ class Objects extends TAINACAN_UnitTestCase {
$collection->set_name('');
$this->assertEquals('', $collection->get_name());
global $Tainacan_Collections;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$this->assertTrue($collection->validate());
$newCol = $Tainacan_Collections->insert($collection);
$this->assertEquals('', $newCol->get_name());

View File

@ -52,7 +52,7 @@ class PrivateObjects extends TAINACAN_UnitTestCase {
true
);
global $Tainacan_Items;
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$items = $Tainacan_Items->fetch([], $collection);

View File

@ -18,7 +18,7 @@ class Taxonomies extends TAINACAN_UnitTestCase {
* Teste da insercao de uma taxonomia simples
*/
function test_add() {
global $Tainacan_Taxonomies;
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$taxonomy = $this->tainacan_entity_factory->create_entity(
'taxonomy',