Test Failed
Push — develop ( 6098b1...78195a )
by Reüel
02:46
created

tests/Connect/GatewayTest.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay\Connect;
4
5
use WP_Http;
0 ignored issues
show
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...
6
use WP_UnitTestCase;
0 ignored issues
show
The type WP_UnitTestCase 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
use Pronamic\WordPress\Pay\Gateways\MultiSafepay\MultiSafepay;
8
9
class GatewayTest extends WP_UnitTestCase {
10
	/**
11
	 * Pre HTTP request
12
	 *
13
	 * @link https://github.com/WordPress/WordPress/blob/3.9.1/wp-includes/class-http.php#L150-L164
14
	 * @return string
15
	 */
16
	public function pre_http_request( $preempt, $request, $url ) {
17
		$response = file_get_contents( dirname( __FILE__ ) . '/Mock/ideal-issuers-response.http' );
18
19
		$processed_response = WP_Http::processResponse( $response );
20
21
		$processed_headers = WP_Http::processHeaders( $processed_response['headers'], $url );
22
23
		$processed_headers['body'] = $processed_response['body'];
24
25
		return $processed_headers;
26
	}
27
28
	public function test_init() {
29
		// Mock HTTP request
30
		//add_action( 'http_api_debug', array( $this, 'http_api_debug' ), 10, 5 );
31
		add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 10, 3 );
0 ignored issues
show
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

31
		/** @scrutinizer ignore-call */ 
32
  add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 10, 3 );
Loading history...
32
33
		// Other
34
		$config = new Config();
35
36
		$config->mode       = getenv( 'MULTISAFEPAY_MODE' );
37
		$config->account_id = getenv( 'MULTISAFEPAY_ACCOUNT_ID' );
38
		$config->site_id    = getenv( 'MULTISAFEPAY_SITE_ID' );
39
		$config->site_code  = getenv( 'MULTISAFEPAY_SECURE_CODE' );
40
41
		if ( Gateway::MODE_TEST === $config->mode ) {
42
			$config->api_url = MultiSafepay::API_TEST_URL;
43
		} else {
44
			$config->api_url = MultiSafepay::API_PRODUCTION_URL;
45
		}
46
47
		$gateway = new Gateway( $config );
48
49
		$issuers = $gateway->get_issuers();
50
51
		$expected = array(
52
			array(
53
				'options' => array(
54
					'3151' => 'Test bank',
55
				),
56
			),
57
		);
58
59
		$this->assertEquals( $expected, $issuers );
60
	}
61
}
62