Delete category
This commit is contained in:
parent
4bcb108dd2
commit
ec66b0b576
|
@ -93,7 +93,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { mapActions } from 'vuex'
|
import { mapActions } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -118,8 +117,8 @@
|
||||||
this.$dialog.confirm({
|
this.$dialog.confirm({
|
||||||
message: this.$i18n.get('info_warning_category_delete'),
|
message: this.$i18n.get('info_warning_category_delete'),
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
this.deleteCategory(categoryId).then(() => {
|
this.deleteCategory(categoryId)
|
||||||
this.loadCategories();
|
.then((res) => {
|
||||||
this.$toast.open({
|
this.$toast.open({
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
message: this.$i18n.get('info_category_deleted'),
|
message: this.$i18n.get('info_category_deleted'),
|
||||||
|
@ -131,15 +130,16 @@
|
||||||
if (this.selectedCategories[i].id === this.categoryId)
|
if (this.selectedCategories[i].id === this.categoryId)
|
||||||
this.selectedCategories.splice(i, 1);
|
this.selectedCategories.splice(i, 1);
|
||||||
}
|
}
|
||||||
}).catch(() =>
|
})
|
||||||
|
.catch((error) => {
|
||||||
this.$toast.open({
|
this.$toast.open({
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
message: this.$i18n.get('info_error_deleting_category'),
|
message: this.$i18n.get('info_error_deleting_category'),
|
||||||
position: 'is-bottom',
|
position: 'is-bottom',
|
||||||
type: 'is-danger',
|
type: 'is-danger',
|
||||||
queue: true
|
queue: true
|
||||||
})
|
});
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -95,7 +95,6 @@ export default {
|
||||||
message: this.$i18n.get('info_warning_collection_delete'),
|
message: this.$i18n.get('info_warning_collection_delete'),
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
this.deleteCollection(collectionId).then(() => {
|
this.deleteCollection(collectionId).then(() => {
|
||||||
this.loadCollections();
|
|
||||||
this.$toast.open({
|
this.$toast.open({
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
message: this.$i18n.get('info_collection_deleted'),
|
message: this.$i18n.get('info_collection_deleted'),
|
||||||
|
|
|
@ -137,10 +137,13 @@ return [
|
||||||
'info_no_category_created' => __( 'No category was created in this repository.', 'tainacan' ),
|
'info_no_category_created' => __( 'No category was created in this repository.', 'tainacan' ),
|
||||||
'info_no_item_created' => __( 'No item was created in this collection.', 'tainacan' ),
|
'info_no_item_created' => __( 'No item was created in this collection.', 'tainacan' ),
|
||||||
'info_error_deleting_collection' => __( 'Error on deleting collection.', 'tainacan' ),
|
'info_error_deleting_collection' => __( 'Error on deleting collection.', 'tainacan' ),
|
||||||
|
'info_error_deleting_category' => __( 'Error on deleting category', 'tainacan' ),
|
||||||
'info_collection_deleted' => __( 'Collection deleted.', 'tainacan' ),
|
'info_collection_deleted' => __( 'Collection deleted.', 'tainacan' ),
|
||||||
'info_item_deleted' => __( 'Item deleted.', 'tainacan' ),
|
'info_item_deleted' => __( 'Item deleted.', 'tainacan' ),
|
||||||
|
'info_category_deleted' => __( 'Category deleted', 'tainacan' ),
|
||||||
'info_warning_collection_delete' => __( 'Do you really want to delete this collection?', 'tainacan' ),
|
'info_warning_collection_delete' => __( 'Do you really want to delete this collection?', 'tainacan' ),
|
||||||
'info_warning_item_delete' => __( 'Do you really want to delete this item?', 'tainacan' ),
|
'info_warning_item_delete' => __( 'Do you really want to delete this item?', 'tainacan' ),
|
||||||
|
'info_warning_category_delete' => __( 'Do you really want to delete this category?', 'tainacan' ),
|
||||||
'info_warning_selected_collections_delete' => __( 'Do you really want to delete the selected collections?', 'tainacan' ),
|
'info_warning_selected_collections_delete' => __( 'Do you really want to delete the selected collections?', 'tainacan' ),
|
||||||
'info_warning_selected_items_delete' => __( 'Do you really want to delete the selected items?', 'tainacan' ),
|
'info_warning_selected_items_delete' => __( 'Do you really want to delete the selected items?', 'tainacan' ),
|
||||||
'info_warning_collection_related' => __( 'The field Collection related is required', 'tainacan' ),
|
'info_warning_collection_related' => __( 'The field Collection related is required', 'tainacan' ),
|
||||||
|
|
|
@ -68,8 +68,8 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_REST_Controller {
|
||||||
'callback' => array($this, 'delete_item'),
|
'callback' => array($this, 'delete_item'),
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'body_args' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, in body you can pass \'is_permanently\' as true. By default this will only trash collection'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
|
||||||
'default' => 'false'
|
'default' => 'false'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -275,9 +275,9 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function delete_item( $request ) {
|
public function delete_item( $request ) {
|
||||||
$collection_id = $request['collection_id'];
|
$collection_id = $request['collection_id'];
|
||||||
$is_permanently = json_decode($request->get_body(), true);
|
$permanently = $request['permanently'];
|
||||||
|
|
||||||
$args = [$collection_id, $is_permanently];
|
$args = [$collection_id, $permanently];
|
||||||
|
|
||||||
$collection = $this->collections_repository->delete($args);
|
$collection = $this->collections_repository->delete($args);
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,8 @@ class TAINACAN_REST_Filters_Controller extends TAINACAN_REST_Controller {
|
||||||
'callback' => array($this, 'delete_item'),
|
'callback' => array($this, 'delete_item'),
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'body_args' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, in body you can pass \'is_permanently\' as true. By default this will only trash collection'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
|
||||||
'default' => 'false'
|
'default' => 'false'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -218,23 +218,15 @@ class TAINACAN_REST_Filters_Controller extends TAINACAN_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function delete_item( $request ) {
|
public function delete_item( $request ) {
|
||||||
$filter_id = $request['filter_id'];
|
$filter_id = $request['filter_id'];
|
||||||
|
$permanently = $request['permanently'];
|
||||||
|
|
||||||
$is_permanently = json_decode($request->get_body(), true);
|
$args = [$filter_id, $permanently];
|
||||||
|
|
||||||
if(!empty($is_permanently)){
|
|
||||||
$args = [$filter_id, $is_permanently];
|
|
||||||
|
|
||||||
$filter = $this->filter_repository->delete($args);
|
$filter = $this->filter_repository->delete($args);
|
||||||
|
|
||||||
return new WP_REST_Response($this->prepare_item_for_response($filter, $request), 200);
|
return new WP_REST_Response($this->prepare_item_for_response($filter, $request), 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WP_REST_Response([
|
|
||||||
'error_message' => __('The body could not be empty', 'tainacan'),
|
|
||||||
'body' => $request->get_body()
|
|
||||||
], 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param WP_REST_Request $request
|
* @param WP_REST_Request $request
|
||||||
*
|
*
|
||||||
|
|
|
@ -77,8 +77,8 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller {
|
||||||
'callback' => array($this, 'delete_item'),
|
'callback' => array($this, 'delete_item'),
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'body_args' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, in body you can pass \'is_permanently\' as true. By default this will only trash collection'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
|
||||||
'default' => 'false'
|
'default' => 'false'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -307,9 +307,9 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function delete_item( $request ) {
|
public function delete_item( $request ) {
|
||||||
$item_id = $request['item_id'];
|
$item_id = $request['item_id'];
|
||||||
$is_permanently = json_decode($request->get_body(), true);
|
$permanently = $request['permanently'];
|
||||||
|
|
||||||
$args = [$item_id, $is_permanently];
|
$args = [$item_id, $permanently];
|
||||||
|
|
||||||
$item = $this->items_repository->delete($args);
|
$item = $this->items_repository->delete($args);
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,9 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_REST_Controller {
|
||||||
'callback' => array($this, 'delete_item'),
|
'callback' => array($this, 'delete_item'),
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'body_args' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, in body you can pass \'is_permanently\' as true. By default this will only trash collection'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
|
||||||
'default' => 'false'
|
'default' => 'false',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -164,22 +164,14 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function delete_item( $request ) {
|
public function delete_item( $request ) {
|
||||||
$taxonomy_id = $request['taxonomy_id'];
|
$taxonomy_id = $request['taxonomy_id'];
|
||||||
|
$permanently = $request['permanently'];
|
||||||
if(empty($request->get_body())){
|
|
||||||
return new WP_REST_Response([
|
|
||||||
'error_message' => __('Body can not be empty.', 'tainacan'),
|
|
||||||
'body' => $request->get_body()
|
|
||||||
], 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
$is_permanently = json_decode($request->get_body(), true);
|
|
||||||
|
|
||||||
$taxonomy = $this->taxonomy_repository->fetch($taxonomy_id);
|
$taxonomy = $this->taxonomy_repository->fetch($taxonomy_id);
|
||||||
|
|
||||||
if(!empty($taxonomy)) {
|
if(!empty($taxonomy)) {
|
||||||
$taxonomy_name = $taxonomy->get_db_identifier();
|
$taxonomy_name = $taxonomy->get_db_identifier();
|
||||||
|
|
||||||
$args = [ $taxonomy_id, $taxonomy_name, $is_permanently ];
|
$args = [ $taxonomy_id, $taxonomy_name, $permanently ];
|
||||||
|
|
||||||
$deleted = $this->taxonomy_repository->delete( $args );
|
$deleted = $this->taxonomy_repository->delete( $args );
|
||||||
|
|
||||||
|
|
|
@ -243,8 +243,8 @@ class Collections extends Repository {
|
||||||
* @return mixed|Collection
|
* @return mixed|Collection
|
||||||
*/
|
*/
|
||||||
public function delete( $args ) {
|
public function delete( $args ) {
|
||||||
if ( ! empty( $args[1] ) && $args[1]['is_permanently'] === true ) {
|
if ( ! empty( $args[1] ) && $args[1] === true ) {
|
||||||
return new Entities\Collection( wp_delete_post( $args[0], $args[1]['is_permanently'] ) );
|
return new Entities\Collection( wp_delete_post( $args[0], $args[1] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Entities\Collection( wp_trash_post( $args[0] ) );
|
return new Entities\Collection( wp_trash_post( $args[0] ) );
|
||||||
|
|
|
@ -188,8 +188,8 @@ class Filters extends Repository {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function delete($args){
|
public function delete($args){
|
||||||
if(!empty($args[1]) && $args[1]['is_permanently'] === true){
|
if(!empty($args[1]) && $args[1] === true){
|
||||||
return new Entities\Filter(wp_delete_post($args[0], $args[1]['is_permanently']));
|
return new Entities\Filter(wp_delete_post($args[0], $args[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Entities\Filter(wp_trash_post($args[0]));
|
return new Entities\Filter(wp_trash_post($args[0]));
|
||||||
|
|
|
@ -304,8 +304,8 @@ class Items extends Repository {
|
||||||
* @return mixed|Entities\Item
|
* @return mixed|Entities\Item
|
||||||
*/
|
*/
|
||||||
public function delete( $args ) {
|
public function delete( $args ) {
|
||||||
if ( ! empty( $args[1] ) && $args[1]['is_permanently'] === true ) {
|
if ( ! empty( $args[1] ) && $args[1] === true ) {
|
||||||
return new Entities\Item( wp_delete_post( $args[0], $args[1]['is_permanently'] ) );
|
return new Entities\Item( wp_delete_post( $args[0], $args[1] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Entities\Item( wp_trash_post( $args[0] ) );
|
return new Entities\Item( wp_trash_post( $args[0] ) );
|
||||||
|
|
|
@ -209,9 +209,9 @@ class Taxonomies extends Repository {
|
||||||
public function delete($args){
|
public function delete($args){
|
||||||
$taxonomy_id = $args[0];
|
$taxonomy_id = $args[0];
|
||||||
$taxonomy_name = $args[1];
|
$taxonomy_name = $args[1];
|
||||||
$is_permanently = $args[2]['is_permanently'];
|
$permanently = $args[2];
|
||||||
|
|
||||||
if($is_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){
|
||||||
|
|
|
@ -25,14 +25,17 @@ export const createCategory = ({commit}, category) => {
|
||||||
|
|
||||||
export const deleteCategory = ({ commit }, categoryId) => {
|
export const deleteCategory = ({ commit }, categoryId) => {
|
||||||
return new Promise(( resolve, reject ) => {
|
return new Promise(( resolve, reject ) => {
|
||||||
axios.tainacan.delete(`/taxonomies/${categoryId}`, {
|
axios.tainacan.delete(`/taxonomies/${categoryId}?permanently=${true}`)
|
||||||
'is_permanently': true
|
|
||||||
})
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
console.info(res);
|
||||||
|
|
||||||
resolve( res.data );
|
commit('deleteCategory', res.data);
|
||||||
|
|
||||||
|
resolve( res );
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
|
||||||
reject( error )
|
reject( error )
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,3 +9,11 @@ export const setCategories = (state, categories) => {
|
||||||
export const setCategoryName = (state, name) => {
|
export const setCategoryName = (state, name) => {
|
||||||
state.categoryName = name;
|
state.categoryName = name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deleteCategory = ( state, category ) => {
|
||||||
|
let index = state.categories.findIndex(deletedCategory => deletedCategory.id === category.id);
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
state.categories.splice(index, 1);
|
||||||
|
}
|
||||||
|
};
|
|
@ -97,13 +97,13 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
$collection1 = $this->tainacan_entity_factory->create_entity('collection', '', true);
|
$collection1 = $this->tainacan_entity_factory->create_entity('collection', '', true);
|
||||||
|
|
||||||
// Delete permanently
|
// Delete permanently
|
||||||
$delete_permanently = json_encode(['is_permanently' => true]);
|
$delete_permanently = ['permanently' => true];
|
||||||
|
|
||||||
$request = new \WP_REST_Request(
|
$request = new \WP_REST_Request(
|
||||||
'DELETE',
|
'DELETE',
|
||||||
$this->namespace . '/collections/' . $collection1->get_id()
|
$this->namespace . '/collections/' . $collection1->get_id()
|
||||||
);
|
);
|
||||||
$request->set_body($delete_permanently);
|
$request->set_query_params($delete_permanently);
|
||||||
|
|
||||||
$response = $this->server->dispatch($request);
|
$response = $this->server->dispatch($request);
|
||||||
|
|
||||||
|
@ -122,13 +122,13 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
$collection2 = $this->tainacan_entity_factory->create_entity('collection', '', true);
|
$collection2 = $this->tainacan_entity_factory->create_entity('collection', '', true);
|
||||||
|
|
||||||
// Move to trash
|
// Move to trash
|
||||||
$delete_permanently = json_encode(['is_permanently' => false]);
|
$delete_permanently = ['permanently' => false];
|
||||||
|
|
||||||
$request = new \WP_REST_Request(
|
$request = new \WP_REST_Request(
|
||||||
'DELETE',
|
'DELETE',
|
||||||
$this->namespace . '/collections/' . $collection2->get_id()
|
$this->namespace . '/collections/' . $collection2->get_id()
|
||||||
);
|
);
|
||||||
$request->set_body($delete_permanently);
|
$request->set_query_params($delete_permanently);
|
||||||
|
|
||||||
$response = $this->server->dispatch($request);
|
$response = $this->server->dispatch($request);
|
||||||
|
|
||||||
|
|
|
@ -84,14 +84,12 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$is_permanently = json_encode([
|
$permanently = [ 'permanently' => false ];
|
||||||
'is_permanently' => false
|
|
||||||
]);
|
|
||||||
|
|
||||||
$request = new \WP_REST_Request(
|
$request = new \WP_REST_Request(
|
||||||
'DELETE', $this->namespace . '/filters/' . $filter->get_id());
|
'DELETE', $this->namespace . '/filters/' . $filter->get_id());
|
||||||
|
|
||||||
$request->set_body($is_permanently);
|
$request->set_query_params($permanently);
|
||||||
|
|
||||||
$response = $this->server->dispatch($request);
|
$response = $this->server->dispatch($request);
|
||||||
|
|
||||||
|
@ -105,14 +103,12 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
##### DELETE #####
|
##### DELETE #####
|
||||||
|
|
||||||
$is_permanently = json_encode([
|
$permanently = [ 'permanently' => true ];
|
||||||
'is_permanently' => true
|
|
||||||
]);
|
|
||||||
|
|
||||||
$request = new \WP_REST_Request(
|
$request = new \WP_REST_Request(
|
||||||
'DELETE', $this->namespace . '/filters/' . $filter->get_id());
|
'DELETE', $this->namespace . '/filters/' . $filter->get_id());
|
||||||
|
|
||||||
$request->set_body($is_permanently);
|
$request->set_query_params($permanently);
|
||||||
|
|
||||||
$response = $this->server->dispatch($request);
|
$response = $this->server->dispatch($request);
|
||||||
|
|
||||||
|
|
|
@ -93,13 +93,13 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Move to trash
|
// Move to trash
|
||||||
$delete_permanently = json_encode(['is_permanently' => false]);
|
$delete_permanently = ['permanently' => false];
|
||||||
|
|
||||||
$request = new \WP_REST_Request(
|
$request = new \WP_REST_Request(
|
||||||
'DELETE',
|
'DELETE',
|
||||||
$this->namespace . '/items/' . $item1->get_id()
|
$this->namespace . '/items/' . $item1->get_id()
|
||||||
);
|
);
|
||||||
$request->set_body($delete_permanently);
|
$request->set_query_params($delete_permanently);
|
||||||
|
|
||||||
$response = $this->server->dispatch($request);
|
$response = $this->server->dispatch($request);
|
||||||
|
|
||||||
|
@ -126,13 +126,13 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete permanently
|
// Delete permanently
|
||||||
$delete_permanently = json_encode(['is_permanently' => true]);
|
$delete_permanently = ['permanently' => true];
|
||||||
|
|
||||||
$request = new \WP_REST_Request(
|
$request = new \WP_REST_Request(
|
||||||
'DELETE',
|
'DELETE',
|
||||||
$this->namespace . '/items/' . $item2->get_id()
|
$this->namespace . '/items/' . $item2->get_id()
|
||||||
);
|
);
|
||||||
$request->set_body($delete_permanently);
|
$request->set_query_params($delete_permanently);
|
||||||
|
|
||||||
$response = $this->server->dispatch($request);
|
$response = $this->server->dispatch($request);
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,13 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$is_permanently = json_encode(['is_permanently' => false]);
|
$permanently = [ 'permanently' => false ];
|
||||||
|
|
||||||
$request_trash = new \WP_REST_Request(
|
$request_trash = new \WP_REST_Request(
|
||||||
'DELETE', $this->namespace . '/taxonomies/' . $taxonomy->get_id()
|
'DELETE', $this->namespace . '/taxonomies/' . $taxonomy->get_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
$request_trash->set_body($is_permanently);
|
$request_trash->set_query_params($permanently);
|
||||||
|
|
||||||
$this->server->dispatch($request_trash);
|
$this->server->dispatch($request_trash);
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
################ DELETE ###
|
################ DELETE ###
|
||||||
|
|
||||||
$is_permanently = json_encode(['is_permanently' => true]);
|
$permanently = [ 'permanently' => true ];
|
||||||
|
|
||||||
$request_delete = new \WP_REST_Request(
|
$request_delete = new \WP_REST_Request(
|
||||||
'DELETE', $this->namespace . '/taxonomies/' . $taxonomy->get_id()
|
'DELETE', $this->namespace . '/taxonomies/' . $taxonomy->get_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
$request_delete->set_body($is_permanently);
|
$request_delete->set_query_params($permanently);
|
||||||
|
|
||||||
$this->server->dispatch($request_delete);
|
$this->server->dispatch($request_delete);
|
||||||
|
|
||||||
|
@ -122,8 +122,10 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_UnitApiTestCase {
|
||||||
|
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
|
|
||||||
$this->assertEquals($taxonomy1->get_name(), $data[1]['name']);
|
$names = [ $data[1]['name'], $data[0]['name']];
|
||||||
$this->assertEquals($taxonomy2->get_name(), $data[0]['name']);
|
|
||||||
|
$this->assertContains($taxonomy1->get_name(), $names);
|
||||||
|
$this->assertContains($taxonomy2->get_name(), $names);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_update_taxonomy(){
|
public function test_update_taxonomy(){
|
||||||
|
|
Loading…
Reference in New Issue