Skip to content

Commit fe7b593

Browse files
committed
MAGETWO-64129: Merge branch 'remove-zend-json-braintree' of github.com:dmanners/magento2 into MAGETWO-64129
2 parents 7647dce + 8d7c1c8 commit fe7b593

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

app/code/Magento/Braintree/Gateway/Response/VaultDetailsHandler.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,33 @@ class VaultDetailsHandler implements HandlerInterface
4141
*/
4242
protected $config;
4343

44+
/**
45+
* @var \Magento\Framework\Serialize\SerializerInterface
46+
*/
47+
private $serializer;
48+
4449
/**
4550
* Constructor
4651
*
4752
* @param PaymentTokenInterfaceFactory $paymentTokenFactory
4853
* @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory
4954
* @param Config $config
5055
* @param SubjectReader $subjectReader
56+
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
5157
*/
5258
public function __construct(
5359
PaymentTokenInterfaceFactory $paymentTokenFactory,
5460
OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory,
5561
Config $config,
56-
SubjectReader $subjectReader
62+
SubjectReader $subjectReader,
63+
\Magento\Framework\Serialize\SerializerInterface $serializer = null
5764
) {
5865
$this->paymentTokenFactory = $paymentTokenFactory;
5966
$this->paymentExtensionFactory = $paymentExtensionFactory;
6067
$this->config = $config;
6168
$this->subjectReader = $subjectReader;
69+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
70+
->get(\Magento\Framework\Serialize\SerializerInterface::class);
6271
}
6372

6473
/**
@@ -133,7 +142,7 @@ private function getExpirationDate(Transaction $transaction)
133142
*/
134143
private function convertDetailsToJSON($details)
135144
{
136-
$json = \Zend_Json::encode($details);
145+
$json = $this->serializer->serialize($details);
137146
return $json ? $json : '{}';
138147
}
139148

app/code/Magento/Braintree/Test/Unit/Gateway/Response/VaultDetailsHandlerTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,20 @@ protected function setUp()
122122
->method('getCctypesMapper')
123123
->willReturn($mapperArray);
124124

125+
$this->serializer = $this->getMock(
126+
\Magento\Framework\Serialize\SerializerInterface::class,
127+
[],
128+
[],
129+
'',
130+
false
131+
);
132+
125133
$this->paymentHandler = new VaultDetailsHandler(
126134
$this->paymentTokenFactory,
127135
$this->paymentExtensionFactory,
128136
$this->config,
129-
$this->subjectReader
137+
$this->subjectReader,
138+
$this->serializer
130139
);
131140
}
132141

0 commit comments

Comments
 (0)