Exemplo n.º 1
0
 /**
  * @test
  *
  * @dataProvider provideGateways
  */
 public function shouldLoadExtensionWithGateway($config, GatewayFactoryInterface $gatewayFactory)
 {
     $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('a_gateway' => array($gatewayFactory->getName() => $config)));
     $configs = array($config);
     $container = new ContainerBuilder();
     $container->setParameter('kernel.debug', false);
     $extension = new PayumExtension();
     $extension->addGatewayFactory($gatewayFactory);
     $extension->addStorageFactory(new FilesystemStorageFactory());
     $extension->load($configs, $container);
     $this->assertTrue($container->hasDefinition('payum.' . $gatewayFactory->getName() . '.factory'));
     $this->assertTrue($container->hasDefinition('payum.' . $gatewayFactory->getName() . '.a_gateway.gateway'));
     $this->assertEquals('payum.' . $gatewayFactory->getName() . '.factory', $container->getDefinition('payum.' . $gatewayFactory->getName() . '.a_gateway.gateway')->getFactoryService());
     $this->assertEquals('create', $container->getDefinition('payum.' . $gatewayFactory->getName() . '.a_gateway.gateway')->getFactoryMethod());
 }
 /**
  * @test
  *
  * @dataProvider provideGateways
  */
 public function shouldLoadExtensionWithGateway($config, GatewayFactoryInterface $gatewayFactory)
 {
     $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('a_gateway' => array($gatewayFactory->getName() => $config)));
     $configs = array($config);
     $container = new ContainerBuilder();
     $container->setParameter('kernel.debug', false);
     $extension = new PayumExtension();
     $extension->addGatewayFactory($gatewayFactory);
     $extension->addStorageFactory(new FilesystemStorageFactory());
     $extension->load($configs, $container);
     $this->assertTrue($container->hasDefinition('payum.' . $gatewayFactory->getName() . '.factory'));
     $this->assertTrue($container->hasDefinition('payum.' . $gatewayFactory->getName() . '.a_gateway.gateway'));
     $factory = $container->getDefinition('payum.' . $gatewayFactory->getName() . '.a_gateway.gateway')->getFactory();
     $this->assertNotEmpty($factory);
     $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $factory[0]);
     $this->assertEquals('payum.' . $gatewayFactory->getName() . '.factory', (string) $factory[0]);
     $this->assertEquals('create', $factory[1]);
 }
Exemplo n.º 3
0
 /**
  * @param GatewayFactoryInterface $factory
  *
  * @throws \Payum\Core\Exception\InvalidArgumentException
  */
 public function addGatewayFactory(GatewayFactoryInterface $factory)
 {
     $factoryName = $factory->getName();
     if (empty($factoryName)) {
         throw new InvalidArgumentException(sprintf('The gateway factory %s has empty name', get_class($factory)));
     }
     if (isset($this->gatewaysFactories[$factoryName])) {
         throw new InvalidArgumentException(sprintf('The gateway factory with such name %s already registered', $factoryName));
     }
     $this->gatewaysFactories[$factory->getName()] = $factory;
 }