-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
546 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace IDCI\Bundle\PaymentBundle\Tests\Unit\Gateway; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use IDCI\Bundle\PaymentBundle\Gateway\PayPlugPaymentGateway; | ||
|
||
class PayPlugPaymentGatewayTest extends PaymentGatewayTestCase | ||
{ | ||
/** | ||
* UrlGeneratorInterface | ||
*/ | ||
private $router; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->router = $this->getMockBuilder(UrlGeneratorInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock() | ||
; | ||
|
||
$this->gateway = new PayPlugPaymentGateway($this->twig, $this->router); | ||
} | ||
|
||
/** | ||
* @expectedException IDCI\Bundle\PaymentBundle\Exception\InvalidPaymentCallbackMethodException | ||
*/ | ||
public function testInvalidMethod() | ||
{ | ||
$request = Request::create('dumy_uri', Request::METHOD_GET); | ||
|
||
$this->gateway->getResponse($request, $this->paymentGatewayConfiguration); | ||
} | ||
|
||
public function getResponse() | ||
{ | ||
$request = Request::create('dumy_uri', Request::METHOD_POST); | ||
|
||
$data = $this->gateway->getResponse($request, $this->paymentGatewayConfiguration); | ||
var_dump($data);die; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace IDCI\Bundle\PaymentBundle\Tests\Unit\Gateway; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Twig\Environment as TwigEnvironment; | ||
use Twig\Loader\FilesystemLoader; | ||
use IDCI\Bundle\PaymentBundle\Model\PaymentGatewayConfiguration; | ||
use IDCI\Bundle\PaymentBundle\Model\Transaction; | ||
use IDCI\Bundle\PaymentBundle\Payment\TransactionFactory; | ||
|
||
class PaymentGatewayTestCase extends TestCase | ||
{ | ||
/** | ||
* @var \Twig_Environment | ||
*/ | ||
protected $twig; | ||
|
||
/** | ||
* @var Transaction | ||
*/ | ||
protected $transaction; | ||
|
||
/** | ||
* @var PaymentGatewayConfiguration | ||
*/ | ||
protected $paymentGatewayConfiguration; | ||
|
||
/** | ||
* @var PaymentGatewayInterface | ||
*/ | ||
protected $gateway; | ||
|
||
public function setUp() | ||
{ | ||
$loader = new FilesystemLoader(); | ||
$loader->addPath(__DIR__ . '/../../..', 'IDCIPaymentBundle'); | ||
|
||
$this->twig = new TwigEnvironment($loader); | ||
|
||
$this->paymentGatewayConfiguration = (new PaymentGatewayConfiguration()) | ||
->setAlias('dummy_gateway_alias') | ||
; | ||
|
||
$this->transaction = TransactionFactory::getInstance()->create([ | ||
'gateway_configuration_alias' => $this->paymentGatewayConfiguration->getAlias(), | ||
'item_id' => 'dummy_item_id', | ||
'customer_id' => 'dummy_customer_id', | ||
'customer_email' => 'dummy_customer_email', | ||
'amount' => 100, | ||
'currency_code' => 'EUR', | ||
'description' => 'Dummy description', | ||
'metadatas' => [], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace IDCI\Bundle\PaymentBundle\Tests\Unit\Gateway; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use IDCI\Bundle\PaymentBundle\Gateway\PaypalPaymentGateway; | ||
|
||
class PaypalPaymentGatewayTest extends PaymentGatewayTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->gateway = new PaypalPaymentGateway($this->twig); | ||
} | ||
|
||
public function testInitialize() | ||
{ | ||
$this->paymentGatewayConfiguration | ||
->set('client_id', 'dummy_client_id') | ||
->set('callback_url', 'dummy_callback_url') | ||
->set('environment', 'dummy_environment') | ||
; | ||
|
||
$data = $this->gateway->initialize($this->paymentGatewayConfiguration, $this->transaction); | ||
|
||
$this->assertEquals($this->paymentGatewayConfiguration->get('client_id'), $data['clientId']); | ||
$this->assertEquals($this->paymentGatewayConfiguration->get('callback_url'), $data['url']); | ||
$this->assertEquals($this->paymentGatewayConfiguration->get('environment'), $data['environment']); | ||
$this->assertEquals($this->transaction, $data['transaction']); | ||
} | ||
|
||
/** | ||
* @expectedException IDCI\Bundle\PaymentBundle\Exception\InvalidPaymentCallbackMethodException | ||
*/ | ||
public function testInvalidMethod() | ||
{ | ||
$request = Request::create('dumy_uri', Request::METHOD_GET); | ||
|
||
$this->gateway->getResponse($request, $this->paymentGatewayConfiguration); | ||
} | ||
} |
Oops, something went wrong.