Created
June 2, 2014 15:34
-
-
Save tlovett1/e9ea0a2a3e76004beab4 to your computer and use it in GitHub Desktop.
WP Mock wp_remote_request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ESTestCore extends PHPUnit_Framework_TestCase { | |
public function setUp() { | |
\WP_Mock::setUp(); | |
} | |
public function tearDown() { | |
\WP_Mock::tearDown(); | |
} | |
public function testRemoteRequest() { | |
$response = array( | |
'body' => '{"success": 1}', | |
'response' => array( | |
'code' => 200, | |
'message' => 'OK', | |
), | |
'cookies' => array(), | |
'filename' => null, | |
); | |
\WP_Mock::wpFunction( 'wp_remote_request', array( | |
'times' => 1, | |
'args' => array( 'http://test.com', '*' ), | |
'return' => $response | |
) ); | |
$return = wp_remote_request( 'http://test.com', json_encode( array( 'test' => true ) ) ); | |
$this->assertEquals( $return, $response ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment