Fixes error on test api filters and changes the condition for delete a object to non strict
This commit is contained in:
parent
dc5e8c597c
commit
2c8def795d
|
@ -142,7 +142,7 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
|
|
||||||
$filter_obj->set_collection_id( $collection_id );
|
$filter_obj->set_collection_id( $collection_id );
|
||||||
|
|
||||||
if(!$body['field']){
|
if(!isset($body['field'])){
|
||||||
throw new \InvalidArgumentException('You need provide a field id');
|
throw new \InvalidArgumentException('You need provide a field id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
} else {
|
} else {
|
||||||
$filter_obj->set_collection_id( 'filter_in_repository' );
|
$filter_obj->set_collection_id( 'filter_in_repository' );
|
||||||
|
|
||||||
if(!$body['field']){
|
if(!isset($body['field'])){
|
||||||
throw new \InvalidArgumentException('You need provide a field id');
|
throw new \InvalidArgumentException('You need provide a field id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ class Collections extends Repository {
|
||||||
* @return mixed|Collection
|
* @return mixed|Collection
|
||||||
*/
|
*/
|
||||||
public function delete( $args ) {
|
public function delete( $args ) {
|
||||||
if ( ! empty( $args[1] ) && $args[1] === true ) {
|
if ( ! empty( $args[1] ) && $args[1] == true ) {
|
||||||
$deleted = new Entities\Collection( wp_delete_post( $args[0], $args[1] ) );
|
$deleted = new Entities\Collection( wp_delete_post( $args[0], $args[1] ) );
|
||||||
|
|
||||||
if($deleted) {
|
if($deleted) {
|
||||||
|
|
|
@ -185,7 +185,7 @@ class Filters extends Repository {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function delete($args){
|
public function delete($args){
|
||||||
if(!empty($args[1]) && $args[1] === true){
|
if(!empty($args[1]) && $args[1] == true){
|
||||||
|
|
||||||
$deleted = new Entities\Filter(wp_delete_post($args[0], $args[1]));
|
$deleted = new Entities\Filter(wp_delete_post($args[0], $args[1]));
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ class Taxonomies extends Repository {
|
||||||
$taxonomy_name = $args[1];
|
$taxonomy_name = $args[1];
|
||||||
$permanently = $args[2];
|
$permanently = $args[2];
|
||||||
|
|
||||||
if($permanently === true){
|
if($permanently == true){
|
||||||
$unregistered = unregister_taxonomy($taxonomy_name);
|
$unregistered = unregister_taxonomy($taxonomy_name);
|
||||||
|
|
||||||
if($unregistered instanceof \WP_Error){
|
if($unregistered instanceof \WP_Error){
|
||||||
|
|
|
@ -257,13 +257,46 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_create_and_fetch_filter_in_repository(){
|
public function test_create_and_fetch_filter_in_repository(){
|
||||||
|
|
||||||
|
$collection = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'collection',
|
||||||
|
array(
|
||||||
|
'name' => 'Collection filtered',
|
||||||
|
'description' => 'Is filtered',
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$field = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'field',
|
||||||
|
array(
|
||||||
|
'name' => 'Field filtered',
|
||||||
|
'description' => 'Is filtered',
|
||||||
|
'collection_id' => $collection->get_id(),
|
||||||
|
'field_type' => 'Tainacan\Field_Types\Text'
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$field2 = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'field',
|
||||||
|
array(
|
||||||
|
'name' => 'Field filtered',
|
||||||
|
'description' => 'Is filtered',
|
||||||
|
'collection_id' => 'default',
|
||||||
|
'field_type' => 'Tainacan\Field_Types\Text'
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
$filter_attr = json_encode([
|
$filter_attr = json_encode([
|
||||||
'filter_type' => 'autocomplete',
|
'filter_type' => 'autocomplete',
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'name' => '2x Filter',
|
'name' => '2x Filter',
|
||||||
'description' => 'Description of 2x Filter',
|
'description' => 'Description of 2x Filter',
|
||||||
'status' => 'publish'
|
'status' => 'publish'
|
||||||
]
|
],
|
||||||
|
'field' => $field2->get_id()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$filter_attr2 = json_encode([
|
$filter_attr2 = json_encode([
|
||||||
|
@ -272,7 +305,8 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
'name' => '4x Filter',
|
'name' => '4x Filter',
|
||||||
'description' => 'Description of 4x Filter',
|
'description' => 'Description of 4x Filter',
|
||||||
'status' => 'publish'
|
'status' => 'publish'
|
||||||
]
|
],
|
||||||
|
'field' => $field->get_id()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#### CREATE A FILTER IN REPOSITORY ####
|
#### CREATE A FILTER IN REPOSITORY ####
|
||||||
|
|
Loading…
Reference in New Issue