Skip to content

Commit

Permalink
Remove paypal plugin dependency (schmittjoh#220)
Browse files Browse the repository at this point in the history
* Cache and test dirs for tests should be in tmp directory

* Add a TestPlugin to use instead of the paypal plugin

* Remove all references to paypal plugin in favor of the test plugin
  • Loading branch information
psrpinto authored Nov 19, 2017
1 parent 271d26d commit 6982285
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Tests/Form/ChoosePaymentMethodTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace JMS\Payment\CoreBundle\Tests\Form\ChoosePaymentMethodTypeTest;

use JMS\Payment\CoreBundle\Form\ChoosePaymentMethodType;
use JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\Form\TestPluginType;
use JMS\Payment\CoreBundle\Util\Legacy;
use JMS\Payment\PaypalBundle\Form\ExpressCheckoutType;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Component\HttpKernel\Kernel;
Expand Down Expand Up @@ -50,7 +50,7 @@ public function testMethodData()
$config = $form->get('data_'.$method)->getConfig();

$this->assertInstanceOf(
'JMS\Payment\PaypalBundle\Form\ExpressCheckoutType',
'JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\Form\TestPluginType',
$config->getType()->getInnerType()
);
}
Expand Down Expand Up @@ -194,7 +194,7 @@ protected function setUp()

protected function getExtensions()
{
$pluginType = new ExpressCheckoutType();
$pluginType = new TestPluginType();

if (Legacy::supportsFormTypeClass()) {
$pluginTypeName = get_class($pluginType);
Expand Down
10 changes: 8 additions & 2 deletions Tests/Functional/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace JMS\Payment\CoreBundle\Tests\Functional;

use JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\TestPluginBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;
Expand Down Expand Up @@ -34,7 +35,7 @@ public function registerBundles()
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \JMS\Payment\CoreBundle\Tests\Functional\TestBundle\TestBundle(),
new \JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
new \JMS\Payment\PaypalBundle\JMSPaymentPaypalBundle(),
new TestPluginBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
);
}
Expand All @@ -46,6 +47,11 @@ public function registerContainerConfiguration(LoaderInterface $loader)

public function getCacheDir()
{
return sys_get_temp_dir().'/JMSPaymentCoreBundle';
return sys_get_temp_dir().'/JMSPaymentCoreBundle/cache';
}

public function getLogDir()
{
return sys_get_temp_dir().'/JMSPaymentCoreBundle/logs';
}
}
2 changes: 1 addition & 1 deletion Tests/Functional/BasePaymentWorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function doTestPaymentDetails()

$crawler = $client->request('GET', $router->generate('payment_details', array('id' => $order->getId())));
$form = $crawler->selectButton('submit_btn')->form();
$form['jms_choose_payment_method[method]']->select('paypal_express_checkout');
$form['jms_choose_payment_method[method]']->select('test_plugin');
$client->submit($form);

$response = $client->getResponse();
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/BasicEntityInteractionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testIndependentCredit()
$c = self::$kernel->getContainer();
$ppc = $c->get('payment.plugin_controller');
$em = $c->get('doctrine.orm.entity_manager');
$instruction = new PaymentInstruction(123.45, 'EUR', 'paypal_express_checkout');
$instruction = new PaymentInstruction(123.45, 'EUR', 'test_plugin');
$ppc->createPaymentInstruction($instruction);
$credit = $ppc->createIndependentCredit($instruction->getId(), 123);

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/TestBundle/Controller/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function paymentDetailsAction(Order $order)
'currency' => 'EUR',
'amount' => $order->getAmount(),
'predefined_data' => array(
'paypal_express_checkout' => array(
'test_plugin' => array(
'foo' => 'bar',
),
),
Expand Down
7 changes: 0 additions & 7 deletions Tests/Functional/TestBundle/Resources/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,3 @@ doctrine:

services:
em: "@doctrine.orm.entity_manager"

jms_payment_paypal:
username: schmit_1283340315_biz_api1.gmail.com
password: 1283340321
signature: A93vj6VJ.ZIRNjbI6GFgi4N2Km.5ATLs-EinlyWk2htEGX0xc3L8YIBo
return_url: http://paypal.test/payment
cancel_url: http://paypal.test/payment
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class TestPluginExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
17 changes: 17 additions & 0 deletions Tests/Functional/TestPlugin/Form/TestPluginType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class TestPluginType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
}
public function getName()
{
return 'test_plugin';
}
}
13 changes: 13 additions & 0 deletions Tests/Functional/TestPlugin/Plugin/TestPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\Plugin;

use JMS\Payment\CoreBundle\Plugin\AbstractPlugin;

class TestPlugin extends AbstractPlugin
{
public function processes($paymentSystemName)
{
return 'test_plugin' === $paymentSystemName;
}
}
11 changes: 11 additions & 0 deletions Tests/Functional/TestPlugin/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
test_plugin:
class: JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\Plugin\TestPlugin
tags:
- { name: payment.plugin }

test_plugin_type:
class: JMS\Payment\CoreBundle\Tests\Functional\TestPlugin\Form\TestPluginType
tags:
- { name: payment.method_form_type }
- { name: form.type, alias: test_plugin }
9 changes: 9 additions & 0 deletions Tests/Functional/TestPlugin/TestPluginBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace JMS\Payment\CoreBundle\Tests\Functional\TestPlugin;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class TestPluginBundle extends Bundle
{
}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"phpunit/phpunit": "~4.8|~5.4",
"symfony/phpunit-bridge": "~2.7",
"doctrine/doctrine-bundle": "~1.6",
"jms/payment-paypal-bundle": "~1.0",
"sensio/framework-extra-bundle": "~3.0",
"symfony/dom-crawler": "~2.3|~3.0",
"symfony/doctrine-bridge": "~2.3|~3.0",
Expand Down

0 comments on commit 6982285

Please sign in to comment.