Skip to content

Commit dcada9c

Browse files
committed
MAGETWO-56952: [Backport] Issue with get active payment methods (getActiveMethods) for 2.1.x
- Removed unnecessary setter
1 parent d530867 commit dcada9c

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

app/code/Magento/Payment/Model/Config.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public function getActiveMethods()
9595
if (isset($data['active'], $data['model']) && (bool)$data['active']) {
9696
/** @var MethodInterface $methodModel Actually it's wrong interface */
9797
$methodModel = $this->_paymentMethodFactory->create($data['model']);
98-
$methodModel->setId($code);
9998
$methodModel->setStore(null);
10099
if ($methodModel->getConfigData('active', null)) {
101100
$methods[$code] = $methodModel;

app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
namespace Magento\Payment\Test\Unit\Model;
1010

11-
use \Magento\Payment\Model\Config;
12-
13-
use Magento\Store\Model\ScopeInterface;
1411
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
12+
use Magento\Payment\Model\Config;
13+
use Magento\Payment\Model\MethodInterface;
14+
use Magento\Store\Model\ScopeInterface;
1515

1616
class ConfigTest extends \PHPUnit_Framework_TestCase
1717
{
@@ -127,24 +127,23 @@ protected function setUp()
127127
*/
128128
public function testGetActiveMethods($isActive)
129129
{
130-
$abstractMethod = $this->getMockBuilder(
131-
'Magento\Payment\Model\Method\AbstractMethod'
132-
)->disableOriginalConstructor()->setMethods(['setId', 'setStore', 'getConfigData'])->getMock();
133-
$this->scopeConfig->expects($this->once())->method('getValue')->with(
134-
'payment', ScopeInterface::SCOPE_STORE, null
135-
)->will($this->returnValue($this->paymentMethodsList));
136-
$this->paymentMethodFactory->expects($this->once())->method('create')->with(
137-
$this->paymentMethodsList['active_method']['model']
138-
)->will($this->returnValue($abstractMethod));
139-
$abstractMethod->expects($this->any())->method('setId')->with('active_method')->will(
140-
$this->returnValue($abstractMethod)
141-
);
142-
$abstractMethod->expects($this->any())->method('setStore')->with(null);
143-
$abstractMethod->expects($this->any())
130+
$adapter = $this->getMock(MethodInterface::class);
131+
$this->scopeConfig->expects(static::once())
132+
->method('getValue')
133+
->with('payment', ScopeInterface::SCOPE_STORE, null)
134+
->willReturn($this->paymentMethodsList);
135+
$this->paymentMethodFactory->expects(static::once())
136+
->method('create')
137+
->with($this->paymentMethodsList['active_method']['model'])
138+
->willReturn($adapter);
139+
$adapter->expects(static::once())
140+
->method('setStore')
141+
->with(null);
142+
$adapter->expects(static::once())
144143
->method('getConfigData')
145-
->with('active', $this->isNull())
146-
->will($this->returnValue($isActive));
147-
$this->assertEquals($isActive ? ['active_method' => $abstractMethod] : [], $this->config->getActiveMethods());
144+
->with('active', static::isNull())
145+
->willReturn($isActive);
146+
static::assertEquals($isActive ? ['active_method' => $adapter] : [], $this->config->getActiveMethods());
148147
}
149148

150149
public function getActiveMethodsDataProvider()

0 commit comments

Comments
 (0)