|
8 | 8 |
|
9 | 9 | namespace Magento\Payment\Test\Unit\Model;
|
10 | 10 |
|
11 |
| -use \Magento\Payment\Model\Config; |
12 |
| - |
13 |
| -use Magento\Store\Model\ScopeInterface; |
14 | 11 | 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; |
15 | 15 |
|
16 | 16 | class ConfigTest extends \PHPUnit_Framework_TestCase
|
17 | 17 | {
|
@@ -127,24 +127,23 @@ protected function setUp()
|
127 | 127 | */
|
128 | 128 | public function testGetActiveMethods($isActive)
|
129 | 129 | {
|
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()) |
144 | 143 | ->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()); |
148 | 147 | }
|
149 | 148 |
|
150 | 149 | public function getActiveMethodsDataProvider()
|
|
0 commit comments