Test Failed
Push — develop ( f70017...24ca99 )
by Reüel
02:51
created

RemoteGetTest::pre_http_request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\TargetPay;
4
5
use PHPUnit_Framework_TestCase;
6
use WP_Http;
0 ignored issues
show
Bug introduced by
The type WP_Http was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Title: TargetPay remote get tests
10
 * Description:
11
 * Copyright: 2005-2019 Pronamic
12
 * Company: Pronamic
13
 *
14
 * @author  Remco Tolsma
15
 * @version 2.0.0
16
 * @since   1.0.0
17
 */
18
class RemoteGetTest extends \PHPUnit_Framework_TestCase {
19
	/**
20
	 * Pre HTTP request
21
	 *
22
	 * @link https://github.com/WordPress/WordPress/blob/3.9.1/wp-includes/class-http.php#L150-L164
23
	 *
24
	 * @param $preempt
25
	 * @param $request
26
	 * @param $url
27
	 *
28
	 * @return array
29
	 */
30
	public function pre_http_request( $preempt, $request, $url ) {
31
		$response = file_get_contents( dirname( __FILE__ ) . '/Mock/GetIssuersXml200.http', true );
32
33
		$processed_response = WP_Http::processResponse( $response );
34
35
		$processed_headers         = WP_Http::processHeaders( $processed_response['headers'], $url );
36
		$processed_headers['body'] = $processed_response['body'];
37
38
		return $processed_headers;
39
	}
40
41
	public function test_get_issuers() {
42
		add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 10, 3 );
0 ignored issues
show
Bug introduced by
The function add_filter was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
		/** @scrutinizer ignore-call */ 
43
  add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 10, 3 );
Loading history...
43
44
		$url = 'https://www.targetpay.com/ideal/getissuers.php?format=xml';
45
46
		$response = wp_remote_get( $url );
0 ignored issues
show
Bug introduced by
The function wp_remote_get was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
		$response = /** @scrutinizer ignore-call */ wp_remote_get( $url );
Loading history...
47
48
		$this->assertEquals( 200, wp_remote_retrieve_response_code( $response ) );
0 ignored issues
show
Bug introduced by
The function wp_remote_retrieve_response_code was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
		$this->assertEquals( 200, /** @scrutinizer ignore-call */ wp_remote_retrieve_response_code( $response ) );
Loading history...
49
	}
50
}
51