From cda055bdb29d25b448025e0b0ec9d61e9ac06eed Mon Sep 17 00:00:00 2001 From: BE-Webdesign Date: Fri, 8 Apr 2016 10:54:13 -0400 Subject: [PATCH] Fixing tests. Thank you danielbachuber. Test now works, but I am not sure if the test should work differently. Currently it only checks if a leading slash is on the path which it should be. However, it is difficult to get the untouched data checked to see if it has a leading slash or not, which is the intention of the test. --- tests/class-wp-test-rest-controller-testcase.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/class-wp-test-rest-controller-testcase.php b/tests/class-wp-test-rest-controller-testcase.php index 441908e0e4..28092554ec 100644 --- a/tests/class-wp-test-rest-controller-testcase.php +++ b/tests/class-wp-test-rest-controller-testcase.php @@ -6,7 +6,7 @@ abstract class WP_Test_REST_Controller_Testcase extends WP_Test_REST_TestCase { public function setUp() { parent::setUp(); - add_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 ); + add_filter( 'rest_url', array( $this, 'filter_rest_url_for_leading_slash' ), 10, 2 ); /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; $this->server = $wp_rest_server = new WP_Test_Spy_REST_Server; @@ -15,7 +15,7 @@ public function setUp() { public function tearDown() { parent::tearDown(); - + remove_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 ); /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; $wp_rest_server = null; @@ -39,8 +39,10 @@ abstract public function test_prepare_item(); abstract public function test_get_item_schema(); - public function test_rest_url_for_leading_slash( $url, $path ) { + public function filter_rest_url_for_leading_slash( $url, $path ) { // Make sure path for rest_url has a leading slash for proper resolution. $this->assertTrue( 0 === strpos( $path, '/' ) ); + + return $url; } }