Solving errors

This commit is contained in:
andre2ar 2018-03-21 09:20:00 -03:00
parent 7555878a8f
commit e8835841a6
27 changed files with 163 additions and 78 deletions

View File

@ -7,8 +7,19 @@ namespace Tainacan;
class Admin { class Admin {
private $menu_slug = 'tainacan_admin'; private $menu_slug = 'tainacan_admin';
private static $instance = null;
public function __construct() { public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_action( 'admin_menu', array(&$this, 'add_admin_menu') ); add_action( 'admin_menu', array(&$this, 'add_admin_menu') );
add_filter( 'admin_body_class', array(&$this, 'admin_body_class') ); add_filter( 'admin_body_class', array(&$this, 'admin_body_class') );
@ -66,7 +77,13 @@ class Admin {
} }
function admin_page() { function admin_page() {
global $TAINACAN_BASE_URL, $Tainacan_Collections, $Tainacan_Fields, $Tainacan_Filters, $Tainacan_Items, $Tainacan_Taxonomies; global $TAINACAN_BASE_URL;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
// TODO move it to a separate file and start the Vue project // TODO move it to a separate file and start the Vue project
echo "<div id='tainacan-admin-app'></div>"; echo "<div id='tainacan-admin-app'></div>";

View File

@ -270,11 +270,22 @@ class Capabilities {
] ]
], ],
]; ];
private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
/** /**
* Register hooks * Register hooks
*/ */
function __construct() { private function __construct() {
add_action('tainacan-insert-tainacan-collection', array(&$this, 'new_collection')); add_action('tainacan-insert-tainacan-collection', array(&$this, 'new_collection'));
add_action('tainacan-add-collection-moderators', array(&$this, 'add_moderators'), 10, 2); add_action('tainacan-add-collection-moderators', array(&$this, 'add_moderators'), 10, 2);

View File

@ -20,7 +20,7 @@ class Collection extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Collections'; protected $repository = 'Collections';
/** /**
* Prefix used to create the db_identifier * Prefix used to create the db_identifier
@ -61,9 +61,9 @@ class Collection extends Entity {
* @return \WP_Post_Type|\WP_Error * @return \WP_Post_Type|\WP_Error
*/ */
function register_collection_item_post_type() { function register_collection_item_post_type() {
global ${$this->repository}; $repository = $this->get_repository();
$cpt_labels = ${$this->repository}->get_cpt_labels(); $cpt_labels = $repository->get_cpt_labels();
$cpt_labels['menu_name'] = $this->get_name(); $cpt_labels['menu_name'] = $this->get_name();
@ -351,7 +351,7 @@ class Collection extends Entity {
* @throws \Exception * @throws \Exception
*/ */
function get_fields() { function get_fields() {
$Tainacan_Fields = new \Tainacan\Repositories\Fields(); $Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
return $Tainacan_Fields->fetch_by_collection( $this, [], 'OBJECT' ); return $Tainacan_Fields->fetch_by_collection( $this, [], 'OBJECT' );
} }

View File

@ -125,6 +125,14 @@ class Entity {
} }
} }
public function get_repository()
{
$namespace = '\Tainacan\Repositories\\'.$this->repository;
$repository = $namespace::getInstance();
return $repository;
}
/** /**
* return the value for a mapped property * return the value for a mapped property
* @param string $prop id of property * @param string $prop id of property
@ -135,8 +143,9 @@ class Entity {
return $this->$prop; return $this->$prop;
} }
//prop is not set at object, try to get from database //prop is not set at object, try to get from database
global ${$this->repository}; $repository = $this->get_repository();
return ${$this->repository}->get_mapped_property($this, $prop);
return $repository->get_mapped_property($this, $prop);
} }
/** /**
@ -167,8 +176,8 @@ class Entity {
*/ */
public function validate() { public function validate() {
global ${$this->repository}; $repository = $this->get_repository();
$map = ${$this->repository}->get_map(); $map = $repository->get_map();
$is_valid = true; $is_valid = true;
@ -190,8 +199,8 @@ class Entity {
* @return boolean * @return boolean
*/ */
public function validate_prop($prop) { public function validate_prop($prop) {
global ${$this->repository}; $repository = $this->get_repository();
$map = ${$this->repository}->get_map(); $map = $repository->get_map();
$mapped = $map[$prop]; $mapped = $map[$prop];
$is_valid = true; $is_valid = true;
@ -289,8 +298,8 @@ class Entity {
} }
public function __toArray(){ public function __toArray(){
global ${$this->repository}; $repository = $this->get_repository();
$map = ${$this->repository}->get_map(); $map = $repository->get_map();
$attributes = []; $attributes = [];
foreach($map as $prop => $content) { foreach($map as $prop => $content) {
@ -310,8 +319,8 @@ class Entity {
* @return bool * @return bool
*/ */
public function can_read($user = null) { public function can_read($user = null) {
global ${$this->repository}; $repository = $this->get_repository();
return ${$this->repository}->can_read($this, $user); return $repository->can_read($this, $user);
} }
/** /**
@ -320,8 +329,8 @@ class Entity {
* @return bool * @return bool
*/ */
public function can_edit($user = null) { public function can_edit($user = null) {
global ${$this->repository}; $repository = $this->get_repository();
return ${$this->repository}->can_edit($this, $user); return $repository->can_edit($this, $user);
} }
/** /**
@ -330,8 +339,8 @@ class Entity {
* @return bool * @return bool
*/ */
public function can_delete($user = null) { public function can_delete($user = null) {
global ${$this->repository}; $repository = $this->get_repository();
return ${$this->repository}->can_delete($this, $user); return $repository->can_delete($this, $user);
} }
/** /**
@ -340,8 +349,8 @@ class Entity {
* @return bool * @return bool
*/ */
public function can_publish($user = null) { public function can_publish($user = null) {
global ${$this->repository}; $repository = $this->get_repository();
return ${$this->repository}->can_publish($this, $user); return $repository->can_publish($this, $user);
} }
/** /**
@ -370,8 +379,8 @@ class Entity {
* @return array * @return array
*/ */
public function diff($which = 0) { public function diff($which = 0) {
global ${$this->repository}; $repository = $this->get_repository();
return ${$this->repository}->diff($which, $this); return $repository->diff($which, $this);
} }
} }

View File

@ -20,7 +20,7 @@ class Field extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Fields'; protected $repository = 'Fields';
public function __toString(){ public function __toString(){
return 'Hello, my name is '. $this->get_name(); return 'Hello, my name is '. $this->get_name();

View File

@ -17,7 +17,7 @@ class Filter extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Filters'; protected $repository = 'Filters';
public function __toString(){ public function __toString(){
return 'Hello, my name is '. $this->get_name(); return 'Hello, my name is '. $this->get_name();

View File

@ -14,7 +14,7 @@ class Item_Metadata_Entity extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Item_Metadata'; protected $repository = 'Item_Metadata';
function __construct(Item $item, Field $field) { function __construct(Item $item, Field $field) {
@ -187,7 +187,7 @@ class Item_Metadata_Entity extends Entity {
} }
if ($this->is_collection_key()) { if ($this->is_collection_key()) {
$Tainacan_Items = new \Tainacan\Repositories\Items(); $Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$test = $Tainacan_Items->fetch([ $test = $Tainacan_Items->fetch([
'meta_query' => [ 'meta_query' => [

View File

@ -14,7 +14,7 @@ class Item extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Items'; protected $repository = 'Items';
/** /**
* {@inheritDoc} * {@inheritDoc}

View File

@ -14,7 +14,7 @@ class Log extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Logs'; protected $repository = 'Logs';
public function __construct($which=0) { public function __construct($which=0) {
parent::__construct($which); parent::__construct($which);
@ -226,7 +226,8 @@ class Log extends Entity {
* @see \Tainacan\Repositories\Logs::approve * @see \Tainacan\Repositories\Logs::approve
*/ */
public function approve() { public function approve() {
global ${$this->repository}; $repository = $this->get_repository();
return ${$this->repository}->approve($this);
return $repository->approve($this);
} }
} }

View File

@ -29,7 +29,7 @@ class Taxonomy extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Taxonomies'; protected $repository = 'Taxonomies';
public function __toString(){ public function __toString(){
return 'Hello, my name is '. $this->get_name(); return 'Hello, my name is '. $this->get_name();

View File

@ -14,7 +14,7 @@ class Term extends Entity {
* @see \Tainacan\Entities\Entity::repository * @see \Tainacan\Entities\Entity::repository
* @var string * @var string
*/ */
protected $repository = 'Tainacan_Terms'; protected $repository = 'Terms';
/** /**
* Term constructor. * Term constructor.

View File

@ -105,7 +105,7 @@ class Item_Metadata extends Repository {
*/ */
public function fetch($object, $output = null ){ public function fetch($object, $output = null ){
if($object instanceof Entities\Item){ if($object instanceof Entities\Item){
global $Tainacan_Items, $Tainacan_Fields; $Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection = $object->get_collection(); $collection = $object->get_collection();

View File

@ -125,7 +125,8 @@ class Items extends Repository {
*/ */
public function register_post_type() { public function register_post_type() {
global $Tainacan_Collections, $Tainacan_Taxonomies; $Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$collections = $Tainacan_Collections->fetch( [], 'OBJECT' ); $collections = $Tainacan_Collections->fetch( [], 'OBJECT' );
$taxonomies = $Tainacan_Taxonomies->fetch( [], 'OBJECT' ); $taxonomies = $Tainacan_Taxonomies->fetch( [], 'OBJECT' );

View File

@ -383,7 +383,14 @@ abstract class Repository {
throw new \Exception( 'Collection object not found for this post' ); throw new \Exception( 'Collection object not found for this post' );
} }
} else { } else {
global $Tainacan_Collections, $Tainacan_Fields, $Tainacan_Item_Metadata, $Tainacan_Filters, $Tainacan_Taxonomies, $Tainacan_Terms, $Tainacan_Logs; $Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
$tnc_globals = [ $tnc_globals = [
$Tainacan_Collections, $Tainacan_Collections,
$Tainacan_Fields, $Tainacan_Fields,
@ -421,7 +428,14 @@ abstract class Repository {
return $Tainacan_Items; return $Tainacan_Items;
} else { } else {
global $Tainacan_Collections, $Tainacan_Fields, $Tainacan_Item_Metadata, $Tainacan_Filters, $Tainacan_Taxonomies, $Tainacan_Terms, $Tainacan_Logs; $Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$tnc_globals = [ $tnc_globals = [
$Tainacan_Collections, $Tainacan_Collections,
$Tainacan_Fields, $Tainacan_Fields,

View File

@ -9,7 +9,19 @@ class DevInterface {
var $repositories = []; var $repositories = [];
var $has_errors = false; var $has_errors = false;
public function __construct() { private static $instance = null;
public static function getInstance()
{
if(!isset(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_action('add_meta_boxes', array(&$this, 'register_metaboxes')); add_action('add_meta_boxes', array(&$this, 'register_metaboxes'));
add_action('save_post', array(&$this, 'save_post'), 10, 2); add_action('save_post', array(&$this, 'save_post'), 10, 2);
@ -17,7 +29,11 @@ class DevInterface {
add_filter('post_type_link', array(&$this, 'permalink_filter'), 10, 3); add_filter('post_type_link', array(&$this, 'permalink_filter'), 10, 3);
global $Tainacan_Collections, $Tainacan_Filters, $Tainacan_Logs, $Tainacan_Fields, $Tainacan_Taxonomies; $Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$repositories = [$Tainacan_Collections, $Tainacan_Filters, $Tainacan_Logs, $Tainacan_Fields, $Tainacan_Taxonomies]; $repositories = [$Tainacan_Collections, $Tainacan_Filters, $Tainacan_Logs, $Tainacan_Fields, $Tainacan_Taxonomies];
@ -214,7 +230,9 @@ class DevInterface {
function metadata_metabox() { function metadata_metabox() {
global $Tainacan_Collections, $Tainacan_Item_Metadata, $pagenow, $typenow, $post; global $typenow, $post;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT'); $collections = $Tainacan_Collections->fetch([], 'OBJECT');
@ -284,7 +302,9 @@ class DevInterface {
} }
function metadata_components_metabox() { function metadata_components_metabox() {
global $Tainacan_Collections, $Tainacan_Item_Metadata, $pagenow, $typenow, $post; global $typenow, $post;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT'); $collections = $Tainacan_Collections->fetch([], 'OBJECT');
@ -489,7 +509,11 @@ class DevInterface {
// TODO: there should ve a method in the repository to find this out // TODO: there should ve a method in the repository to find this out
// or I could try to initialize an entity and find out what type it is // or I could try to initialize an entity and find out what type it is
global $Tainacan_Collections, $Tainacan_Items, $Tainacan_Fields, $Tainacan_Item_Metadata; $Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT'); $collections = $Tainacan_Collections->fetch([], 'OBJECT');
$cpts = []; $cpts = [];
foreach($collections as $col) { foreach($collections as $col) {

View File

@ -224,7 +224,9 @@ abstract class Importer {
* @return Tainacan\Entities\Item Item inserted * @return Tainacan\Entities\Item Item inserted
*/ */
public function insert( $index, $processed_item ){ public function insert( $index, $processed_item ){
global $Tainacan_Items, $Tainacan_Item_Metadata, $Tainacan_Fields; $Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$isUpdate = ( is_array( $this->processed_items ) && isset( $this->processed_items[ $index ] ) ) $isUpdate = ( is_array( $this->processed_items ) && isset( $this->processed_items[ $index ] ) )
? $this->processed_items[ $index ] : 0; ? $this->processed_items[ $index ] : 0;

View File

@ -19,20 +19,18 @@ require_once(CLASSES_DIR . 'tainacan-creator.php');
require_once(API_DIR . 'tainacan-rest-creator.php'); require_once(API_DIR . 'tainacan-rest-creator.php');
require_once('dev-interface/class-tainacan-dev-interface.php'); require_once('dev-interface/class-tainacan-dev-interface.php');
$Tainacan_Dev_interface = new \Tainacan\DevInterface\DevInterface(); $Tainacan_Dev_interface = \Tainacan\DevInterface\DevInterface::getInstance();
function tnc_enable_dev_wp_interface() { function tnc_enable_dev_wp_interface() {
//return defined('TNC_ENABLE_DEV_WP_INTERFACE') && true === TNC_ENABLE_DEV_WP_INTERFACE ? true : false; /*return defined('TNC_ENABLE_DEV_WP_INTERFACE') && true === TNC_ENABLE_DEV_WP_INTERFACE ? true : false;*/
} }
global $Tainacan_Capabilities; $Tainacan_Capabilities = \Tainacan\Capabilities::getInstance();
$Tainacan_Capabilities = new \Tainacan\Capabilities();
register_activation_hook( __FILE__, array( $Tainacan_Capabilities, 'init' ) ); register_activation_hook( __FILE__, array( $Tainacan_Capabilities, 'init' ) );
// TODO move it somewhere else? // TODO move it somewhere else?
require_once('admin/class-tainacan-admin.php'); require_once('admin/class-tainacan-admin.php');
global $Tainacan_Admin; $Tainacan_Admin = \Tainacan\Admin::getInstance();
$Tainacan_Admin = new \Tainacan\Admin();
function tainacan_load_plugin_textdomain() { function tainacan_load_plugin_textdomain() {
load_plugin_textdomain( 'tainacan', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); load_plugin_textdomain( 'tainacan', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );

View File

@ -55,7 +55,7 @@ class Entity_Factory {
} }
$this->entity = new $this->entity_type(); $this->entity = new $this->entity_type();
$this->repository = new $this->repository_type(); $this->repository = $this->repository_type::getInstance();
if($publish) { if($publish) {
$this->entity->set_status('publish'); $this->entity->set_status('publish');

View File

@ -53,7 +53,6 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_UnitApiTestCase {
} }
public function test_create_suggestion_item_metadata_in_a_collection(){ public function test_create_suggestion_item_metadata_in_a_collection(){
global $Tainacan_Fields, $Tainacan_Item_Metadata;
extract($this->create_meta_requirements()); extract($this->create_meta_requirements());
@ -125,7 +124,6 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_UnitApiTestCase {
function test_create_anonymous_suggestion_item_metadata_in_a_collection() { function test_create_anonymous_suggestion_item_metadata_in_a_collection() {
extract($this->create_meta_requirements()); extract($this->create_meta_requirements());
global $Tainacan_Fields, $Tainacan_Item_Metadata;
$item__metadata_json = json_encode([ $item__metadata_json = json_encode([
'values' => 'TestValues_metadado', 'values' => 'TestValues_metadado',

View File

@ -18,7 +18,9 @@ class CategoryFieldTypes extends TAINACAN_UnitTestCase {
function test_category_field_types() { function test_category_field_types() {
global $Tainacan_Item_Metadata, $Tainacan_Items, $Tainacan_Fields, $Tainacan_Terms; $Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
@ -131,8 +133,8 @@ class CategoryFieldTypes extends TAINACAN_UnitTestCase {
} }
function test_relate_taxonomy() { function test_relate_taxonomy() {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
global $Tainacan_Item_Metadata, $Tainacan_Items, $Tainacan_Fields, $Tainacan_Terms, $Tainacan_Taxonomies; $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',

View File

@ -18,7 +18,8 @@ class CoreFieldTypes extends TAINACAN_UnitTestCase {
function test_core_field_types() { function test_core_field_types() {
global $Tainacan_Item_Metadata, $Tainacan_Items; $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',

View File

@ -17,7 +17,7 @@ class DefaultCapabilities extends TAINACAN_UnitTestCase {
function test_capabilities_present() { function test_capabilities_present() {
global $Tainacan_Capabilities; $Tainacan_Capabilities = \Tainacan\Capabilities::getInstance();
$c = new \Tainacan\Entities\Collection(); $c = new \Tainacan\Entities\Collection();
$caps = $c->get_capabilities(); $caps = $c->get_capabilities();

View File

@ -202,7 +202,8 @@ class Fields extends TAINACAN_UnitTestCase {
* *
*/ */
function test_ordenation_fields(){ function test_ordenation_fields(){
global $Tainacan_Collections, $Tainacan_Fields; $Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',

View File

@ -37,7 +37,8 @@ class ImporterTests extends TAINACAN_UnitTestCase {
* @group importer * @group importer
*/ */
public function test_file_csv () { public function test_file_csv () {
global $Tainacan_Fields, $Tainacan_Items; $Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$csv_importer = new Importer\CSV(); $csv_importer = new Importer\CSV();
$id = $csv_importer->get_id(); $id = $csv_importer->get_id();

View File

@ -18,7 +18,8 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
*/ */
function test_add() { function test_add() {
global $Tainacan_Fields, $Tainacan_Item_Metadata; $Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
@ -68,7 +69,8 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
* Teste da insercao de um metadado simples com o tipo * Teste da insercao de um metadado simples com o tipo
*/ */
function teste_required(){ function teste_required(){
global $Tainacan_Fields, $Tainacan_Item_Metadata; $Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
@ -121,7 +123,8 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
} }
function teste_collection_key(){ function teste_collection_key(){
global $Tainacan_Fields, $Tainacan_Item_Metadata; $Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',

View File

@ -135,7 +135,8 @@ class PrivateObjects extends TAINACAN_UnitTestCase {
$new_contributor_user = $this->factory()->user->create(array( 'role' => 'contributor' )); $new_contributor_user = $this->factory()->user->create(array( 'role' => 'contributor' ));
wp_set_current_user($new_contributor_user); wp_set_current_user($new_contributor_user);
global $Tainacan_Items, $Tainacan_Collections; $Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$items = $Tainacan_Items->fetch([], $collection); $items = $Tainacan_Items->fetch([], $collection);
$this->assertEquals(2, $items->found_posts, 'items of a public collections should be visible'); $this->assertEquals(2, $items->found_posts, 'items of a public collections should be visible');

View File

@ -40,7 +40,8 @@ class Taxonomies extends TAINACAN_UnitTestCase {
} }
function test_add_term_taxonomy(){ function test_add_term_taxonomy(){
global $Tainacan_Taxonomies, $Tainacan_Terms; $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
$taxonomy = $this->tainacan_entity_factory->create_entity( $taxonomy = $this->tainacan_entity_factory->create_entity(
'taxonomy', 'taxonomy',