1 | <?php |
||||||
2 | |||||||
3 | namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay\Connect; |
||||||
4 | |||||||
5 | use stdClass; |
||||||
6 | use WP_Http; |
||||||
0 ignored issues
–
show
|
|||||||
7 | 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
8 | use Pronamic\WordPress\Pay\Core\Server; |
||||||
9 | use Pronamic\WordPress\Pay\Gateways\MultiSafepay\MultiSafepay; |
||||||
10 | use Pronamic\WordPress\Pay\Gateways\MultiSafepay\Config; |
||||||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
Pronamic\WordPress\Pay\G...iSafepay\Connect\Config . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||||||
11 | |||||||
12 | class DirectTransactionTest extends WP_UnitTestCase { |
||||||
13 | /** |
||||||
14 | * Pre HTTP request |
||||||
15 | * |
||||||
16 | * @link https://github.com/WordPress/WordPress/blob/3.9.1/wp-includes/class-http.php#L150-L164 |
||||||
17 | * @return string |
||||||
18 | */ |
||||||
19 | public function pre_http_request( $preempt, $request, $url ) { |
||||||
20 | $response = file_get_contents( dirname( __FILE__ ) . '/Mock/direct-transaction-response.http' ); |
||||||
21 | |||||||
22 | $processed_response = WP_Http::processResponse( $response ); |
||||||
23 | |||||||
24 | $processed_headers = WP_Http::processHeaders( $processed_response['headers'], $url ); |
||||||
25 | |||||||
26 | $processed_headers['body'] = $processed_response['body']; |
||||||
27 | |||||||
28 | return $processed_headers; |
||||||
29 | } |
||||||
30 | |||||||
31 | public function http_api_debug( $response, $context, $class, $args, $url ) { |
||||||
32 | |||||||
33 | } |
||||||
34 | |||||||
35 | public function test_init() { |
||||||
36 | // Actions |
||||||
37 | //add_action( 'http_api_debug', array( $this, 'http_api_debug' ), 10, 5 ); |
||||||
38 | 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
![]() |
|||||||
39 | |||||||
40 | // Config |
||||||
41 | $config = new Config(); |
||||||
42 | |||||||
43 | $config->mode = getenv( 'MULTISAFEPAY_MODE' ); |
||||||
44 | $config->account_id = getenv( 'MULTISAFEPAY_ACCOUNT_ID' ); |
||||||
45 | $config->site_id = getenv( 'MULTISAFEPAY_SITE_ID' ); |
||||||
46 | $config->site_code = getenv( 'MULTISAFEPAY_SECURE_CODE' ); |
||||||
47 | |||||||
48 | if ( Gateway::MODE_TEST === $config->mode ) { |
||||||
49 | $config->api_url = MultiSafepay::API_TEST_URL; |
||||||
50 | } else { |
||||||
51 | $config->api_url = MultiSafepay::API_PRODUCTION_URL; |
||||||
52 | } |
||||||
53 | |||||||
54 | // Client |
||||||
55 | $client = new Client(); |
||||||
56 | |||||||
57 | $client->api_url = $config->api_url; |
||||||
58 | |||||||
59 | // Message |
||||||
60 | $merchant = new Merchant(); |
||||||
61 | |||||||
62 | $merchant->account = $config->account_id; |
||||||
63 | $merchant->site_id = $config->site_id; |
||||||
64 | $merchant->site_secure_code = $config->site_code; |
||||||
65 | $merchant->notification_url = home_url(); |
||||||
0 ignored issues
–
show
The function
home_url 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
![]() |
|||||||
66 | $merchant->redirect_url = home_url(); |
||||||
67 | $merchant->cancel_url = home_url(); |
||||||
68 | $merchant->close_window = 'false'; |
||||||
69 | |||||||
70 | $customer = new Customer(); |
||||||
71 | |||||||
72 | $customer->locale = get_locale(); |
||||||
0 ignored issues
–
show
The function
get_locale 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
![]() |
|||||||
73 | $customer->ip_address = Server::get( 'REMOTE_ADDR', FILTER_VALIDATE_IP ); |
||||||
74 | $customer->forwarded_ip = Server::get( 'HTTP_X_FORWARDED_FOR', FILTER_VALIDATE_IP ); |
||||||
75 | $customer->first_name = ''; |
||||||
76 | $customer->last_name = ''; |
||||||
77 | $customer->address_1 = 'Test'; |
||||||
78 | $customer->address_2 = ''; |
||||||
79 | $customer->house_number = '1'; |
||||||
80 | $customer->zip_code = '1234 AB'; |
||||||
81 | $customer->city = 'Test'; |
||||||
82 | $customer->country = 'Test'; |
||||||
83 | $customer->phone = ''; |
||||||
84 | $customer->email = get_option( 'admin_email' ); |
||||||
0 ignored issues
–
show
The function
get_option 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
![]() |
|||||||
85 | |||||||
86 | $transaction = new Transaction(); |
||||||
87 | |||||||
88 | $transaction->id = uniqid(); |
||||||
89 | $transaction->currency = 'EUR'; |
||||||
90 | $transaction->amount = 123; |
||||||
91 | $transaction->description = 'Test'; |
||||||
92 | $transaction->var1 = ''; |
||||||
93 | $transaction->var2 = ''; |
||||||
94 | $transaction->var3 = ''; |
||||||
95 | $transaction->items = ''; |
||||||
96 | $transaction->manual = 'false'; |
||||||
97 | $transaction->gateway = ''; |
||||||
98 | $transaction->days_active = ''; |
||||||
99 | $transaction->gateway = Methods::IDEAL; |
||||||
100 | //$transaction->gateway = Pronamic\WordPress\Pay\Gateways\MultiSafepay\Connect\Gateways::MASTERCARD; |
||||||
101 | //$transaction->gateway = Pronamic\WordPress\Pay\Gateways\MultiSafepay\Connect\Gateways::BANK_TRANSFER; |
||||||
102 | |||||||
103 | //$gateway_info = null; |
||||||
104 | $gateway_info = new GatewayInfo(); |
||||||
105 | |||||||
106 | $gateway_info->issuer_id = '3151'; |
||||||
107 | |||||||
108 | $message = new XML\DirectTransactionRequestMessage( $merchant, $customer, $transaction, $gateway_info ); |
||||||
109 | |||||||
110 | $signature = Signature::generate( $transaction->amount, $transaction->currency, $merchant->account, $merchant->site_id, $transaction->id ); |
||||||
111 | |||||||
112 | $message->signature = $signature; |
||||||
0 ignored issues
–
show
|
|||||||
113 | |||||||
114 | // Response |
||||||
115 | $response = $client->start_transaction( $message ); |
||||||
0 ignored issues
–
show
$message of type Pronamic\WordPress\Pay\G...ansactionRequestMessage is incompatible with the type array expected by parameter $message of Pronamic\WordPress\Pay\G...nt::start_transaction() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
116 | |||||||
117 | // Expected |
||||||
118 | $expected = new XML\DirectTransactionResponseMessage(); |
||||||
119 | |||||||
120 | $expected->result = 'ok'; |
||||||
121 | |||||||
122 | $expected->transaction = new Transaction(); |
||||||
0 ignored issues
–
show
It seems like
new Pronamic\WordPress\P...y\Connect\Transaction() of type Pronamic\WordPress\Pay\G...pay\Connect\Transaction is incompatible with the declared type Pronamic\WordPress\Pay\G...nsactionResponseMessage of property $transaction .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
123 | |||||||
124 | $expected->transaction->id = '554202bb33498'; |
||||||
125 | |||||||
126 | $expected->gateway_info = new GatewayInfo(); |
||||||
127 | |||||||
128 | $expected->gateway_info->issuer_id = '3151'; |
||||||
129 | $expected->gateway_info->redirect_url = 'http://testpay.multisafepay.com/simulator/ideal?trxid=10447735643871196&ideal=prob&issuerid=3151&merchantReturnURL=https%3A%2F%2Ftestpay%2Emultisafepay%2Ecom%2Fdirect%2Fcomplete%2F%3Fid%3D9943038943576689'; |
||||||
130 | $expected->gateway_info->ext_var = 'https://testpay.multisafepay.com/direct/complete/'; |
||||||
131 | |||||||
132 | // Assert |
||||||
133 | $this->assertEquals( $expected, $response ); |
||||||
134 | } |
||||||
135 | } |
||||||
136 |
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