From 72418d4bc10f32c019fab0fb17c098988aa433ee Mon Sep 17 00:00:00 2001 From: Rachel Baker Date: Thu, 20 Oct 2016 05:12:26 +0000 Subject: [PATCH] REST API: Fix test failures. - Fix leak in setup_notify_comment() test help by removing the comment_flood_filter. - Correct uses of $term_taxonomy_id -> $term_id in Category and Tags routing. - Temporarily remove the metadata tests for canola.jpg as that file does not have an exifdata. Will need to update the test. Props jorbin, rmccue, nacin See #38373. git-svn-id: https://develop.svn.wordpress.org/trunk@38834 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/comment.php | 5 ++++- tests/phpunit/tests/rest-api/rest-attachments-controller.php | 2 -- tests/phpunit/tests/rest-api/rest-categories-controller.php | 2 +- tests/phpunit/tests/rest-api/rest-tags-controller.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index e0a123ae71..d41b781fb9 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -460,7 +460,7 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertFalse( $notification_sent, 'Moderator notification setting on, filter set to off' ); remove_filter( 'notify_moderator', '__return_false' ); - + remove_filter( 'comment_flood_filter', '__return_false' ); } /** @@ -481,6 +481,7 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( $notification_sent, 'Moderator notification setting off, filter set to on' ); remove_filter( 'notify_moderator', '__return_true' ); + remove_filter( 'comment_flood_filter', '__return_false' ); } /** @@ -502,6 +503,7 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertFalse( $notification_sent, 'Test with author notification setting on, filter set to off' ); remove_filter( 'notify_post_author', '__return_false' ); + remove_filter( 'comment_flood_filter', '__return_false' ); } /** @@ -522,6 +524,7 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( $notification_sent, 'Test with author notification setting off, filter set to on' ); remove_filter( 'notify_post_author', '__return_true' ); + remove_filter( 'comment_flood_filter', '__return_false' ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index 84a8577411..9eef1e2584 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -425,8 +425,6 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $data = $response->get_data(); $this->assertEquals( 201, $response->get_status() ); $this->assertEquals( 'image', $data['media_type'] ); - $this->assertEquals( 'A field of amazing canola', $data['title']['rendered'] ); - $this->assertEquals( 'The description for the image', $data['caption'] ); } public function test_create_item_default_filename_title() { diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index 6c2e38443f..c62bc695ac 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -677,7 +677,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $parent = get_term_by( 'id', $this->factory->category->create(), 'category' ); $term = get_term_by( 'id', $this->factory->category->create(), 'category' ); - $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_taxonomy_id ); + $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'parent', $parent->term_id ); $response = $this->server->dispatch( $request ); $this->assertEquals( 200, $response->get_status() ); diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php index dc9b5fb3ea..d7dcf22edc 100644 --- a/tests/phpunit/tests/rest-api/rest-tags-controller.php +++ b/tests/phpunit/tests/rest-api/rest-tags-controller.php @@ -531,7 +531,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { wp_set_current_user( $this->administrator ); $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' ); - $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_taxonomy_id ); + $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id ); $request->set_param( 'parent', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); $response = $this->server->dispatch( $request ); $this->assertErrorResponse( 'rest_taxonomy_not_hierarchical', $response, 400 );