-
Notifications
You must be signed in to change notification settings - Fork 107
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
11 changed files
with
184 additions
and
138 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 was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
Tests/Functional/PaymentWorkflow/BasePaymentWorkflowTest.php
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,52 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\Tests\Functional\PaymentWorkflow; | ||
|
||
use JMS\Payment\CoreBundle\Tests\Functional\BaseTestCase; | ||
use JMS\Payment\CoreBundle\Tests\Functional\TestBundle\Entity\Order; | ||
|
||
abstract class BasePaymentWorkflowTest extends BaseTestCase | ||
{ | ||
protected function getRawExtendedData($order) | ||
{ | ||
$em = self::$kernel->getContainer()->get('em'); | ||
|
||
$stmt = $em->getConnection()->prepare(' | ||
SELECT extended_data | ||
FROM payment_instructions | ||
WHERE id = '.$order->getPaymentInstruction()->getId() | ||
); | ||
|
||
$stmt->execute(); | ||
$result = $stmt->fetchAll(); | ||
|
||
return unserialize($result[0]['extended_data']); | ||
} | ||
|
||
protected function doRequest($order, $route) | ||
{ | ||
$client = $this->createClient(); | ||
$this->importDatabaseSchema(); | ||
|
||
$em = self::$kernel->getContainer()->get('em'); | ||
$router = self::$kernel->getContainer()->get('router'); | ||
|
||
$em->persist($order); | ||
$em->flush(); | ||
|
||
$crawler = $client->request('GET', $router->generate($route, array('id' => $order->getId()))); | ||
$form = $crawler->selectButton('submit_btn')->form(); | ||
$form['jms_choose_payment_method[method]']->select('paypal_express_checkout'); | ||
$client->submit($form); | ||
|
||
return $client->getResponse(); | ||
} | ||
|
||
protected function refreshOrder($order) | ||
{ | ||
$em = self::$kernel->getContainer()->get('em'); | ||
$em->clear(); | ||
|
||
return $em->getRepository('TestBundle:Order')->find($order->getId()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Tests/Functional/PaymentWorkflow/PaymentWorkflowMcryptTest.php
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,43 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\Tests\Functional\PaymentWorkflow; | ||
|
||
use JMS\Payment\CoreBundle\Tests\Functional\TestBundle\Entity\Order; | ||
use JMS\Payment\CoreBundle\Util\Number; | ||
|
||
class PaymentWorkflowMcryptTest extends PaymentWorkflowTest | ||
{ | ||
protected static function createKernel(array $options = array()) | ||
{ | ||
return parent::createKernel(array('config' => 'config_mcrypt.yml')); | ||
} | ||
|
||
public function setUp() | ||
{ | ||
if (version_compare(phpversion(), '7.1', '>=')) { | ||
$this->markTestSkipped('mcrypt is deprecated since PHP 7.1'); | ||
} | ||
|
||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testPayment() | ||
{ | ||
$amount = 123.45; | ||
$order = new Order($amount); | ||
|
||
$response = parent::doRequest($order, 'payment'); | ||
$order = $this->refreshOrder($order); | ||
|
||
$this->assertSame(201, $response->getStatusCode(), substr($response, 0, 2000)); | ||
$this->assertTrue(Number::compare($amount, $order->getPaymentInstruction()->getAmount(), '==')); | ||
$this->assertEquals('bar', $order->getPaymentInstruction()->getExtendedData()->get('foo')); | ||
|
||
$extendedData = $this->getRawExtendedData($order); | ||
$this->assertArrayHasKey('foo', $extendedData); | ||
$this->assertNotEquals('bar', $extendedData['foo'][0]); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Tests/Functional/PaymentWorkflow/PaymentWorkflowNoEncryptionTest.php
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,37 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\Tests\Functional\PaymentWorkflow; | ||
|
||
use JMS\Payment\CoreBundle\Tests\Functional\TestBundle\Entity\Order; | ||
use JMS\Payment\CoreBundle\Util\Number; | ||
|
||
class PaymentWorkflowNoEncryptionTest extends BasePaymentWorkflowTest | ||
{ | ||
/** | ||
* Disable encryption globally. | ||
*/ | ||
protected static function createKernel(array $options = array()) | ||
{ | ||
return parent::createKernel(array('config' => 'config_no_encryption.yml')); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testPayment() | ||
{ | ||
$amount = 123.45; | ||
$order = new Order($amount); | ||
|
||
$response = parent::doRequest($order, 'payment'); | ||
$order = $this->refreshOrder($order); | ||
|
||
$this->assertSame(201, $response->getStatusCode(), substr($response, 0, 2000)); | ||
$this->assertTrue(Number::compare($amount, $order->getPaymentInstruction()->getAmount(), '==')); | ||
$this->assertEquals('bar', $order->getPaymentInstruction()->getExtendedData()->get('foo')); | ||
|
||
$extendedData = $this->getRawExtendedData($order); | ||
$this->assertArrayHasKey('foo', $extendedData); | ||
$this->assertEquals('bar', $extendedData['foo'][0]); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\Tests\Functional\PaymentWorkflow; | ||
|
||
use JMS\Payment\CoreBundle\Tests\Functional\TestBundle\Entity\Order; | ||
use JMS\Payment\CoreBundle\Util\Number; | ||
|
||
class PaymentWorkflowTest extends BasePaymentWorkflowTest | ||
{ | ||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testPayment() | ||
{ | ||
$amount = 123.45; | ||
$order = new Order($amount); | ||
|
||
$response = parent::doRequest($order, 'payment'); | ||
$order = $this->refreshOrder($order); | ||
|
||
$this->assertSame(201, $response->getStatusCode(), substr($response, 0, 2000)); | ||
$this->assertTrue(Number::compare($amount, $order->getPaymentInstruction()->getAmount(), '==')); | ||
$this->assertEquals('bar', $order->getPaymentInstruction()->getExtendedData()->get('foo')); | ||
|
||
$extendedData = $this->getRawExtendedData($order); | ||
$this->assertArrayHasKey('foo', $extendedData); | ||
$this->assertNotEquals('bar', $extendedData['foo'][0]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.