Skip to content

Commit

Permalink
Do not use GatewayAwareAction class. Use interface + trait
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Mar 27, 2017
1 parent 6b880f1 commit d4f6339
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 20 deletions.
6 changes: 5 additions & 1 deletion Action/AuthorizePaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Model\PaymentInterface;
use Payum\Core\Request\Authorize;
use Payum\Core\Request\Convert;
use Payum\Core\Request\GetHumanStatus;

class AuthorizePaymentAction extends GatewayAwareAction
class AuthorizePaymentAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;

/**
* {@inheritDoc}
*
Expand Down
6 changes: 5 additions & 1 deletion Action/CapturePaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Model\PaymentInterface;
use Payum\Core\Request\Capture;
use Payum\Core\Request\Convert;
use Payum\Core\Request\GetHumanStatus;

class CapturePaymentAction extends GatewayAwareAction
class CapturePaymentAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;

/**
* {@inheritDoc}
*
Expand Down
6 changes: 5 additions & 1 deletion Action/ExecuteSameRequestWithModelDetailsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Model\DetailsAggregateInterface;
use Payum\Core\Model\DetailsAwareInterface;
use Payum\Core\Model\ModelAggregateInterface;
use Payum\Core\Model\ModelAwareInterface;

class ExecuteSameRequestWithModelDetailsAction extends GatewayAwareAction
class ExecuteSameRequestWithModelDetailsAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;

/**
* {@inheritDoc}
*
Expand Down
2 changes: 1 addition & 1 deletion Action/GetCurrencyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Payum\Core\Request\GetCurrency;
use Payum\ISO4217\ISO4217;

class GetCurrencyAction extends GatewayAwareAction
class GetCurrencyAction implements ActionInterface
{
/**
* @var ISO4217
Expand Down
2 changes: 1 addition & 1 deletion Action/GetTokenAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Payum\Core\Request\GetToken;
use Payum\Core\Storage\StorageInterface;

class GetTokenAction extends GatewayAwareAction
class GetTokenAction implements ActionInterface
{
/**
* @var StorageInterface
Expand Down
8 changes: 6 additions & 2 deletions Bridge/Symfony/Action/ObtainCreditCardAction.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
namespace Payum\Core\Bridge\Symfony\Action;

use Payum\Core\Action\GatewayAwareAction;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Symfony\Form\Type\CreditCardType;
use Payum\Core\Bridge\Symfony\Reply\HttpResponse;
use Payum\Core\Exception\LogicException;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Model\CreditCardInterface;
use Payum\Core\Request\ObtainCreditCard;
use Payum\Core\Request\RenderTemplate;
Expand All @@ -15,8 +17,10 @@
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

class ObtainCreditCardAction extends GatewayAwareAction
class ObtainCreditCardAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;

/**
* @var FormFactoryInterface
*/
Expand Down
5 changes: 3 additions & 2 deletions Tests/Action/ExecuteSameRequestWithModelDetailsActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Payum\Core\Tests\Action;

use Payum\Core\Action\ExecuteSameRequestWithModelDetailsAction;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\Model\DetailsAggregateInterface;
use Payum\Core\Model\DetailsAwareInterface;
use Payum\Core\Model\ModelAggregateInterface;
Expand All @@ -25,11 +26,11 @@ public function provideSupportedRequests()
/**
* @test
*/
public function shouldBeSubClassOfGatewayAwareAction()
public function shouldImplementGatewayAwareInterface()
{
$rc = new \ReflectionClass($this->actionClass);

$this->assertTrue($rc->isSubclassOf('Payum\Core\Action\GatewayAwareAction'));
$this->assertTrue($rc->implementsInterface(GatewayAwareInterface::class));
}

/**
Expand Down
17 changes: 11 additions & 6 deletions Tests/Action/GatewayAwareActionTest.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
<?php
namespace Payum\Core\Tests\Action;

use Payum\Core\Action\ActionInterface;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayInterface;
use Payum\Core\Tests\GatewayAwareAction;

This comment has been minimized.

Copy link
@michallkanak

michallkanak Dec 11, 2017

  1. Unit test Error here @makasim
    ReflectionException: Class Payum\Core\Tests\GatewayAwareAction does not exist
    ...\vendor\payum\core\Payum\Core\Tests\Action\GatewayAwareActionTest.php:16

This comment has been minimized.

Copy link
@makasim

makasim Dec 11, 2017

Author Member

Could you please open an issue?

This comment has been minimized.

Copy link
@michallkanak

michallkanak Dec 11, 2017

Yes, i'll do it tomorrow.


class GatewayAwareActionTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldImplementActionInterface()
{
$rc = new \ReflectionClass('Payum\Core\Action\GatewayAwareAction');
$rc = new \ReflectionClass(GatewayAwareAction::class);

$this->assertTrue($rc->implementsInterface('Payum\Core\Action\ActionInterface'));
$this->assertTrue($rc->implementsInterface(ActionInterface::class));
}

/**
* @test
*/
public function shouldImplementGatewayAwareInterface()
{
$rc = new \ReflectionClass('Payum\Core\Action\GatewayAwareAction');
$rc = new \ReflectionClass(GatewayAwareAction::class);

$this->assertTrue($rc->implementsInterface('Payum\Core\GatewayAwareInterface'));
$this->assertTrue($rc->implementsInterface(GatewayAwareInterface::class));
}

/**
* @test
*/
public function shouldSetGatewayToProperty()
{
$gateway = $this->getMock('Payum\Core\GatewayInterface');
$gateway = $this->getMock(GatewayInterface::class);

$action = $this->getMockForAbstractClass('Payum\Core\Action\GatewayAwareAction');
$action = $this->getMockForAbstractClass(GatewayAwareAction::class);

$action->setGateway($gateway);

Expand Down
7 changes: 4 additions & 3 deletions Tests/Bridge/Symfony/Action/ObtainCreditCardActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Payum\Core\Bridge\Symfony\Action\ObtainCreditCardAction;
use Payum\Core\Bridge\Symfony\Form\Type\CreditCardType;
use Payum\Core\Bridge\Symfony\Reply\HttpResponse;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\Model\CreditCard;
use Payum\Core\GatewayInterface;
use Payum\Core\Request\ObtainCreditCard;
Expand All @@ -18,11 +19,11 @@ class ObtainCreditCardActionTest extends \PHPUnit_Framework_TestCase
/**
* @test
*/
public function shouldBeSubClassOfGatewayAwareAction()
public function shouldImplementGatewayAwareInterface()
{
$rc = new \ReflectionClass('Payum\Core\Bridge\Symfony\Action\ObtainCreditCardAction');
$rc = new \ReflectionClass(ObtainCreditCardAction::class);

$this->assertTrue($rc->isSubclassOf('Payum\Core\Action\GatewayAwareAction'));
$this->assertTrue($rc->implementsInterface(GatewayAwareInterface::class));
}

/**
Expand Down
8 changes: 6 additions & 2 deletions Tests/Mocks/Action/CaptureAction.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php
namespace Payum\Core\Tests\Mocks\Action;

use Payum\Core\Action\GatewayAwareAction;
use Payum\Core\Action\ActionInterface;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Tests\Mocks\Model\AuthorizeRequiredModel;
use Payum\Core\Request\Capture;
use Payum\Core\Tests\Mocks\Request\AuthorizeRequest;

class CaptureAction extends GatewayAwareAction
class CaptureAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit d4f6339

Please sign in to comment.