@@ -299,8 +299,45 @@ public function testPostIpnValidatorError(): void
299299 $ client ->expects ($ this ->once ())->method ('getInvoice ' )->willReturn ($ invoice );
300300 $ this ->client ->expects ($ this ->once ())->method ('initialize ' )->willReturn ($ client );
301301 $ this ->transactionRepository ->expects ($ this ->once ())->method ('findBy ' )->willReturn ([]);
302- $ this ->
throwException (
new IPNValidationException (
'Email from IPN data ( \'[email protected] \') does not ' .
303- 'match with email from invoice ( \'[email protected] \') ' ));
302+
303+ $ this ->response ->expects ($ this ->once ())->method ('addMessage ' )->with (
304+ "Email from IPN data (' {$ data ['data ' ]['buyerFields ' ]['buyerEmail ' ]}') does not match with " .
305+ "email from invoice (' {$ invoice ->getBuyer ()->getEmail ()}') " ,
306+ 500
307+ );
308+
309+ $ this ->ipnManagement ->postIpn ();
310+ }
311+
312+ public function testPostIpnNoValidatorErrorWhenEmailCasingMismatch (): void
313+ {
314+ $ eventName = 'ivoice_confirmed ' ;
315+ $ orderInvoiceId = '12 ' ;
316+ $ data = [
317+ 'data ' => [
318+ 'orderId ' => '00000012 ' ,
319+ 'id ' => $ orderInvoiceId ,
320+ 'buyerFields ' => [
321+ 'buyerName ' => 'test ' ,
322+ 'buyerEmail ' =>
'[email protected] ' ,
323+ 'buyerAddress1 ' => '12 test road '
324+ ],
325+ 'amountPaid ' => 1232132
326+ ],
327+ 'event ' => ['name ' => $ eventName ]
328+ ];
329+ $ serializer = new Json ();
330+ $ serializerData = $ serializer ->serialize ($ data );
331+ $ this ->serializer ->expects ($ this ->once ())->method ('unserialize ' )->willReturn ($ data );
332+ $ this ->request ->expects ($ this ->once ())->method ('getContent ' )->willReturn ($ serializerData );
333+
334+ $ invoice = $ this ->prepareInvoice ();
335+ $ client = $ this ->getMockBuilder (\BitPaySDK \Client::class)->disableOriginalConstructor ()->getMock ();
336+ $ client ->expects ($ this ->once ())->method ('getInvoice ' )->willReturn ($ invoice );
337+ $ this ->client ->expects ($ this ->once ())->method ('initialize ' )->willReturn ($ client );
338+ $ this ->transactionRepository ->expects ($ this ->once ())->method ('findBy ' )->willReturn ([]);
339+
340+ $ this ->response ->expects ($ this ->never ())->method ('addMessage ' );
304341
305342 $ this ->ipnManagement ->postIpn ();
306343 }
0 commit comments