Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/299298
Change subject: [WIP] Test for logCompleted ...................................................................... [WIP] Test for logCompleted Change-Id: Ib7a1133579b3661fa5faafc64a1e9121a5222d32 --- M tests/LoggingTest.php 1 file changed, 28 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/98/299298/1 diff --git a/tests/LoggingTest.php b/tests/LoggingTest.php index 2ff51be..62d56f9 100644 --- a/tests/LoggingTest.php +++ b/tests/LoggingTest.php @@ -103,4 +103,32 @@ $this->assertEquals( $expectedObject, $actualObject, 'Completion message is as expected' ); } + + /** + * Bad encoding emits self-diagnostics + */ + public function testJsonEncodeFailed() { + $init = $this->getDonorTestData(); + $init['payment_method'] = 'cc'; + $init['payment_submethod'] = 'visa'; + $init['email'] = 'innoc...@manichean.com'; + $init['ffname'] = 'cc-vmad'; + $init['impossible_key'] = function () {}; + unset( $init['order_id'] ); + + // Reuse: $this->paySuccessfully( $init ); + $gateway = $this->getFreshGatewayObject( $init ); + $gateway->setDummyGatewayResponseCode( '200' ); + $gateway->do_transaction( 'Confirm_CreditCard' ); + $preface_pattern = '/' . preg_quote( GatewayAdapter::COMPLETED_PREFACE ) . '/'; + $matches = $this->getLogMatches( LogLevel::INFO, $preface_pattern ); + $this->assertTrue( $matches !== false, + 'Should log completion error message' ); + + $json = str_replace( GatewayAdapter::COMPLETED_PREFACE, '', $matches[0] ); + $result = json_decode( $json, true ); + $expectedError = '1: boo'; + $this->assertEquals( $expectedError, $result['json_encode_error'], + 'Completion message is as expected' ); + } } -- To view, visit https://gerrit.wikimedia.org/r/299298 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib7a1133579b3661fa5faafc64a1e9121a5222d32 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits