From a3a8c10e4ac161ca835dc6750faa2543081c6b3f Mon Sep 17 00:00:00 2001 From: weryques Date: Mon, 8 Jan 2018 10:53:28 -0200 Subject: [PATCH] Test delete or trash Taxonomy --- tests/test-api-taxonomies.php | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/test-api-taxonomies.php b/tests/test-api-taxonomies.php index df39c0785..d7898b89f 100644 --- a/tests/test-api-taxonomies.php +++ b/tests/test-api-taxonomies.php @@ -4,6 +4,48 @@ namespace Tainacan\Tests; class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_UnitApiTestCase { + public function test_delete_or_trash_a_taxonomy(){ + $taxonomy = $this->tainacan_entity_factory->create_entity( + 'taxonomy', + array( + 'name' => '1genero', + 'description' => 'tipos de musica', + 'allow_insert' => 'yes', + 'status' => 'publish' + ), + true + ); + + $is_permanently = json_encode(['is_permanently' => false]); + + $request_trash = new \WP_REST_Request( + 'DELETE', $this->namespace . '/taxonomies/' . $taxonomy->get_id() + ); + + $request_trash->set_body($is_permanently); + + $this->server->dispatch($request_trash); + + $taxmy = get_post($taxonomy->get_id()); + + $this->assertEquals('trash', $taxmy->post_status); + $this->assertEquals(true, taxonomy_exists($taxonomy->get_db_identifier())); + + ################ DELETE ### + + $is_permanently = json_encode(['is_permanently' => true]); + + $request_delete = new \WP_REST_Request( + 'DELETE', $this->namespace . '/taxonomies/' . $taxonomy->get_id() + ); + + $request_delete->set_body($is_permanently); + + $this->server->dispatch($request_delete); + + $this->assertEquals(false, taxonomy_exists($taxonomy->get_db_identifier())); + } + public function test_create_taxonomy(){ $taxonomy_json = json_encode([ 'name' => 'Nome',