Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Fixing tests.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BE-Webdesign committed Apr 8, 2016
1 parent 5f351d6 commit cda055b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/class-wp-test-rest-controller-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
}

0 comments on commit cda055b

Please sign in to comment.