Skip to content

Commit

Permalink
Use pre_http_request to filter the API response
Browse files Browse the repository at this point in the history
  • Loading branch information
valendesigns committed May 15, 2016
1 parent 49b6c63 commit 4e79ba4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/mock-http-response.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Mock_Http_Response {
* @param string $url The request URL.
* @return array
*/
public function http_response( $data, $args, $url ) {
public function filter_response( $data, $args, $url ) {
if ( null !== self::$test_class ) {
if ( ! empty( self::$expected_args ) ) {
self::$test_class->assertContains( self::$expected_args, $args );
Expand Down
4 changes: 2 additions & 2 deletions tests/test-class-gem-dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setUp() {

$this->http_response = new Mock_Http_Response();
Mock_Http_Response::$test_class = $this;
add_filter( 'http_response', array( $this->http_response, 'http_response' ), 10, 3 );
add_filter( 'pre_http_request', array( $this->http_response, 'filter_response' ), 10, 3 );
}

/**
Expand All @@ -41,7 +41,7 @@ public function setUp() {
public function tearDown() {
parent::tearDown();

remove_filter( 'http_response', array( $this->http_response, 'http_response' ), 10, 3 );
remove_filter( 'pre_http_request', array( $this->http_response, 'filter_response' ), 10, 3 );
Mock_Http_Response::$data = null;
Mock_Http_Response::$test_class = null;
Mock_Http_Response::$expected_args = null;
Expand Down
4 changes: 2 additions & 2 deletions tests/test-class-gem-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setUp() {

$this->http_response = new Mock_Http_Response();
Mock_Http_Response::$test_class = $this;
add_filter( 'http_response', array( $this->http_response, 'http_response' ), 10, 3 );
add_filter( 'pre_http_request', array( $this->http_response, 'filter_response' ), 10, 3 );
}

/**
Expand All @@ -42,7 +42,7 @@ public function tearDown() {
global $wp_settings_errors;
parent::tearDown();

remove_filter( 'http_response', array( $this->http_response, 'http_response' ), 10, 3 );
remove_filter( 'pre_http_request', array( $this->http_response, 'filter_response' ), 10, 3 );
Mock_Http_Response::$data = null;
Mock_Http_Response::$test_class = null;
Mock_Http_Response::$expected_args = null;
Expand Down

0 comments on commit 4e79ba4

Please sign in to comment.