/**
  * @test
  */
 public function shouldAddGatewayTagWithCorrectGatewayAndFactoryNamesSet()
 {
     $config = array('security' => array('token_storage' => array('Payum\\Core\\Model\\Token' => array('filesystem' => array('storage_dir' => sys_get_temp_dir(), 'id_property' => 'hash')))), 'gateways' => array('the_paypal_gateway' => 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->addGatewayFactory(new PaypalExpressCheckoutNvpGatewayFactory());
     $extension->addStorageFactory(new FilesystemStorageFactory());
     $extension->load($configs, $containerBuilder);
     $gatewayDefinition = $containerBuilder->getDefinition('payum.paypal_express_checkout_nvp.the_paypal_gateway.gateway');
     $tagAttributes = $gatewayDefinition->getTag('payum.gateway');
     $this->assertCount(1, $tagAttributes);
     $attributes = $tagAttributes[0];
     $this->assertArrayHasKey('factory', $attributes);
     $this->assertEquals('paypal_express_checkout_nvp', $attributes['factory']);
     $this->assertArrayHasKey('gateway', $attributes);
     $this->assertEquals('the_paypal_gateway', $attributes['gateway']);
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function shouldPassContainerToGatewayFactoryPrependMethodIfImplementsPrependFactoryInterface()
 {
     $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->addGatewayFactory($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']);
 }