@@ -138,8 +138,7 @@ public function testCancelSubscription()
138
138
139
139
public function testParseNotification ()
140
140
{
141
- /* Webhook notifications need PHP >= 5.4 */
142
- if (PHP_VERSION >= '5.4 ' ) {
141
+ if (\Braintree_Version::MAJOR >= 3 ) {
143
142
$ xml = '<notification></notification> ' ;
144
143
$ payload = base64_encode ($ xml );
145
144
$ signature = \Braintree_Digest::hexDigestSha1 (\Braintree_Configuration::privateKey (), $ payload );
@@ -152,7 +151,17 @@ public function testParseNotification()
152
151
$ request = $ gateway ->parseNotification ($ params );
153
152
$ this ->assertInstanceOf ('\Braintree_WebhookNotification ' , $ request );
154
153
} else {
155
- $ this ->assertTrue (true );
154
+ $ xml = '<notification><subject></subject></notification> ' ;
155
+ $ payload = base64_encode ($ xml );
156
+ $ signature = \Braintree_Digest::hexDigestSha1 (\Braintree_Configuration::privateKey (), $ payload );
157
+ $ gatewayMock = $ this ->buildGatewayMock ($ payload );
158
+ $ gateway = new Gateway ($ this ->getHttpClient (), $ this ->getHttpRequest (), $ gatewayMock );
159
+ $ params = array (
160
+ 'bt_signature ' => $ payload .'| ' .$ signature ,
161
+ 'bt_payload ' => $ payload
162
+ );
163
+ $ request = $ gateway ->parseNotification ($ params );
164
+ $ this ->assertInstanceOf ('\Braintree_WebhookNotification ' , $ request );
156
165
}
157
166
}
158
167
0 commit comments