Skip to content

Commit

Permalink
Merge pull request #117 from magento-firedrakes/MAGETWO-53667
Browse files Browse the repository at this point in the history
[Firedrakes+MPI] Bugfixes and @API tags
  • Loading branch information
MomotenkoNatalia authored Jun 16, 2016
2 parents 1923cef + 22553f9 commit ac933c2
Show file tree
Hide file tree
Showing 86 changed files with 347 additions and 6 deletions.
7 changes: 5 additions & 2 deletions app/code/Magento/Payment/Model/Method/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,15 @@ private function executeCommand($commandCode, array $arguments = [])
return null;
}

if (isset($arguments['payment'])) {
/** @var InfoInterface|null $payment */
$payment = null;
if (isset($arguments['payment']) && $arguments['payment'] instanceof InfoInterface) {
$payment = $arguments['payment'];
$arguments['payment'] = $this->paymentDataObjectFactory->create($arguments['payment']);
}

if ($this->commandExecutor !== null) {
return $this->commandExecutor->executeByCode($commandCode, $arguments);
return $this->commandExecutor->executeByCode($commandCode, $payment, $arguments);
}

if ($this->commandPool === null) {
Expand Down
134 changes: 134 additions & 0 deletions app/code/Magento/Payment/Test/Unit/Model/Method/AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
namespace Magento\Payment\Test\Unit\Model\Method;

use Magento\Framework\Event\ManagerInterface;
use Magento\Payment\Gateway\Command\CommandManagerInterface;
use Magento\Payment\Gateway\Command\CommandPoolInterface;
use Magento\Payment\Gateway\CommandInterface;
use Magento\Payment\Gateway\Config\ValueHandlerInterface;
use Magento\Payment\Gateway\Config\ValueHandlerPoolInterface;
use Magento\Payment\Gateway\Data\PaymentDataObjectFactory;
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
use Magento\Payment\Gateway\Validator\ValidatorPoolInterface;
use Magento\Payment\Model\InfoInterface;
use Magento\Payment\Model\Method\Adapter;

class AdapterTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -158,4 +163,133 @@ public function testIsAvailableEmptyQuote()
$this->adapter->setInfoInstance($paymentInfo);
static::assertTrue($this->adapter->isAvailable(null));
}

public function testExecuteCommandWithCommandExecutor()
{
/** @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */
$eventManager = $this->getMock(
ManagerInterface::class
);

/** @var ValueHandlerPoolInterface|\PHPUnit_Framework_MockObject_MockObject $valueHandlerPool */
$valueHandlerPool = $this->getMock(
ValueHandlerPoolInterface::class
);

/** @var CommandManagerInterface|\PHPUnit_Framework_MockObject_MockObject $commandManager */
$commandManager = $this->getMock(
CommandManagerInterface::class
);

/** @var PaymentDataObjectFactory|\PHPUnit_Framework_MockObject_MockObject $paymentDataObjectFactory */
$paymentDataObjectFactory = $this->getMockBuilder(
PaymentDataObjectFactory::class
)
->disableOriginalConstructor()
->getMock();

$paymentInfo = $this->getMock(InfoInterface::class);
$paymentDO = $this->getMock(PaymentDataObjectInterface::class);

$adapter = new Adapter(
$eventManager,
$valueHandlerPool,
$paymentDataObjectFactory,
'CODE',
'\FormBlock',
'\InfoBlock',
null,
null,
$commandManager
);

$valueHandler = $this->getMock(ValueHandlerInterface::class);

$valueHandlerPool->expects(static::once())
->method('get')
->with('can_authorize')
->willReturn($valueHandler);
$valueHandler->expects(static::once())
->method('handle')
->with(['field' => 'can_authorize'])
->willReturn(true);

$paymentDataObjectFactory->expects(static::once())
->method('create')
->with($paymentInfo)
->willReturn($paymentDO);

$commandManager->expects(static::once())
->method('executeByCode')
->with('authorize', $paymentInfo, ['amount' => 10, 'payment' => $paymentDO])
->willReturn(null);

$adapter->authorize($paymentInfo, 10);
}

public function testExecuteCommandWithCommandPool()
{
/** @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject $eventManager */
$eventManager = $this->getMock(
ManagerInterface::class
);

/** @var ValueHandlerPoolInterface|\PHPUnit_Framework_MockObject_MockObject $valueHandlerPool */
$valueHandlerPool = $this->getMock(
ValueHandlerPoolInterface::class
);

/** @var CommandPoolInterface|\PHPUnit_Framework_MockObject_MockObject $commandPool */
$commandPool = $this->getMock(
CommandPoolInterface::class
);

/** @var PaymentDataObjectFactory|\PHPUnit_Framework_MockObject_MockObject $paymentDataObjectFactory */
$paymentDataObjectFactory = $this->getMockBuilder(
PaymentDataObjectFactory::class
)
->disableOriginalConstructor()
->getMock();

$paymentInfo = $this->getMock(InfoInterface::class);
$paymentDO = $this->getMock(PaymentDataObjectInterface::class);

$adapter = new Adapter(
$eventManager,
$valueHandlerPool,
$paymentDataObjectFactory,
'CODE',
'\FormBlock',
'\InfoBlock',
$commandPool
);

$valueHandler = $this->getMock(ValueHandlerInterface::class);
$command = $this->getMock(CommandInterface::class);

$valueHandlerPool->expects(static::once())
->method('get')
->with('can_authorize')
->willReturn($valueHandler);
$valueHandler->expects(static::once())
->method('handle')
->with(['field' => 'can_authorize'])
->willReturn(true);

$paymentDataObjectFactory->expects(static::once())
->method('create')
->with($paymentInfo)
->willReturn($paymentDO);

$commandPool->expects(static::once())
->method('get')
->with('authorize')
->willReturn($command);
$command->expects(static::once())
->method('execute')
->with(['amount' => 10, 'payment' => $paymentDO])
->willReturn(null);

$adapter->authorize($paymentInfo, 10);
}
}
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/App/Action/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use Magento\Framework\Controller\ResultFactory;

/**
* @api
*/
class Context implements \Magento\Framework\ObjectManager\ContextInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/App/ActionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework\App;

/**
* @api
*/
class ActionFactory
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/App/ActionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework\App;

/**
* @api
*/
interface ActionInterface
{
const FLAG_NO_DISPATCH = 'no-dispatch';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework\App\Area;

/**
* @api
*/
class FrontNameResolverFactory
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface FrontNameResolverInterface
/**
* Retrieve front name
*
* @param bool if true, only return frontname if it is valid for the host
* @param bool $checkHost if true, return front name only if it is valid for the current host
* @return string|bool
*/
public function getFrontName($checkHost = false);
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/Magento/Framework/App/Language/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* A service for reading language package dictionaries
*
* @api
*/
class Dictionary
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Framework\App\Request;

/**
* @api
*/
interface DataPersistorInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework\App\Request;

/**
* @api
*/
interface PathInfoProcessorInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/App/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework\App;

/**
* @api
*/
interface RequestInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/App/ResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework\App;

/**
* @api
*/
interface ResponseInterface
{
/**
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/Magento/Framework/App/View/Asset/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

/**
* A publishing service for view assets
*
* @api
*/
class Publisher
{
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/AppInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework;

/**
* @api
*/
interface AppInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/AuthorizationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace Magento\Framework;

/**
* @api
*/
interface AuthorizationInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* Provides ability to statically register components.
*
* @author Josh Di Fabio <[email protected]>
*
* @api
*/
class ComponentRegistrar implements ComponentRegistrarInterface
{
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/Magento/Framework/Controller/ResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* An abstraction of result that controller actions must return
* The point of this kind of object is to encapsulate all information/objects relevant to the result
* and be able to set it to the HTTP response
*
* @api
*/
interface ResultInterface
{
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/CurrencyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Framework;

/**
* @api
*/
interface CurrencyInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Interface that encapsulates complexity of expression computation
*
* @api
*/
interface InterpreterInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
namespace Magento\Framework\Data\Form\Filter;

/**
* @api
*/
interface FilterInterface
{
/**
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/Magento/Framework/Data/OptionSourceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Source of option values in a form of value-label pairs
*
* @api
*/
interface OptionSourceInterface
{
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
namespace Magento\Framework;

/**
* @api
*/
class Event extends \Magento\Framework\DataObject
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/Event/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use Magento\Framework\Event;

/**
* @api
*/
class Observer extends \Magento\Framework\DataObject
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Magento\Framework\Phrase;
use Magento\Framework\Phrase\Renderer\Placeholder;

/**
* @api
*/
class LocalizedException extends \Exception
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/Magento/Framework/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

use Magento\Framework\Filesystem\DriverPool;

/**
* @api
*/
class Filesystem
{
/**
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/Magento/Framework/Filesystem/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* Class Driver
*
* @api
*/
interface DriverInterface
{
Expand Down
Loading

0 comments on commit ac933c2

Please sign in to comment.