Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
CcTest Class Reference
Inheritance diagram for CcTest:

Public Member Functions

 testGetCcTypeName ($configCcTypes, $ccType, $expected)
 
 getCcTypeNameDataProvider ()
 
 testHasCcExpDate ($ccExpMonth, $ccExpYear, $expected)
 
 hasCcExpDateDataProvider ()
 
 testGetCcExpMonth ($ccExpMonth, $expected)
 
 ccExpMonthDataProvider ()
 
 testGetCcExpDate ($ccExpMonth, $ccExpYear)
 
 getCcExpDateDataProvider ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $model
 
 $objectManager
 
 $paymentConfig
 
 $localeDate
 

Detailed Description

Definition at line 9 of file CcTest.php.

Member Function Documentation

◆ ccExpMonthDataProvider()

ccExpMonthDataProvider ( )
Returns
array

Definition at line 121 of file CcTest.php.

122  {
123  return [
124  [2, '02'],
125  [12, '12']
126  ];
127  }

◆ getCcExpDateDataProvider()

getCcExpDateDataProvider ( )
Returns
array

Definition at line 157 of file CcTest.php.

158  {
159  return [
160  [3, 2015],
161  [12, 2011],
162  [01, 2036]
163  ];
164  }

◆ getCcTypeNameDataProvider()

getCcTypeNameDataProvider ( )
Returns
array

Definition at line 68 of file CcTest.php.

69  {
70  return [
71  [['VS', 'MC', 'JCB'], 'JCB', 'JCB'],
72  [['VS', 'MC', 'JCB'], 'BNU', 'BNU'],
73  [['VS', 'MC', 'JCB'], null, 'N/A'],
74  ];
75  }

◆ hasCcExpDateDataProvider()

hasCcExpDateDataProvider ( )
Returns
array

Definition at line 96 of file CcTest.php.

97  {
98  return [
99  [0, 1, true],
100  [1, 0, true],
101  [0, 0, false]
102  ];
103  }

◆ setUp()

setUp ( )
protected

Definition at line 31 of file CcTest.php.

32  {
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,
42  [
43  'paymentConfig' => $this->paymentConfig,
44  'context' => $context
45  ]
46  );
47  }

◆ testGetCcExpDate()

testGetCcExpDate (   $ccExpMonth,
  $ccExpYear 
)

@dataProvider getCcExpDateDataProvider

Definition at line 132 of file CcTest.php.

133  {
134  $paymentInfo = $this->createPartialMock(\Magento\Payment\Model\Info::class, ['getCcExpMonth', 'getCcExpYear']);
136  ->expects($this->any())
137  ->method('getCcExpMonth')
138  ->willReturn($ccExpMonth);
140  ->expects($this->any())
141  ->method('getCcExpYear')
142  ->willReturn($ccExpYear);
143  $this->model->setData('info', $paymentInfo);
144 
145  $this->localeDate
146  ->expects($this->exactly(2))
147  ->method('getConfigTimezone')
148  ->willReturn('America/Los_Angeles');
149 
150  $this->assertEquals($ccExpYear, $this->model->getCcExpDate()->format('Y'));
151  $this->assertEquals($ccExpMonth, $this->model->getCcExpDate()->format('m'));
152  }
$paymentInfo
$ccExpYear
Definition: info.phtml:18
$ccExpMonth
Definition: info.phtml:17

◆ testGetCcExpMonth()

testGetCcExpMonth (   $ccExpMonth,
  $expected 
)

@dataProvider ccExpMonthDataProvider

Definition at line 108 of file CcTest.php.

109  {
110  $paymentInfo = $this->createPartialMock(\Magento\Payment\Model\Info::class, ['getCcExpMonth']);
111  $paymentInfo->expects($this->any())
112  ->method('getCcExpMonth')
113  ->will($this->returnValue($ccExpMonth));
114  $this->model->setData('info', $paymentInfo);
115  $this->assertEquals($expected, $this->model->getCcExpMonth());
116  }
$paymentInfo
$ccExpMonth
Definition: info.phtml:17

◆ testGetCcTypeName()

testGetCcTypeName (   $configCcTypes,
  $ccType,
  $expected 
)

@dataProvider getCcTypeNameDataProvider

Definition at line 52 of file CcTest.php.

53  {
54  $this->paymentConfig->expects($this->any())
55  ->method('getCcTypes')
56  ->will($this->returnValue($configCcTypes));
57  $paymentInfo = $this->createPartialMock(\Magento\Payment\Model\Info::class, ['getCcType']);
58  $paymentInfo->expects($this->any())
59  ->method('getCcType')
60  ->will($this->returnValue($ccType));
61  $this->model->setData('info', $paymentInfo);
62  $this->assertEquals($expected, $this->model->getCcTypeName());
63  }
$paymentInfo
$ccType
Definition: info.phtml:16

◆ testHasCcExpDate()

testHasCcExpDate (   $ccExpMonth,
  $ccExpYear,
  $expected 
)

@dataProvider hasCcExpDateDataProvider

Definition at line 80 of file CcTest.php.

81  {
82  $paymentInfo = $this->createPartialMock(\Magento\Payment\Model\Info::class, ['getCcExpMonth', 'getCcExpYear']);
83  $paymentInfo->expects($this->any())
84  ->method('getCcExpMonth')
85  ->will($this->returnValue($ccExpMonth));
86  $paymentInfo->expects($this->any())
87  ->method('getCcExpYear')
88  ->will($this->returnValue($ccExpYear));
89  $this->model->setData('info', $paymentInfo);
90  $this->assertEquals($expected, $this->model->hasCcExpDate());
91  }
$paymentInfo
$ccExpYear
Definition: info.phtml:18
$ccExpMonth
Definition: info.phtml:17

Field Documentation

◆ $localeDate

$localeDate
protected

Definition at line 29 of file CcTest.php.

◆ $model

$model
protected

Definition at line 14 of file CcTest.php.

◆ $objectManager

$objectManager
protected

Definition at line 19 of file CcTest.php.

◆ $paymentConfig

$paymentConfig
protected

Definition at line 24 of file CcTest.php.


The documentation for this class was generated from the following file: