Convert Authorize.net doDirectPayment to use guzzle & add test
Created by: eileenmcnaughton
Overview
This brings the main Authorize.net payment function under testing, putting us in a better position to bring it into line with more recommended coding practices.
My hope is that we can add doPayment testing to all core-enabled processors & select them more randomly during other tests to flush out more variations. Also to move them to core-extensions with a longer term view to moving at least some entirely out of core (I think the following are broken in core - FirstData, PaymentExpress, maybe Eway)
Before
No test on doPayment
After
Unit test covers doPayment
Technical Details
Note the trick to writing tests for Guzzle is to first add the lines
$this->setUpClientWithHistoryContainer();
$this->processor->setGuzzleClient($this->getGuzzleClient());
... do the stuff
$responses = $this->getResponseBodies();
$requests = $this->getRequestBodies();
That allows you to capture the outgoing & incoming responses that form the expectations. Obviously some credential wrangling is needed to get an OK response but it's also possible with some processors (e.g ones that are basically done for) to just worry about ensuring the outgoing is captured
Comments
@karing - this uses a new guzzle test trait in core that can also be used from extensions