Skip to content

Commit ac933c2

Browse files
Merge pull request #117 from magento-firedrakes/MAGETWO-53667
[Firedrakes+MPI] Bugfixes and @API tags
2 parents 1923cef + 22553f9 commit ac933c2

File tree

86 files changed

+347
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+347
-6
lines changed

app/code/Magento/Payment/Model/Method/Adapter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,15 @@ private function executeCommand($commandCode, array $arguments = [])
507507
return null;
508508
}
509509

510-
if (isset($arguments['payment'])) {
510+
/** @var InfoInterface|null $payment */
511+
$payment = null;
512+
if (isset($arguments['payment']) && $arguments['payment'] instanceof InfoInterface) {
513+
$payment = $arguments['payment'];
511514
$arguments['payment'] = $this->paymentDataObjectFactory->create($arguments['payment']);
512515
}
513516

514517
if ($this->commandExecutor !== null) {
515-
return $this->commandExecutor->executeByCode($commandCode, $arguments);
518+
return $this->commandExecutor->executeByCode($commandCode, $payment, $arguments);
516519
}
517520

518521
if ($this->commandPool === null) {

app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
namespace Magento\Payment\Test\Unit\Model\Method;
77

88
use Magento\Framework\Event\ManagerInterface;
9+
use Magento\Payment\Gateway\Command\CommandManagerInterface;
910
use Magento\Payment\Gateway\Command\CommandPoolInterface;
11+
use Magento\Payment\Gateway\CommandInterface;
12+
use Magento\Payment\Gateway\Config\ValueHandlerInterface;
1013
use Magento\Payment\Gateway\Config\ValueHandlerPoolInterface;
1114
use Magento\Payment\Gateway\Data\PaymentDataObjectFactory;
15+
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
1216
use Magento\Payment\Gateway\Validator\ValidatorPoolInterface;
17+
use Magento\Payment\Model\InfoInterface;
1318
use Magento\Payment\Model\Method\Adapter;
1419

1520
class AdapterTest extends \PHPUnit_Framework_TestCase
@@ -158,4 +163,133 @@ public function testIsAvailableEmptyQuote()
158163
$this->adapter->setInfoInstance($paymentInfo);
159164
static::assertTrue($this->adapter->isAvailable(null));
160165
}
166+
167+
public function testExecuteCommandWithCommandExecutor()
168+
{
169+
/** @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */
170+
$eventManager = $this->getMock(
171+
ManagerInterface::class
172+
);
173+
174+
/** @var ValueHandlerPoolInterface|\PHPUnit_Framework_MockObject_MockObject $valueHandlerPool */
175+
$valueHandlerPool = $this->getMock(
176+
ValueHandlerPoolInterface::class
177+
);
178+
179+
/** @var CommandManagerInterface|\PHPUnit_Framework_MockObject_MockObject $commandManager */
180+
$commandManager = $this->getMock(
181+
CommandManagerInterface::class
182+
);
183+
184+
/** @var PaymentDataObjectFactory|\PHPUnit_Framework_MockObject_MockObject $paymentDataObjectFactory */
185+
$paymentDataObjectFactory = $this->getMockBuilder(
186+
PaymentDataObjectFactory::class
187+
)
188+
->disableOriginalConstructor()
189+
->getMock();
190+
191+
$paymentInfo = $this->getMock(InfoInterface::class);
192+
$paymentDO = $this->getMock(PaymentDataObjectInterface::class);
193+
194+
$adapter = new Adapter(
195+
$eventManager,
196+
$valueHandlerPool,
197+
$paymentDataObjectFactory,
198+
'CODE',
199+
'\FormBlock',
200+
'\InfoBlock',
201+
null,
202+
null,
203+
$commandManager
204+
);
205+
206+
$valueHandler = $this->getMock(ValueHandlerInterface::class);
207+
208+
$valueHandlerPool->expects(static::once())
209+
->method('get')
210+
->with('can_authorize')
211+
->willReturn($valueHandler);
212+
$valueHandler->expects(static::once())
213+
->method('handle')
214+
->with(['field' => 'can_authorize'])
215+
->willReturn(true);
216+
217+
$paymentDataObjectFactory->expects(static::once())
218+
->method('create')
219+
->with($paymentInfo)
220+
->willReturn($paymentDO);
221+
222+
$commandManager->expects(static::once())
223+
->method('executeByCode')
224+
->with('authorize', $paymentInfo, ['amount' => 10, 'payment' => $paymentDO])
225+
->willReturn(null);
226+
227+
$adapter->authorize($paymentInfo, 10);
228+
}
229+
230+
public function testExecuteCommandWithCommandPool()
231+
{
232+
/** @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */
233+
$eventManager = $this->getMock(
234+
ManagerInterface::class
235+
);
236+
237+
/** @var ValueHandlerPoolInterface|\PHPUnit_Framework_MockObject_MockObject $valueHandlerPool */
238+
$valueHandlerPool = $this->getMock(
239+
ValueHandlerPoolInterface::class
240+
);
241+
242+
/** @var CommandPoolInterface|\PHPUnit_Framework_MockObject_MockObject $commandPool */
243+
$commandPool = $this->getMock(
244+
CommandPoolInterface::class
245+
);
246+
247+
/** @var PaymentDataObjectFactory|\PHPUnit_Framework_MockObject_MockObject $paymentDataObjectFactory */
248+
$paymentDataObjectFactory = $this->getMockBuilder(
249+
PaymentDataObjectFactory::class
250+
)
251+
->disableOriginalConstructor()
252+
->getMock();
253+
254+
$paymentInfo = $this->getMock(InfoInterface::class);
255+
$paymentDO = $this->getMock(PaymentDataObjectInterface::class);
256+
257+
$adapter = new Adapter(
258+
$eventManager,
259+
$valueHandlerPool,
260+
$paymentDataObjectFactory,
261+
'CODE',
262+
'\FormBlock',
263+
'\InfoBlock',
264+
$commandPool
265+
);
266+
267+
$valueHandler = $this->getMock(ValueHandlerInterface::class);
268+
$command = $this->getMock(CommandInterface::class);
269+
270+
$valueHandlerPool->expects(static::once())
271+
->method('get')
272+
->with('can_authorize')
273+
->willReturn($valueHandler);
274+
$valueHandler->expects(static::once())
275+
->method('handle')
276+
->with(['field' => 'can_authorize'])
277+
->willReturn(true);
278+
279+
$paymentDataObjectFactory->expects(static::once())
280+
->method('create')
281+
->with($paymentInfo)
282+
->willReturn($paymentDO);
283+
284+
$commandPool->expects(static::once())
285+
->method('get')
286+
->with('authorize')
287+
->willReturn($command);
288+
$command->expects(static::once())
289+
->method('execute')
290+
->with(['amount' => 10, 'payment' => $paymentDO])
291+
->willReturn(null);
292+
293+
$adapter->authorize($paymentInfo, 10);
294+
}
161295
}

lib/internal/Magento/Framework/App/Action/Context.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\Controller\ResultFactory;
99

10+
/**
11+
* @api
12+
*/
1013
class Context implements \Magento\Framework\ObjectManager\ContextInterface
1114
{
1215
/**

lib/internal/Magento/Framework/App/ActionFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
namespace Magento\Framework\App;
99

10+
/**
11+
* @api
12+
*/
1013
class ActionFactory
1114
{
1215
/**

lib/internal/Magento/Framework/App/ActionInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
namespace Magento\Framework\App;
99

10+
/**
11+
* @api
12+
*/
1013
interface ActionInterface
1114
{
1215
const FLAG_NO_DISPATCH = 'no-dispatch';

lib/internal/Magento/Framework/App/Area/FrontNameResolverFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
namespace Magento\Framework\App\Area;
99

10+
/**
11+
* @api
12+
*/
1013
class FrontNameResolverFactory
1114
{
1215
/**

lib/internal/Magento/Framework/App/Area/FrontNameResolverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface FrontNameResolverInterface
1616
/**
1717
* Retrieve front name
1818
*
19-
* @param bool if true, only return frontname if it is valid for the host
19+
* @param bool $checkHost if true, return front name only if it is valid for the current host
2020
* @return string|bool
2121
*/
2222
public function getFrontName($checkHost = false);

lib/internal/Magento/Framework/App/Language/Dictionary.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* A service for reading language package dictionaries
14+
*
15+
* @api
1416
*/
1517
class Dictionary
1618
{

lib/internal/Magento/Framework/App/Request/DataPersistorInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Framework\App\Request;
77

8+
/**
9+
* @api
10+
*/
811
interface DataPersistorInterface
912
{
1013
/**

lib/internal/Magento/Framework/App/Request/PathInfoProcessorInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
namespace Magento\Framework\App\Request;
99

10+
/**
11+
* @api
12+
*/
1013
interface PathInfoProcessorInterface
1114
{
1215
/**

0 commit comments

Comments
 (0)