wp-pay-gateways /
multisafepay
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay; |
||
| 4 | |||
| 5 | use WP_Http; |
||
| 6 | use WP_UnitTestCase; |
||
| 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( 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 ); |
||
| 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 | try { |
||
| 50 | $issuers = $gateway->get_issuers(); |
||
| 51 | } catch ( \Pronamic\WordPress\Pay\GatewayException $e ) { |
||
|
0 ignored issues
–
show
|
|||
| 52 | $issuers = null; |
||
| 53 | } |
||
| 54 | |||
| 55 | $expected = array( |
||
| 56 | array( |
||
| 57 | 'options' => array( |
||
| 58 | '3151' => 'Test bank', |
||
| 59 | ), |
||
| 60 | ), |
||
| 61 | ); |
||
| 62 | |||
| 63 | $this->assertEquals( $expected, $issuers ); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths