Exemplo n.º 1
0
    /**
     * @test
     */
    public function shouldAddPaymentTagWithCorrectPaymentAndFactoryNamesSet()
    {
        $config = array(
            'security' => array(
                'token_storage' => array(
                    'Payum\Core\Model\Token' => array(
                        'filesystem' => array(
                            'storage_dir' => sys_get_temp_dir(),
                            'id_property' => 'hash'
                        )
                    )
                )
            ),
            'payments' => array(
                'the_paypal_payment' => array(
                    'paypal_express_checkout_nvp' => array(
                        'username' => 'a_username',
                        'password' => 'a_password',
                        'signature' => 'a_signature',
                        'sandbox' => true
                    ),
                )
            )
        );

        $configs = array($config);

        $containerBuilder = new ContainerBuilder();
        $containerBuilder->setParameter('kernel.debug', false);

        $extension = new PayumExtension;
        $extension->addPaymentFactory(new PaypalExpressCheckoutNvpPaymentFactory);
        $extension->addStorageFactory(new FilesystemStorageFactory);

        $extension->load($configs, $containerBuilder);

        $paymentDefinition = $containerBuilder->getDefinition('payum.paypal_express_checkout_nvp.the_paypal_payment.payment');

        $tagAttributes = $paymentDefinition->getTag('payum.payment');

        $this->assertCount(1, $tagAttributes);

        $attributes = $tagAttributes[0];

        $this->assertArrayHasKey('factory', $attributes);
        $this->assertEquals('paypal_express_checkout_nvp', $attributes['factory']);

        $this->assertArrayHasKey('payment', $attributes);
        $this->assertEquals('the_paypal_payment', $attributes['payment']);
    }
Exemplo n.º 2
0
    /**
     * @test
     */
    public function shouldPassContainerToPaymentFactoryPrependMethodIfImplementsPrependFactoryInterface()
    {
        $container = new ContainerBuilder;
        $container->setParameter('kernel.bundles', array('TwigBundle' => 'TwigBundle'));

        $factoryMock = $this->getMock('Payum\Bundle\PayumBundle\Tests\DependencyInjection\FactoryPlusPrependExtension');
        $factoryMock
            ->expects($this->any())
            ->method('getName')
            ->will($this->returnValue('aFactory'))
        ;
        $factoryMock
            ->expects($this->any())
            ->method('prepend')
            ->with($this->identicalTo($container))
            ->will($this->returnCallback(function(ContainerBuilder $container) {
                $container->prependExtensionConfig('twig', array('foo' => 'fooVal'));
                $container->prependExtensionConfig('twig', array('bar' => 'barVal'));
            }))
        ;

        //guard
        $this->assertInstanceOf('Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface', $factoryMock);

        $extension = new PayumExtension;
        $extension->addPaymentFactory($factoryMock);


        $extension->prepend($container);

        $twigConfig = $container->getExtensionConfig('twig');

        $this->assertContains('barVal', $twigConfig[0]['bar']);
        $this->assertContains('fooVal', $twigConfig[1]['foo']);
        $this->assertContains('PayumCore', $twigConfig[2]['paths']);
        $this->assertContains('PayumSymfonyBridge', $twigConfig[2]['paths']);
    }
 /**
  * @test
  */
 public function shouldPassContainerToPaymentFactoryPrependMethodIfImplementsPrependFactoryInterface()
 {
     $this->markTestSkipped('The logic was disabled because of the bug. See https://github.com/symfony/symfony/pull/9719');
     $container = new ContainerBuilder();
     $factoryMock = $this->getMock('Payum\\Bundle\\PayumBundle\\Tests\\DependencyInjection\\FactoryPlusPrependExtension');
     $factoryMock->expects($this->any())->method('getName')->will($this->returnValue('aFactory'));
     $factoryMock->expects($this->any())->method('prepend')->with($this->identicalTo($container))->will($this->returnCallback(function (ContainerBuilder $container) {
         $container->prependExtensionConfig('twig', array('foo' => 'fooVal'));
         $container->prependExtensionConfig('twig', array('bar' => 'barVal'));
     }));
     //guard
     $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Extension\\PrependExtensionInterface', $factoryMock);
     $extension = new PayumExtension();
     $extension->addPaymentFactory($factoryMock);
     $extension->prepend($container);
     $this->assertEquals(array(array('bar' => 'barVal'), array('foo' => 'fooVal')), $container->getExtensionConfig('twig'));
 }