private function get_directory_object() { $url = 'http://acme.org/directory'; $args = array('body' => ''); $response = MockData::get_directory_response(); \WP_Mock::setUp(); // Mock the remote request \WP_Mock::wpFunction('wp_remote_request', array('args' => array($url, $args), 'times' => 1, 'return' => $response)); $directory = new \LEWP\Request\Directory($url); $directory->send(); \WP_Mock::tearDown(); return $directory; }
public function test_send_generates_response_and_sets_properties() { $url = 'http://acme.org/directory'; $args = array('body' => ''); $response = MockData::get_directory_response(); \WP_Mock::setUp(); // Mock the remote request \WP_Mock::wpFunction('wp_remote_request', array('args' => array($url, $args), 'times' => 1, 'return' => $response)); $directory = new \LEWP\Request\Directory($url); $this->assertEquals($response, $directory->send()); $this->assertEquals($response, $directory->get_response()); $this->assertEquals($response['body'], $directory->get_body()); $this->assertEquals($response['headers']['replay-nonce'], $directory->get_response_nonce()); \WP_Mock::tearDown(); }