47 private $paymentMethodsList = [
48 'not_active_method' => [
'active' => 0],
49 'active_method_no_model' => [
'active' => 1],
50 'active_method' => [
'active' => 1,
'model' =>
'model_name'],
100 $this->scopeConfig = $this->createMock(\
Magento\Framework\
App\
Config\ScopeConfigInterface::class);
101 $this->paymentMethodFactory = $this->createMock(\
Magento\
Payment\Model\Method\Factory::class);
102 $this->localeResolver = $this->createMock(\
Magento\Framework\Locale\ResolverInterface::class);
103 $this->dataStorage = $this->createMock(\
Magento\Framework\
Config\DataInterface::class);
104 $this->date = $this->createMock(\
Magento\Framework\Stdlib\DateTime\DateTime::class);
106 $this->objectManagerHelper =
new ObjectManagerHelper($this);
107 $this->config = $this->objectManagerHelper->getObject(
110 'scopeConfig' => $this->scopeConfig,
111 'paymentMethodFactory' => $this->paymentMethodFactory,
112 'localeResolver' => $this->localeResolver,
113 'dataStorage' => $this->dataStorage,
114 'date' => $this->date
126 $adapter = $this->createMock(MethodInterface::class);
127 $this->scopeConfig->expects(static::once())
130 ->willReturn($this->paymentMethodsList);
131 $this->paymentMethodFactory->expects(static::once())
133 ->with($this->paymentMethodsList[
'active_method'][
'model'])
139 ->method(
'getConfigData')
140 ->with(
'active', static::isNull())
141 ->willReturn($isActive);
142 static::assertEquals($isActive ? [
'active_method' =>
$adapter] : [], $this->config->getActiveMethods());
150 return [[
true], [
false]];
156 $this->dataStorage->expects($this->once())->method(
'get')->with(
'credit_cards')->will(
157 $this->returnValue($expected)
159 $this->assertEquals($expected, $this->config->getCcTypes());
165 $this->dataStorage->expects($this->once())->method(
'get')->with(
'methods')->will(
166 $this->returnValue($expected)
168 $this->assertEquals($expected, $this->config->getMethodsInfo());
174 $this->dataStorage->expects($this->once())->method(
'get')->with(
'groups')->will(
175 $this->returnValue($expected)
177 $this->assertEquals($expected, $this->config->getGroups());
182 $this->localeResolver->expects($this->once())->method(
'getLocale')->willReturn(
'en_US');
183 $this->assertEquals($this->expectedMonthList, $this->config->getMonths());
188 $this->date->expects($this->once())->method(
'date')->with(
'Y')->will($this->returnValue(self::CURRENT_YEAR));
189 $this->assertEquals($this->_getPreparedYearsList(), $this->config->getYears());
197 private function _getPreparedYearsList()
199 $expectedYearsList = [];
201 $year = (int)self::CURRENT_YEAR +
$index;
202 $expectedYearsList[$year] = $year;
204 return $expectedYearsList;
testGetActiveMethods($isActive)
getActiveMethodsDataProvider()