6 declare(strict_types=1);
10 use Braintree\Result\Error;
21 use PHPUnit\Framework\TestCase;
22 use PHPUnit_Framework_MockObject_MockObject as MockObject;
34 private $objectManager;
48 $this->client = $this->getMockBuilder(TransactionSale::class)
49 ->disableOriginalConstructor()
51 $this->objectManager->addSharedInstance($this->client, TransactionSale::class);
59 $this->objectManager->removeSharedInstance(TransactionSale::class);
78 public function testSavePaymentInformationAndPlaceOrderWithErrors(
80 array $testErrorCodes,
81 string $expectedOutput
84 $state = $this->objectManager->get(State::class);
85 $state->setAreaCode($area);
87 $quote = $this->getQuote(
'test_order_1');
90 $payment = $this->objectManager->create(PaymentInterface::class);
95 foreach ($testErrorCodes as $testErrorCode) {
96 array_push(
$errors[
'errors'], [
'code' => $testErrorCode]);
101 $this->client->method(
'placeRequest')
104 $this->expectExceptionMessage($expectedOutput);
107 $paymentInformationManagement = $this->objectManager->get(PaymentInformationManagementInterface::class);
108 $paymentInformationManagement->savePaymentInformationAndPlaceOrder(
121 $testErrorGlobal = [
'code' => 81802,
'message' =>
'Company is too long.'];
122 $testErrorAdmin = [
'code' => 91511,
'message' =>
'Customer does not have any credit cards.'];
123 $testErrorFake = [
'code' =>
'fake_code',
'message' =>
'Error message should not be mapped.'];
128 [$testErrorAdmin[
'code'], $testErrorFake[
'code']],
129 'Transaction has been declined. Please try again later.' 132 [$testErrorGlobal[
'code'], $testErrorAdmin[
'code'], $testErrorFake[
'code']],
133 $testErrorGlobal[
'message']
136 [$testErrorGlobal[
'code'], $testErrorAdmin[
'code'], $testErrorFake[
'code']],
137 $testErrorGlobal[
'message'] . PHP_EOL . $testErrorAdmin[
'message']
148 private function getQuote(
string $reservedOrderId):
CartInterface 156 $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class);
static getObjectManager()