9 class CcTest extends \PHPUnit\Framework\TestCase
33 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
34 $this->paymentConfig = $this->createMock(\
Magento\Payment\Model\Config::class);
35 $this->localeDate = $this->createMock(\
Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
36 $context = $this->createPartialMock(\
Magento\Framework\View\Element\Template\Context::class, [
'getLocaleDate']);
37 $context->expects($this->any())
38 ->method(
'getLocaleDate')
39 ->will($this->returnValue($this->localeDate));
40 $this->model = $this->objectManager->getObject(
41 \
Magento\Payment\Block\Info\Cc::class,
43 'paymentConfig' => $this->paymentConfig,
54 $this->paymentConfig->expects($this->any())
55 ->method(
'getCcTypes')
56 ->will($this->returnValue($configCcTypes));
60 ->will($this->returnValue(
$ccType));
62 $this->assertEquals($expected, $this->model->getCcTypeName());
71 [[
'VS',
'MC',
'JCB'],
'JCB',
'JCB'],
72 [[
'VS',
'MC',
'JCB'],
'BNU',
'BNU'],
73 [[
'VS',
'MC',
'JCB'],
null,
'N/A'],
82 $paymentInfo = $this->createPartialMock(\
Magento\Payment\Model\Info::class, [
'getCcExpMonth',
'getCcExpYear']);
84 ->method(
'getCcExpMonth')
87 ->method(
'getCcExpYear')
90 $this->assertEquals($expected, $this->model->hasCcExpDate());
110 $paymentInfo = $this->createPartialMock(\
Magento\Payment\Model\Info::class, [
'getCcExpMonth']);
112 ->method(
'getCcExpMonth')
115 $this->assertEquals($expected, $this->model->getCcExpMonth());
134 $paymentInfo = $this->createPartialMock(\
Magento\Payment\Model\Info::class, [
'getCcExpMonth',
'getCcExpYear']);
136 ->expects($this->any())
137 ->method(
'getCcExpMonth')
140 ->expects($this->any())
141 ->method(
'getCcExpYear')
146 ->expects($this->exactly(2))
147 ->method(
'getConfigTimezone')
148 ->willReturn(
'America/Los_Angeles');
150 $this->assertEquals(
$ccExpYear, $this->model->getCcExpDate()->format(
'Y'));
151 $this->assertEquals(
$ccExpMonth, $this->model->getCcExpDate()->format(
'm'));
hasCcExpDateDataProvider()
getCcTypeNameDataProvider()
testHasCcExpDate($ccExpMonth, $ccExpYear, $expected)
testGetCcTypeName($configCcTypes, $ccType, $expected)
getCcExpDateDataProvider()
testGetCcExpDate($ccExpMonth, $ccExpYear)
testGetCcExpMonth($ccExpMonth, $expected)