public function test_successful_purge_request_for_individual_url_with_instant_purge()
 {
     $url = 'http://www.example.org/2015/05/test-post';
     $expected_result = MockData::purge_url_response_200();
     // Mock the remote request
     \WP_Mock::wpFunction('wp_remote_request', array('args' => array($url, array('method' => 'PURGE')), 'times' => 1, 'return' => MockData::purge_url_response_200()));
     $purge = new Purgely_Purge();
     $actual_result = $purge->purge('url', $url, array('purge-type' => 'instant'));
     $this->assertEquals($expected_result, $actual_result);
     $this->assertEquals($expected_result, $purge->get_response());
     // The request is successful so ensure is_wp_error returns false
     \WP_Mock::wpFunction('is_wp_error', array('args' => array($expected_result), 'times' => 1, 'return' => false));
     \WP_Mock::wpFunction('wp_remote_retrieve_response_code', array('args' => array($expected_result), 'times' => 1, 'return' => '200'));
     $this->assertEquals('success', $purge->get_result());
 }
 public function test_purge_related_result_when_one_request_produces_a_wp_error()
 {
     $url = 'http://example.com/2015/09/my-url';
     $object = $this->setup_standard_collection($url);
     // We are going to issue a number of remote requests, which need some mocking
     \WP_Mock::wpFunction('wp_remote_request', array('args' => array(\WP_Mock\Functions::type('string'), \WP_Mock\Functions::type('array')), 'times' => 14, 'return' => MockData::purge_url_response_200()));
     \WP_Mock::wpFunction('wp_remote_request', array('args' => array(\WP_Mock\Functions::type('string'), \WP_Mock\Functions::type('array')), 'times' => 1, 'return' => MockData::purge_url_response_405()));
     \WP_Mock::wpFunction('is_wp_error', array('args' => array('*'), 'times' => 14, 'return' => false));
     \WP_Mock::wpFunction('is_wp_error', array('args' => array('*'), 'times' => 1, 'return' => true));
     \WP_Mock::wpFunction('wp_remote_retrieve_response_code', array('args' => array('*'), 'times' => 14, 'return' => '200'));
     $object->purge_related();
     $result = $object->get_result();
     $this->assertEquals('failure', $result);
 }