php 8.3: fix call function and fix tests
This commit is contained in:
parent
368b8d81a0
commit
475affd462
|
@ -1025,7 +1025,8 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
'status' => 'draft'
|
'status' => 'draft'
|
||||||
];
|
];
|
||||||
|
|
||||||
$body = json_decode($request->get_body(), true);
|
$data_body = $request->get_body() ?? '';
|
||||||
|
$body = json_decode($data_body, true);
|
||||||
|
|
||||||
if (!is_array($body)) {
|
if (!is_array($body)) {
|
||||||
$body = [];
|
$body = [];
|
||||||
|
@ -1178,7 +1179,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
}
|
}
|
||||||
return $new_term;
|
return $new_term;
|
||||||
}
|
}
|
||||||
return count($split_value) > 1 ? $value : filter_var($value, FILTER_SANITIZE_STRING);
|
return count($split_value) > 1 ? $value : htmlspecialchars($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function submission_rollback_new_terms () {
|
private function submission_rollback_new_terms () {
|
||||||
|
@ -1193,7 +1194,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
$item = json_decode($request->get_body(), true);
|
$item = json_decode($request->get_body(), true);
|
||||||
$metadata = $item['metadata'];
|
$metadata = $item['metadata'];
|
||||||
foreach ($item as $key => $value) {
|
foreach ($item as $key => $value) {
|
||||||
$item[$key] = ( is_string($value) && !is_numeric($value) ? filter_var($value, FILTER_SANITIZE_STRING) : $value );
|
$item[$key] = ( is_string($value) && !is_numeric($value) ? htmlspecialchars($value) : $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
$response_recaptcha = $this->submission_item_check_recaptcha($request);
|
$response_recaptcha = $this->submission_item_check_recaptcha($request);
|
||||||
|
@ -1236,7 +1237,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
$child_value = implode(' ', $child_value);
|
$child_value = implode(' ', $child_value);
|
||||||
}
|
}
|
||||||
if (is_numeric($value) != true) {
|
if (is_numeric($value) != true) {
|
||||||
$child_value = filter_var($child_value, FILTER_SANITIZE_STRING);
|
$child_value = htmlspecialchars($child_value);
|
||||||
}
|
}
|
||||||
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
||||||
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
||||||
|
@ -1258,7 +1259,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
$child_value = implode(' ', $child_value);
|
$child_value = implode(' ', $child_value);
|
||||||
}
|
}
|
||||||
if (is_numeric($value) != true) {
|
if (is_numeric($value) != true) {
|
||||||
$child_value = filter_var($child_value, FILTER_SANITIZE_STRING);
|
$child_value = htmlspecialchars($child_value);
|
||||||
}
|
}
|
||||||
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
||||||
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
||||||
|
@ -1291,9 +1292,9 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (is_array($value) == true) {
|
if (is_array($value) == true) {
|
||||||
$value = array_map( function($v) { return is_numeric($v) ? $v : filter_var($v, FILTER_SANITIZE_STRING); }, $value);
|
$value = array_map( function($v) { return is_numeric($v) ? $v : htmlspecialchars($v); }, $value);
|
||||||
} else if (is_numeric($value) != true) {
|
} else if (is_numeric($value) != true) {
|
||||||
$value = filter_var($value, FILTER_SANITIZE_STRING);
|
$value = htmlspecialchars($value);
|
||||||
}
|
}
|
||||||
if ($item_metadata->is_multiple()) {
|
if ($item_metadata->is_multiple()) {
|
||||||
$item_metadata->set_value( is_array($value) ? $value : [$value] );
|
$item_metadata->set_value( is_array($value) ? $value : [$value] );
|
||||||
|
|
|
@ -91,8 +91,8 @@ class Collection extends Entity {
|
||||||
$array_collection['header_image'] = $this->get_header_image();
|
$array_collection['header_image'] = $this->get_header_image();
|
||||||
$array_collection['author_name'] = $this->get_author_name();
|
$array_collection['author_name'] = $this->get_author_name();
|
||||||
$array_collection['url'] = $this->get_url();
|
$array_collection['url'] = $this->get_url();
|
||||||
$array_collection['creation_date'] = $this->get_date_i18n( explode( ' ', $array_collection['creation_date'] )[0] );
|
$array_collection['creation_date'] = $this->get_date_i18n( explode( ' ', $array_collection['creation_date'] ?? '' )[0] );
|
||||||
$array_collection['modification_date'] = $this->get_date_i18n( explode( ' ', $array_collection['modification_date'] )[0] );
|
$array_collection['modification_date'] = $this->get_date_i18n( explode( ' ', $array_collection['modification_date'] ?? '' )[0] );
|
||||||
|
|
||||||
return apply_filters('tainacan-collection-to-array', $array_collection, $this);
|
return apply_filters('tainacan-collection-to-array', $array_collection, $this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ class Filter extends Entity {
|
||||||
function get_filter_type_object(){
|
function get_filter_type_object(){
|
||||||
$class_name = $this->get_filter_type();
|
$class_name = $this->get_filter_type();
|
||||||
|
|
||||||
if( !class_exists( $class_name ) ){
|
if( is_null($class_name) || !class_exists( $class_name ) ){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ class Item extends Entity {
|
||||||
$array_item['_thumbnail_id'] = $this->get__thumbnail_id();
|
$array_item['_thumbnail_id'] = $this->get__thumbnail_id();
|
||||||
$array_item['author_name'] = $this->get_author_name();
|
$array_item['author_name'] = $this->get_author_name();
|
||||||
$array_item['url'] = get_permalink( $this->get_id() );
|
$array_item['url'] = get_permalink( $this->get_id() );
|
||||||
$array_item['creation_date'] = $this->get_date_i18n( explode( ' ', $array_item['creation_date'] )[0] );
|
$array_item['creation_date'] = $this->get_date_i18n( explode( ' ', $array_item['creation_date'] ?? '' )[0] );
|
||||||
$array_item['modification_date'] = $this->get_date_i18n( explode( ' ', $array_item['modification_date'] )[0] );
|
$array_item['modification_date'] = $this->get_date_i18n( explode( ' ', $array_item['modification_date'] ?? '' )[0] );
|
||||||
$array_item['document_mimetype'] = $this->get_document_mimetype();
|
$array_item['document_mimetype'] = $this->get_document_mimetype();
|
||||||
return apply_filters('tainacan-item-to-array', $array_item, $this);
|
return apply_filters('tainacan-item-to-array', $array_item, $this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ class Bulk_Edit_Process extends Generic_Process {
|
||||||
|
|
||||||
$serealize_erro = (object) array('err' => array());
|
$serealize_erro = (object) array('err' => array());
|
||||||
$erro = $item_metadata->get_errors();
|
$erro = $item_metadata->get_errors();
|
||||||
array_walk_recursive($erro, function($v, $k, &$t) {$t->err[] = $v;}, $serealize_erro);
|
array_walk_recursive($erro, function($v, $k, $t) {$t->err[] = $v;}, $serealize_erro);
|
||||||
$this->add_error_log( __('errors: ', 'tainacan') . implode(", ", $serealize_erro->err) );
|
$this->add_error_log( __('errors: ', 'tainacan') . implode(", ", $serealize_erro->err) );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,6 +5,8 @@ use Tainacan;
|
||||||
use Tainacan\Entities;
|
use Tainacan\Entities;
|
||||||
|
|
||||||
class CSV extends Importer {
|
class CSV extends Importer {
|
||||||
|
private $items_repo;
|
||||||
|
|
||||||
public function __construct($attributes = array()) {
|
public function __construct($attributes = array()) {
|
||||||
parent::__construct($attributes);
|
parent::__construct($attributes);
|
||||||
$this->items_repo = \Tainacan\Repositories\Items::get_instance();
|
$this->items_repo = \Tainacan\Repositories\Items::get_instance();
|
||||||
|
@ -487,7 +489,7 @@ class CSV extends Importer {
|
||||||
case 'utf8':
|
case 'utf8':
|
||||||
return $string;
|
return $string;
|
||||||
case 'iso88591':
|
case 'iso88591':
|
||||||
return utf8_encode($string);
|
return mb_convert_encoding($string, 'UTF-8', 'ISO-8859-1');
|
||||||
default:
|
default:
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
@ -1089,11 +1091,11 @@ class CSV extends Importer {
|
||||||
$author = $current_user->user_login;
|
$author = $current_user->user_login;
|
||||||
|
|
||||||
$message = __('imported file:', 'tainacan');
|
$message = __('imported file:', 'tainacan');
|
||||||
$message .= " <b> ${imported_file} </b><br/>";
|
$message .= " <b> $imported_file </b><br/>";
|
||||||
$message .= __('target collections:', 'tainacan');
|
$message .= __('target collections:', 'tainacan');
|
||||||
$message .= " <b>" . implode(", ", $this->get_collections_names() ) . "</b><br/>";
|
$message .= " <b>" . implode(", ", $this->get_collections_names() ) . "</b><br/>";
|
||||||
$message .= __('Imported by:', 'tainacan');
|
$message .= __('Imported by:', 'tainacan');
|
||||||
$message .= " <b> ${author} </b><br/>";
|
$message .= " <b> $author </b><br/>";
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,14 @@
|
||||||
namespace Tainacan\Importer;
|
namespace Tainacan\Importer;
|
||||||
use \Tainacan\Entities;
|
use \Tainacan\Entities;
|
||||||
|
|
||||||
class Old_Tainacan extends Importer{
|
class Old_Tainacan extends Importer {
|
||||||
|
|
||||||
|
protected $tax_repo;
|
||||||
|
protected $col_repo;
|
||||||
|
protected $items_repo;
|
||||||
|
protected $metadata_repo;
|
||||||
|
protected $term_repo;
|
||||||
|
protected $item_metadata_repo;
|
||||||
|
|
||||||
protected $steps = [
|
protected $steps = [
|
||||||
[
|
[
|
||||||
|
@ -443,7 +450,7 @@ class Old_Tainacan extends Importer{
|
||||||
$info = $this->requester( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items", $args );
|
$info = $this->requester( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items", $args );
|
||||||
|
|
||||||
if( !isset($info['body']) ){
|
if( !isset($info['body']) ){
|
||||||
$this->add_error_log($result->get_error_message());
|
$this->add_error_log($info->get_error_message());
|
||||||
$this->add_error_log('Error in fetch remote total items');
|
$this->add_error_log('Error in fetch remote total items');
|
||||||
$this->abort();
|
$this->abort();
|
||||||
return false;
|
return false;
|
||||||
|
@ -474,7 +481,7 @@ class Old_Tainacan extends Importer{
|
||||||
$info = wp_remote_get( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items?includeMetadata=1&filter[page]=" . $page, $args );
|
$info = wp_remote_get( $this->get_url() . $this->tainacan_api_address . "/collections/".$collection_id."/items?includeMetadata=1&filter[page]=" . $page, $args );
|
||||||
|
|
||||||
if( !isset($info['body']) ){
|
if( !isset($info['body']) ){
|
||||||
$this->add_error_log($result->get_error_message());
|
$this->add_error_log($info->get_error_message());
|
||||||
$this->add_error_log('Error in fetch remote first page item');
|
$this->add_error_log('Error in fetch remote first page item');
|
||||||
$this->abort();
|
$this->abort();
|
||||||
return false;
|
return false;
|
||||||
|
@ -493,7 +500,7 @@ class Old_Tainacan extends Importer{
|
||||||
$info = json_decode($info['body']);
|
$info = json_decode($info['body']);
|
||||||
|
|
||||||
if( !isset($info['body']) ){
|
if( !isset($info['body']) ){
|
||||||
$this->add_error_log($result->get_error_message());
|
$this->add_error_log($info->get_error_message());
|
||||||
$this->add_error_log('Error in fetch remote ' . $page . ' page item');
|
$this->add_error_log('Error in fetch remote ' . $page . ' page item');
|
||||||
$this->abort();
|
$this->abort();
|
||||||
return false;
|
return false;
|
||||||
|
@ -613,7 +620,7 @@ class Old_Tainacan extends Importer{
|
||||||
if (is_wp_error($result)) {
|
if (is_wp_error($result)) {
|
||||||
|
|
||||||
$this->add_log($result->get_error_message());
|
$this->add_log($result->get_error_message());
|
||||||
$this->add_log('Error in fetch remote' . $url);
|
$this->add_log('Error in fetch remote' . $link);
|
||||||
$this->add_log('request number ' . $requests);
|
$this->add_log('request number ' . $requests);
|
||||||
|
|
||||||
} else if (isset($result['body'])){
|
} else if (isset($result['body'])){
|
||||||
|
@ -644,7 +651,7 @@ class Old_Tainacan extends Importer{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->add_error_log('Error in fetch remote, expired the 10 requests limit ' . $url);
|
$this->add_error_log('Error in fetch remote, expired the 10 requests limit ' . $link);
|
||||||
$this->abort();
|
$this->abort();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -713,10 +720,9 @@ class Old_Tainacan extends Importer{
|
||||||
* @return int $metadatum_id
|
* @return int $metadatum_id
|
||||||
*/
|
*/
|
||||||
protected function create_metadata( $node_metadata_old, $collection_id = null){
|
protected function create_metadata( $node_metadata_old, $collection_id = null){
|
||||||
$this->add_log('Creating metadata' . $meta->name);
|
|
||||||
|
|
||||||
$newMetadatum = new Entities\Metadatum();
|
$newMetadatum = new Entities\Metadatum();
|
||||||
$meta = $node_metadata_old;
|
$meta = $node_metadata_old;
|
||||||
|
$this->add_log('Creating metadata' . $meta->name);
|
||||||
|
|
||||||
$name = $meta->name;
|
$name = $meta->name;
|
||||||
$type = $this->define_type($meta->type);
|
$type = $this->define_type($meta->type);
|
||||||
|
@ -856,7 +862,7 @@ class Old_Tainacan extends Importer{
|
||||||
/**
|
/**
|
||||||
* create attachments, document and thumb from old
|
* create attachments, document and thumb from old
|
||||||
*
|
*
|
||||||
* @param string $node_old
|
* @param Object $node_old
|
||||||
*
|
*
|
||||||
* @return string the class name
|
* @return string the class name
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -137,7 +137,8 @@ class Mappers_Handler {
|
||||||
* @return Mappers\Mapper|boolean false
|
* @return Mappers\Mapper|boolean false
|
||||||
*/
|
*/
|
||||||
public static function get_mapper_from_request($request) {
|
public static function get_mapper_from_request($request) {
|
||||||
$body = json_decode( $request->get_body(), true );
|
$data_body = $request->get_body() ?? '';
|
||||||
|
$body = json_decode( $data_body, true );
|
||||||
$Tainacan_Mappers = self::get_instance();
|
$Tainacan_Mappers = self::get_instance();
|
||||||
$query_url_params = $request->get_query_params();
|
$query_url_params = $request->get_query_params();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ class Collections extends Repository {
|
||||||
public $entities_type = '\Tainacan\Entities\Collection';
|
public $entities_type = '\Tainacan\Entities\Collection';
|
||||||
|
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
|
private $old_collection;
|
||||||
|
private $old_core_title;
|
||||||
|
private $old_core_description;
|
||||||
|
|
||||||
public static function get_instance() {
|
public static function get_instance() {
|
||||||
if ( ! isset( self::$instance ) ) {
|
if ( ! isset( self::$instance ) ) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ use \Respect\Validation\Validator as v;
|
||||||
class Metadata extends Repository {
|
class Metadata extends Repository {
|
||||||
public $entities_type = '\Tainacan\Entities\Metadatum';
|
public $entities_type = '\Tainacan\Entities\Metadatum';
|
||||||
protected $default_metadata = 'default';
|
protected $default_metadata = 'default';
|
||||||
|
protected $current_taxonomy;
|
||||||
|
|
||||||
public $metadata_types = [];
|
public $metadata_types = [];
|
||||||
|
|
||||||
|
@ -1384,7 +1385,7 @@ class Metadata extends Repository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$number = ctype_digit($args['number']) && $args['number'] >=1 ? $args['number'] : $total;
|
$number = ctype_digit((string)$args['number']) && $args['number'] >=1 ? $args['number'] : $total;
|
||||||
if( $number < 1){
|
if( $number < 1){
|
||||||
$pages = 1;
|
$pages = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1401,8 +1402,10 @@ class Metadata extends Repository {
|
||||||
$total_items = null;
|
$total_items = null;
|
||||||
|
|
||||||
if ( $args['count_items'] ) {
|
if ( $args['count_items'] ) {
|
||||||
$count_items_query = $args['items_filter'];
|
$count_items_query = array(
|
||||||
$count_items_query['posts_per_page'] = 1;
|
'posts_per_page' => 1
|
||||||
|
);
|
||||||
|
$count_items_query = array_merge($args['items_filter'] != false ? $args['items_filter'] : [], $count_items_query);
|
||||||
if ( !isset($count_items_query['tax_query']) ) {
|
if ( !isset($count_items_query['tax_query']) ) {
|
||||||
$count_items_query['tax_query'] = [];
|
$count_items_query['tax_query'] = [];
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1451,7 @@ class Metadata extends Repository {
|
||||||
|
|
||||||
$results = $wpdb->get_col($query);
|
$results = $wpdb->get_col($query);
|
||||||
$total = $wpdb->get_var($total_query);
|
$total = $wpdb->get_var($total_query);
|
||||||
$number = ctype_digit($args['number']) && $args['number'] >=1 ? $args['number'] : $total;
|
$number = ctype_digit((string)$args['number']) && $args['number'] >=1 ? $args['number'] : $total;
|
||||||
if( $number < 1){
|
if( $number < 1){
|
||||||
$pages = 1;
|
$pages = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1485,7 +1488,7 @@ class Metadata extends Repository {
|
||||||
|
|
||||||
if ( $args['count_items'] ) {
|
if ( $args['count_items'] ) {
|
||||||
$count_items_query = $args['items_filter'];
|
$count_items_query = $args['items_filter'];
|
||||||
$count_items_query['posts_per_page'] = 1;
|
$count_items_query['posts_per_page'] = (int)1;
|
||||||
if ( !isset($count_items_query['meta_query']) ) {
|
if ( !isset($count_items_query['meta_query']) ) {
|
||||||
$count_items_query['meta_query'] = [];
|
$count_items_query['meta_query'] = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -941,7 +941,10 @@ abstract class Repository {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function sanitize_value($content) {
|
protected function sanitize_value($content) {
|
||||||
if (is_numeric($content) || empty($content) ) {
|
if( $content == null ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (is_numeric($content) || empty($content ) ) {
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,8 @@ abstract class Filter_Type {
|
||||||
/**
|
/**
|
||||||
* @param $options
|
* @param $options
|
||||||
*/
|
*/
|
||||||
public function set_options( $options ){
|
public function set_options( $options ) {
|
||||||
|
$options = $options ?? '';
|
||||||
$this->options = ( is_array( $options ) ) ? $options : (!is_array(unserialize( $options )) ? [] : unserialize( $options ));
|
$this->options = ( is_array( $options ) ) ? $options : (!is_array(unserialize( $options )) ? [] : unserialize( $options ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,8 @@ abstract class Metadata_Type {
|
||||||
/**
|
/**
|
||||||
* @param $options
|
* @param $options
|
||||||
*/
|
*/
|
||||||
public function set_options( $options ){
|
public function set_options( $options ) {
|
||||||
|
$options = $options ?? '';
|
||||||
$this->options = ( is_array( $options ) ) ? $options : (!is_array(unserialize( $options )) ? [] : unserialize( $options ));
|
$this->options = ( is_array( $options ) ) ? $options : (!is_array(unserialize( $options )) ? [] : unserialize( $options ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class BulkEdit extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
public $items_ids = [];
|
public $items_ids = [];
|
||||||
|
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$collection = $this->tainacan_entity_factory->create_entity(
|
$collection = $this->tainacan_entity_factory->create_entity(
|
||||||
'collection',
|
'collection',
|
||||||
|
|
|
@ -20,7 +20,15 @@ class TAINACAN_UnitApiTestCase extends TAINACAN_UnitTestCase {
|
||||||
*/
|
*/
|
||||||
protected $namespace = '/tainacan/v2';
|
protected $namespace = '/tainacan/v2';
|
||||||
|
|
||||||
public function setUp(){
|
public $collection;
|
||||||
|
public $metadatum;
|
||||||
|
public $item;
|
||||||
|
public $multiple_meta;
|
||||||
|
public $taxonomy;
|
||||||
|
public $category;
|
||||||
|
public $api_baseroute;
|
||||||
|
|
||||||
|
public function setUp() : void{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
global $wp_rest_server;
|
global $wp_rest_server;
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Tainacan\Tests;
|
||||||
|
|
||||||
use Tainacan\Tests\Factories;
|
use Tainacan\Tests\Factories;
|
||||||
|
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
class TAINACAN_UnitTestCase extends \WP_UnitTestCase {
|
class TAINACAN_UnitTestCase extends \WP_UnitTestCase {
|
||||||
protected $tainacan_entity_factory;
|
protected $tainacan_entity_factory;
|
||||||
protected $tainacan_metadatum_factory;
|
protected $tainacan_metadatum_factory;
|
||||||
|
@ -11,7 +12,7 @@ class TAINACAN_UnitTestCase extends \WP_UnitTestCase {
|
||||||
protected $tainacan_item_metadata_factory;
|
protected $tainacan_item_metadata_factory;
|
||||||
protected $user_id;
|
protected $user_id;
|
||||||
|
|
||||||
public function setUp(){
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->tainacan_entity_factory = new Factories\Entity_Factory();
|
$this->tainacan_entity_factory = new Factories\Entity_Factory();
|
||||||
$this->tainacan_metadatum_factory = new Factories\Metadatum_Factory();
|
$this->tainacan_metadatum_factory = new Factories\Metadatum_Factory();
|
||||||
|
|
|
@ -7,7 +7,10 @@ namespace Tainacan\Tests;
|
||||||
*/
|
*/
|
||||||
class TAINACAN_REST_Compound_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
class TAINACAN_REST_Compound_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
function setUp() {
|
public $collection;
|
||||||
|
public $item;
|
||||||
|
|
||||||
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->collection = $this->tainacan_entity_factory->create_entity(
|
$this->collection = $this->tainacan_entity_factory->create_entity(
|
||||||
|
|
|
@ -6,8 +6,11 @@ namespace Tainacan\Tests;
|
||||||
* @group api
|
* @group api
|
||||||
*/
|
*/
|
||||||
class TAINACAN_REST_Items_Submission extends TAINACAN_UnitApiTestCase {
|
class TAINACAN_REST_Items_Submission extends TAINACAN_UnitApiTestCase {
|
||||||
|
private $col_user_anonymous;
|
||||||
|
private $col_user_logged;
|
||||||
|
private $collections_metadatum;
|
||||||
|
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// collections:
|
// collections:
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace Tainacan\Tests;
|
||||||
*/
|
*/
|
||||||
class TAINACAN_REST_Metadatum_Mappers_Controller extends TAINACAN_UnitApiTestCase {
|
class TAINACAN_REST_Metadatum_Mappers_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
|
private $metadatum2;
|
||||||
|
private $metadatum3;
|
||||||
|
|
||||||
protected function create_meta_requirements() {
|
protected function create_meta_requirements() {
|
||||||
$collection = $this->tainacan_entity_factory->create_entity(
|
$collection = $this->tainacan_entity_factory->create_entity(
|
||||||
'collection',
|
'collection',
|
||||||
|
|
|
@ -7,6 +7,8 @@ namespace Tainacan\Tests;
|
||||||
*/
|
*/
|
||||||
class TAINACAN_REST_Private_Files extends TAINACAN_UnitApiTestCase {
|
class TAINACAN_REST_Private_Files extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
|
public $test_file;
|
||||||
|
|
||||||
public function test_create_item() {
|
public function test_create_item() {
|
||||||
|
|
||||||
$orig_file = './tests/attachment/codeispoetrywp.jpg';
|
$orig_file = './tests/attachment/codeispoetrywp.jpg';
|
||||||
|
@ -58,8 +60,7 @@ class TAINACAN_REST_Private_Files extends TAINACAN_UnitApiTestCase {
|
||||||
$attachment_data = wp_get_attachment_metadata($attachment->ID);
|
$attachment_data = wp_get_attachment_metadata($attachment->ID);
|
||||||
|
|
||||||
$folder = 'tainacan-items/' . $this->collection->get_id() . '/' . $this->item->get_id();
|
$folder = 'tainacan-items/' . $this->collection->get_id() . '/' . $this->item->get_id();
|
||||||
|
$this->assertStringStartsWith( $folder, $attachment_data['file'] );
|
||||||
$this->assertContains( $folder, $attachment_data['file'] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_internal_api() {
|
function test_internal_api() {
|
||||||
|
@ -91,8 +92,7 @@ class TAINACAN_REST_Private_Files extends TAINACAN_UnitApiTestCase {
|
||||||
$attachment_id = \Tainacan\Media::get_instance()->insert_attachment_from_file($this->test_file, $this->item->get_id());
|
$attachment_id = \Tainacan\Media::get_instance()->insert_attachment_from_file($this->test_file, $this->item->get_id());
|
||||||
$attachment_data = wp_get_attachment_metadata($attachment_id);
|
$attachment_data = wp_get_attachment_metadata($attachment_id);
|
||||||
$folder = 'tainacan-items/' . $this->collection->get_id() . '/' . $this->item->get_id();
|
$folder = 'tainacan-items/' . $this->collection->get_id() . '/' . $this->item->get_id();
|
||||||
|
$this->assertStringStartsWith( $folder, $attachment_data['file'] );
|
||||||
$this->assertContains( $folder, $attachment_data['file'] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Tainacan\Tests;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class TAINACAN_REST_Roles_Controller extends TAINACAN_UnitApiTestCase {
|
class TAINACAN_REST_Roles_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
// reset WP_Roles object. Possible bug was cleaning database between tests, but not the object
|
// reset WP_Roles object. Possible bug was cleaning database between tests, but not the object
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Tainacan\Tests;
|
||||||
* @group api
|
* @group api
|
||||||
* **/
|
* **/
|
||||||
class TAINACAN_REST_Search extends TAINACAN_UnitApiTestCase {
|
class TAINACAN_REST_Search extends TAINACAN_UnitApiTestCase {
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||||
|
|
|
@ -10,8 +10,11 @@ use Tainacan\Entities;
|
||||||
class SequenceEdit extends TAINACAN_UnitApiTestCase {
|
class SequenceEdit extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
public $items_ids = [];
|
public $items_ids = [];
|
||||||
|
public $collection;
|
||||||
|
public $metadatum;
|
||||||
|
public $api_baseroute;
|
||||||
|
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$collection = $this->tainacan_entity_factory->create_entity(
|
$collection = $this->tainacan_entity_factory->create_entity(
|
||||||
'collection',
|
'collection',
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TAINACAN_REST_Visibilility_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
public $term_public;
|
public $term_public;
|
||||||
public $term_private;
|
public $term_private;
|
||||||
|
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$taxonomy_public = $this->tainacan_entity_factory->create_entity(
|
$taxonomy_public = $this->tainacan_entity_factory->create_entity(
|
||||||
|
|
|
@ -17,7 +17,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
public $items_ids = [];
|
public $items_ids = [];
|
||||||
|
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$collection = $this->tainacan_entity_factory->create_entity(
|
$collection = $this->tainacan_entity_factory->create_entity(
|
||||||
'collection',
|
'collection',
|
||||||
|
@ -263,7 +263,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
//$bulk->add_value($this->multiple_meta, 'super');
|
//$bulk->add_value($this->multiple_meta, 'super');
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
'tax_query' => [
|
'tax_query' => [
|
||||||
|
@ -431,7 +431,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$query = [
|
$query = [
|
||||||
'meta_query' => [
|
'meta_query' => [
|
||||||
|
@ -456,7 +456,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -500,7 +500,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -570,7 +570,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -632,7 +632,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]);
|
]);
|
||||||
$this->assertEquals(0, $items->found_posts);
|
$this->assertEquals(0, $items->found_posts);
|
||||||
|
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
'meta_query' => [
|
'meta_query' => [
|
||||||
|
@ -676,7 +676,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->category->get_id(),
|
"metadatum_id" => $this->category->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$process = $this->new_process(
|
$process = $this->new_process(
|
||||||
[
|
[
|
||||||
|
@ -690,7 +690,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->category->get_id(),
|
"metadatum_id" => $this->category->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
// should add super only to the 20 items that had test
|
// should add super only to the 20 items that had test
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -741,7 +741,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->metadatum->get_id(),
|
"metadatum_id" => $this->metadatum->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
// should add super only to the 20 items that had even
|
// should add super only to the 20 items that had even
|
||||||
|
@ -794,7 +794,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// all items selected, search and replace the value of one
|
// all items selected, search and replace the value of one
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
'meta_query' => [
|
'meta_query' => [
|
||||||
|
@ -839,7 +839,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->category->get_id(),
|
"metadatum_id" => $this->category->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
'tax_query' => [
|
'tax_query' => [
|
||||||
|
@ -910,7 +910,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->metadatum->get_id(),
|
"metadatum_id" => $this->metadatum->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
'meta_query' => [
|
'meta_query' => [
|
||||||
|
@ -967,7 +967,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -1002,7 +1002,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->multiple_meta->get_id(),
|
"metadatum_id" => $this->multiple_meta->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$process = $this->new_process(
|
$process = $this->new_process(
|
||||||
[
|
[
|
||||||
|
@ -1015,7 +1015,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->multiple_meta->get_id(),
|
"metadatum_id" => $this->multiple_meta->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$ids = array_slice($this->items_ids, 2, 7);
|
$ids = array_slice($this->items_ids, 2, 7);
|
||||||
|
@ -1032,7 +1032,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->multiple_meta->get_id(),
|
"metadatum_id" => $this->multiple_meta->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1095,7 +1095,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $core_title->get_id(),
|
"metadatum_id" => $core_title->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$process = $this->new_process(
|
$process = $this->new_process(
|
||||||
[
|
[
|
||||||
|
@ -1108,7 +1108,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $core_description->get_id(),
|
"metadatum_id" => $core_description->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
'meta_query' => [
|
'meta_query' => [
|
||||||
|
@ -1171,7 +1171,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||||
|
|
||||||
|
@ -1219,7 +1219,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$trashed = $Tainacan_Items->fetch_ids(['post_status' => 'trash', 'posts_per_page' => -1]);
|
$trashed = $Tainacan_Items->fetch_ids(['post_status' => 'trash', 'posts_per_page' => -1]);
|
||||||
$rest = $Tainacan_Items->fetch_ids(['posts_per_page' => -1]);
|
$rest = $Tainacan_Items->fetch_ids(['posts_per_page' => -1]);
|
||||||
|
@ -1238,7 +1238,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$trashed = $Tainacan_Items->fetch_ids(['post_status' => 'trash', 'posts_per_page' => -1]);
|
$trashed = $Tainacan_Items->fetch_ids(['post_status' => 'trash', 'posts_per_page' => -1]);
|
||||||
$private = $Tainacan_Items->fetch_ids(['post_status' => 'private', 'posts_per_page' => -1]);
|
$private = $Tainacan_Items->fetch_ids(['post_status' => 'private', 'posts_per_page' => -1]);
|
||||||
|
@ -1272,7 +1272,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch_ids(['posts_per_page' => -1]);
|
$items = $Tainacan_Items->fetch_ids(['posts_per_page' => -1]);
|
||||||
$this->assertEquals(40, sizeof($items), 'Items must be on trash to be deleted');
|
$this->assertEquals(40, sizeof($items), 'Items must be on trash to be deleted');
|
||||||
|
@ -1288,7 +1288,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$process = $this->new_process(
|
$process = $this->new_process(
|
||||||
|
@ -1302,7 +1302,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$trashed = $Tainacan_Items->fetch_ids(['post_status' => 'trash', 'posts_per_page' => -1]);
|
$trashed = $Tainacan_Items->fetch_ids(['post_status' => 'trash', 'posts_per_page' => -1]);
|
||||||
|
@ -1341,7 +1341,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->category->get_id(),
|
"metadatum_id" => $this->category->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
|
||||||
|
@ -1369,7 +1369,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->category->get_id(),
|
"metadatum_id" => $this->category->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
|
||||||
|
@ -1430,7 +1430,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $category2->get_id(),
|
"metadatum_id" => $category2->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -1458,7 +1458,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $category2->get_id(),
|
"metadatum_id" => $category2->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
|
||||||
|
@ -1550,7 +1550,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->category->get_id(),
|
"metadatum_id" => $this->category->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -1634,7 +1634,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->metadatum->get_id(),
|
"metadatum_id" => $this->metadatum->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
// single valued metadatum dont accept array
|
// single valued metadatum dont accept array
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -1672,7 +1672,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => $this->multiple_meta->get_id(),
|
"metadatum_id" => $this->multiple_meta->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
|
@ -1730,7 +1730,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$query = [
|
$query = [
|
||||||
|
@ -1756,7 +1756,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id" => null,
|
"metadatum_id" => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch([
|
$items = $Tainacan_Items->fetch([
|
||||||
'comment_status' => 'closed',
|
'comment_status' => 'closed',
|
||||||
|
@ -1822,7 +1822,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id_from" => $this->metadatum->get_id(),
|
"metadatum_id_from" => $this->metadatum->get_id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
$query = [
|
$query = [
|
||||||
'meta_query' => [
|
'meta_query' => [
|
||||||
|
@ -1847,7 +1847,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id_from" => 'created_by',
|
"metadatum_id_from" => 'created_by',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
$query = [
|
$query = [
|
||||||
'meta_query' => [
|
'meta_query' => [
|
||||||
[
|
[
|
||||||
|
@ -1897,7 +1897,7 @@ class BulkEditBgProcess extends TAINACAN_UnitApiTestCase {
|
||||||
"metadatum_id_from" => $this->category->get_id()
|
"metadatum_id_from" => $this->category->get_id()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->assertInternalType('int', $this->run_process($process));
|
$this->assertIsInt($this->run_process($process));
|
||||||
|
|
||||||
|
|
||||||
$query = [
|
$query = [
|
||||||
|
|
|
@ -13,9 +13,10 @@ use Tainacan\Entities\Collection;
|
||||||
/**
|
/**
|
||||||
* @group permissions
|
* @group permissions
|
||||||
*/
|
*/
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
class Capabilities extends TAINACAN_UnitTestCase {
|
class Capabilities extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -857,7 +858,7 @@ class Capabilities extends TAINACAN_UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group collectionss
|
* @group collections
|
||||||
*/
|
*/
|
||||||
function test_manage_collection_can_edit_collection() {
|
function test_manage_collection_can_edit_collection() {
|
||||||
global $current_user;
|
global $current_user;
|
||||||
|
|
|
@ -127,7 +127,7 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
$this->assertFalse($metadatum2->validate(), 'Taxonomy Metadatum should not validate when using a taxonomy in use by another metadatum in the same collection');
|
$this->assertFalse($metadatum2->validate(), 'Taxonomy Metadatum should not validate when using a taxonomy in use by another metadatum in the same collection');
|
||||||
$errors = $metadatum2->get_errors();
|
$errors = $metadatum2->get_errors();
|
||||||
$this->assertInternalType('array', $errors);
|
$this->assertIsArray($errors);
|
||||||
$this->assertArrayHasKey('taxonomy_id', $errors[0]['metadata_type_options']);
|
$this->assertArrayHasKey('taxonomy_id', $errors[0]['metadata_type_options']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
|
|
||||||
$checkTax = $Tainacan_Taxonomies->fetch($tax->get_id());
|
$checkTax = $Tainacan_Taxonomies->fetch($tax->get_id());
|
||||||
$this->assertContains($collection->get_id(), $checkTax->get_collections_ids(), 'Collection must be added to taxonomy when metadatum is created');
|
$this->assertContains((string)$collection->get_id(), $checkTax->get_collections_ids(), 'Collection must be added to taxonomy when metadatum is created');
|
||||||
|
|
||||||
|
|
||||||
$metadatum->set_metadata_type_options([
|
$metadatum->set_metadata_type_options([
|
||||||
|
@ -206,14 +206,14 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
$checkTax = $Tainacan_Taxonomies->fetch($tax->get_id());
|
$checkTax = $Tainacan_Taxonomies->fetch($tax->get_id());
|
||||||
$checkTax2 = $Tainacan_Taxonomies->fetch($tax2->get_id());
|
$checkTax2 = $Tainacan_Taxonomies->fetch($tax2->get_id());
|
||||||
$this->assertContains($collection->get_id(), $checkTax2->get_collections_ids(), 'Collection must be added to taxonomy when metadatum is updated');
|
$this->assertContains((string)$collection->get_id(), $checkTax2->get_collections_ids(), 'Collection must be added to taxonomy when metadatum is updated');
|
||||||
$this->assertNotContains($collection->get_id(), $checkTax->get_collections_ids(), 'Collection must be removed from taxonomy when metadatum is updated');
|
$this->assertNotContains((string)$collection->get_id(), $checkTax->get_collections_ids(), 'Collection must be removed from taxonomy when metadatum is updated');
|
||||||
|
|
||||||
$metadatum = $Tainacan_Metadata->trash($metadatum);
|
$metadatum = $Tainacan_Metadata->trash($metadatum);
|
||||||
|
|
||||||
$checkTax2 = $Tainacan_Taxonomies->fetch($tax2->get_id());
|
$checkTax2 = $Tainacan_Taxonomies->fetch($tax2->get_id());
|
||||||
|
|
||||||
$this->assertNotContains($collection->get_id(), $checkTax2->get_collections_ids(), 'Collection must be removed from taxonomy when metadatum is deleted');
|
$this->assertNotContains((string)$collection->get_id(), $checkTax2->get_collections_ids(), 'Collection must be removed from taxonomy when metadatum is deleted');
|
||||||
|
|
||||||
|
|
||||||
$metadatum_repo = $this->tainacan_entity_factory->create_entity(
|
$metadatum_repo = $this->tainacan_entity_factory->create_entity(
|
||||||
|
@ -590,10 +590,10 @@ class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
$meta = $Tainacan_ItemMetadata->insert($meta);
|
$meta = $Tainacan_ItemMetadata->insert($meta);
|
||||||
|
|
||||||
$this->assertInternalType( 'string', $meta->get_value_as_html() );
|
$this->assertIsString( $meta->get_value_as_html() );
|
||||||
$this->assertInternalType( 'string', $meta->get_value_as_string() );
|
$this->assertIsString( $meta->get_value_as_string() );
|
||||||
|
|
||||||
$this->assertInternalType( 'integer', strpos($meta->get_value_as_html(), '<a ') );
|
$this->assertIsInt( strpos($meta->get_value_as_html(), '<a ') );
|
||||||
$this->assertFalse( strpos($meta->get_value_as_string(), '<a ') );
|
$this->assertFalse( strpos($meta->get_value_as_string(), '<a ') );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Tainacan\Tests;
|
||||||
class TestEntities extends TAINACAN_UnitTestCase {
|
class TestEntities extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
|
|
||||||
function setUp() {
|
function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->collection = $this->tainacan_entity_factory->create_entity(
|
$this->collection = $this->tainacan_entity_factory->create_entity(
|
||||||
'collection',
|
'collection',
|
||||||
|
|
|
@ -79,7 +79,7 @@ class Facets extends TAINACAN_UnitApiTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function setUp() {
|
function setUp() : void{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$collection1 = $this->tainacan_entity_factory->create_entity(
|
$collection1 = $this->tainacan_entity_factory->create_entity(
|
||||||
'collection',
|
'collection',
|
||||||
|
|
|
@ -35,7 +35,7 @@ class TAINACAN_HTML_Injection extends TAINACAN_UnitTestCase
|
||||||
private $taxonomy = null;
|
private $taxonomy = null;
|
||||||
private $taxonomy_db = null;
|
private $taxonomy_db = null;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$link = $this->link;
|
$link = $this->link;
|
||||||
|
|
|
@ -282,7 +282,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
||||||
having
|
having
|
||||||
multiple
|
multiple
|
||||||
lines', 'Data 24', 'Data 25'),
|
lines', 'Data 24', 'Data 25'),
|
||||||
array(get_current_user_id(), 'Data 31', 'Data 32', utf8_decode( 'Data 33||Rééço' ), 'Data 34', 'Data 35'),
|
array(get_current_user_id(), 'Data 31', 'Data 32', mb_convert_encoding('Data 33||Rééço', 'UTF-8', 'ISO-8859-1'), 'Data 34', 'Data 35'),
|
||||||
array(get_current_user_id(), 'Data 41', 'Data 42', 'Data 43||limbbo', 'Data 44', 'Data 45'),
|
array(get_current_user_id(), 'Data 41', 'Data 42', 'Data 43||limbbo', 'Data 44', 'Data 45'),
|
||||||
array(get_current_user_id(), 'Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55>>DATA551')
|
array(get_current_user_id(), 'Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55>>DATA551')
|
||||||
);
|
);
|
||||||
|
@ -447,7 +447,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
||||||
array(
|
array(
|
||||||
'Data 31',
|
'Data 31',
|
||||||
'458',
|
'458',
|
||||||
utf8_decode( 'Data 33||Rééço' ),
|
mb_convert_encoding( 'Data 33||Rééço', 'ISO-8859-1', 'UTF-8' ),
|
||||||
'https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg||https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/58f72418-b5ee-4765-8e80-e463623a921d/01-httparchive-opt-small.png',
|
'https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg||https://cloud.netlifyusercontent.com/assets/344dbf88-fdf9-42bb-adb4-46f01eedd629/58f72418-b5ee-4765-8e80-e463623a921d/01-httparchive-opt-small.png',
|
||||||
'file:https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg'),
|
'file:https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg'),
|
||||||
array('Data 41', '459', 'Data 43||limbbo', 'photos/SamplePNGImage_100kbmb.png||audios/SampleAudio_0.4mb.mp3', 'url:http://www.pdf995.com/samples/pdf.pdf'),
|
array('Data 41', '459', 'Data 43||limbbo', 'photos/SamplePNGImage_100kbmb.png||audios/SampleAudio_0.4mb.mp3', 'url:http://www.pdf995.com/samples/pdf.pdf'),
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
||||||
private $item = null;
|
private $item = null;
|
||||||
private $separator = '<span class="multivalue-separator"> | </span>';
|
private $separator = '<span class="multivalue-separator"> | </span>';
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$c = $this->tainacan_entity_factory->create_entity('collection', ['name' => 'My Collection'], true);
|
$c = $this->tainacan_entity_factory->create_entity('collection', ['name' => 'My Collection'], true);
|
||||||
$i = $this->tainacan_entity_factory->create_entity(
|
$i = $this->tainacan_entity_factory->create_entity(
|
||||||
|
@ -652,7 +652,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
$relationship_metadata->set_multiple('yes');
|
$relationship_metadata->set_multiple('yes');
|
||||||
$item_metadata_relationship->set_value([ $mystify->get_id(), $disappear->get_id() ]);
|
$item_metadata_relationship->set_value([ $mystify->get_id(), $disappear->get_id() ]);
|
||||||
$this->assertEquals($item_metadata_relationship->get_value_as_html(), "${expected_return}" . $this->separator . "${expected_return2}");
|
$this->assertEquals($item_metadata_relationship->get_value_as_html(), "$expected_return" . $this->separator . "$expected_return2");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_taxonomy_metadata_html() {
|
function test_taxonomy_metadata_html() {
|
||||||
|
@ -760,7 +760,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
||||||
private function relationship_expected_return($id, $title) {
|
private function relationship_expected_return($id, $title) {
|
||||||
$URL = get_permalink($id);
|
$URL = get_permalink($id);
|
||||||
|
|
||||||
return "<a data-linkto='item' data-id='${id}' href='${URL}'>${title}</a>";
|
return "<a data-linkto='item' data-id='$id' href='$URL'>$title</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_multiple_with_cardinality() {
|
function test_multiple_with_cardinality() {
|
||||||
|
|
|
@ -19,7 +19,7 @@ class RelationshipMetadatumTypes extends TAINACAN_UnitTestCase {
|
||||||
private $collection_book = null;
|
private $collection_book = null;
|
||||||
private $collection_article = null;
|
private $collection_article = null;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->collection_book = $this->tainacan_entity_factory->create_entity('collection', ['name' => 'Book', 'status' => 'publish'], true);
|
$this->collection_book = $this->tainacan_entity_factory->create_entity('collection', ['name' => 'Book', 'status' => 'publish'], true);
|
||||||
$this->collection_author = $this->tainacan_entity_factory->create_entity('collection', ['name' => 'Author', 'status' => 'publish'], true);
|
$this->collection_author = $this->tainacan_entity_factory->create_entity('collection', ['name' => 'Author', 'status' => 'publish'], true);
|
||||||
|
|
Loading…
Reference in New Issue