Skip to content

Commit 7ca0c70

Browse files
author
Konstantinos Christofilos
committed
Override parseNotification test if PHP < 5.4
1 parent c633ec3 commit 7ca0c70

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

tests/GatewayTest.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,22 @@ public function testCancelSubscription()
138138

139139
public function testParseNotification()
140140
{
141-
$xml = '<notification></notification>';
142-
$payload = base64_encode($xml);
143-
$signature = \Braintree_Digest::hexDigestSha1(\Braintree_Configuration::privateKey(), $payload);
144-
$gatewayMock = $this->buildGatewayMock($payload);
145-
$gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest(), $gatewayMock);
146-
$params = array(
147-
'bt_signature' => $payload.'|'.$signature,
148-
'bt_payload' => $payload
149-
);
150-
$request = $gateway->parseNotification($params);
151-
$this->assertInstanceOf('\Braintree_WebhookNotification', $request);
141+
/* Webhook notifications need PHP >= 5.4 */
142+
if (PHP_VERSION >= '5.4') {
143+
$xml = '<notification></notification>';
144+
$payload = base64_encode($xml);
145+
$signature = \Braintree_Digest::hexDigestSha1(\Braintree_Configuration::privateKey(), $payload);
146+
$gatewayMock = $this->buildGatewayMock($payload);
147+
$gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest(), $gatewayMock);
148+
$params = array(
149+
'bt_signature' => $payload.'|'.$signature,
150+
'bt_payload' => $payload
151+
);
152+
$request = $gateway->parseNotification($params);
153+
$this->assertInstanceOf('\Braintree_WebhookNotification', $request);
154+
} else {
155+
$this->assertTrue(true);
156+
}
152157
}
153158

154159
/**

0 commit comments

Comments
 (0)