/** * Retrieve card info object * * @return \Magento\Payment\Model\Info */ public function getInfo() { if ($this->hasCardInfoObject()) { return $this->getCardInfoObject(); } return parent::getInfo(); }
/** * @dataProvider getCcExpDateDataProvider */ public function testGetCcExpDate($ccExpMonth, $ccExpYear) { $paymentInfo = $this->getMock('Magento\\Payment\\Model\\Info', ['getCcExpMonth', 'getCcExpYear'], [], '', false); $paymentInfo->expects($this->any())->method('getCcExpMonth')->will($this->returnValue($ccExpMonth)); $paymentInfo->expects($this->any())->method('getCcExpYear')->will($this->returnValue($ccExpYear)); $this->model->setData('info', $paymentInfo); $this->localeDate->expects($this->exactly(2))->method('getConfigTimezone')->willReturn('America/Los_Angeles'); $this->assertEquals($ccExpYear, $this->model->getCcExpDate()->format('Y')); $this->assertEquals($ccExpMonth, $this->model->getCcExpDate()->format('m')); }
/** * Prepare PayPal-specific payment information * * @param \Magento\Framework\DataObject|array|null $transport * @return \Magento\Framework\DataObject */ protected function _prepareSpecificInformation($transport = null) { $transport = parent::_prepareSpecificInformation($transport); $payment = $this->getInfo(); $paypalInfo = $this->_paypalInfoFactory->create(); if ($this->getIsSecureMode()) { $info = $paypalInfo->getPublicPaymentInfo($payment, true); } else { $info = $paypalInfo->getPaymentInfo($payment, true); } return $transport->addData($info); }
/** * @dataProvider getCcExpDateDataProvider */ public function testGetCcExpDate($ccExpMonth, $ccExpYear) { $paymentInfo = $this->getMock('Magento\\Payment\\Model\\Info', ['getCcExpMonth', 'getCcExpYear'], [], '', false); $paymentInfo->expects($this->any())->method('getCcExpMonth')->will($this->returnValue($ccExpMonth)); $paymentInfo->expects($this->any())->method('getCcExpYear')->will($this->returnValue($ccExpYear)); $this->model->setData('info', $paymentInfo); $date = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface', ['setYear', 'getYear', 'setMonth', 'getMonth', 'getDefaultTimezonePath', 'getDefaultTimezone', 'getDateFormat', 'getDateFormatWithLongYear', 'getTimeFormat', 'getDateTimeFormat', 'date', 'scopeDate', 'utcDate', 'scopeTimeStamp', 'formatDate', 'formatTime', 'getConfigTimezone', 'isScopeDateInInterval'], [], '', false); $date->expects($this->any())->method('getYear')->willReturn($ccExpYear); $date->expects($this->any())->method('getMonth')->willReturn($ccExpMonth); $this->localeDate->expects($this->any())->method('date')->will($this->returnValue($date)); $this->assertEquals($ccExpYear, $this->model->getCcExpDate()->getYear()); $this->assertEquals($ccExpMonth, $this->model->getCcExpDate()->getMonth()); }