/** * @test * * @expectedException \Payum\Core\Exception\InvalidArgumentException * @expectedExceptionMessage The storage factory with such name theFoo already registered */ public function throwIfTryToAddStoragePaymentFactoryWithNameAlreadyAdded() { $factory = $this->getMock('Payum\Bundle\PayumBundle\DependencyInjection\Factory\Storage\StorageFactoryInterface'); $factory ->expects($this->atLeastOnce()) ->method('getName') ->will($this->returnValue('theFoo')) ; $extension = new PayumExtension; $extension->addStorageFactory($factory); $extension->addStorageFactory($factory); }
/** * @test */ public function shouldAddPaymentTagWithCorrectContextAndFactoryNamesSet() { $config = array('security' => array('token_storage' => array('Payum\\Core\\Model\\Token' => array('filesystem' => array('storage_dir' => sys_get_temp_dir(), 'id_property' => 'hash')))), 'contexts' => array('the_paypal_context' => array('paypal_express_checkout_nvp' => array('username' => 'a_username', 'password' => 'a_password', 'signature' => 'a_signature', 'sandbox' => true)))); $configs = array($config); $containerBuilder = new ContainerBuilder(new ParameterBag()); $extension = new PayumExtension(); $extension->addPaymentFactory(new PaypalExpressCheckoutNvpPaymentFactory()); $extension->addStorageFactory(new FilesystemStorageFactory()); $extension->load($configs, $containerBuilder); $paymentDefinition = $containerBuilder->getDefinition('payum.context.the_paypal_context.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('context', $attributes); $this->assertEquals('the_paypal_context', $attributes['context']); }
/** * @test */ public function shouldNotConfigureSonataAdminClassForPaymentConfigIfDisabled() { $config = array( 'dynamic_payments' => array( 'sonata_admin' => false, 'config_storage' => array( 'Payum\Bundle\PayumBundle\Tests\Functional\DependencyInjection\TestPaymentConfig' => array( 'filesystem' => array( 'storage_dir' => sys_get_temp_dir(), 'id_property' => 'hash' ) ) ) ), 'security' => array( 'token_storage' => array( 'Payum\Core\Model\Token' => array( 'filesystem' => array( 'storage_dir' => sys_get_temp_dir(), 'id_property' => 'hash' ) ) ) ), 'payments' => array(), ); $configs = array($config); $containerBuilder = new ContainerBuilder(); $containerBuilder->setParameter('kernel.debug', false); $extension = new PayumExtension; $extension->addStorageFactory(new FilesystemStorageFactory); $extension->load($configs, $containerBuilder); $this->assertFalse($containerBuilder->hasDefinition('payum.dynamic_payments.payment_config_admin')); }
/** * @test */ public function shouldAddGatewaysToBuilder() { $extension = new PayumExtension(); $extension->addStorageFactory(new FeeStorageFactory()); $container = new ContainerBuilder(); $container->setParameter('kernel.debug', true); $container->setParameter('kernel.bundles', []); $extension->load([['security' => array('token_storage' => array('Payum\\Core\\Model\\Token' => array('bar_storage' => ['bar_opt' => 'val']))), 'gateways_v2' => array('a_gateway' => array('foo' => 'fooVal'), 'another_gateway' => array('bar' => 'barVal'))]], $container); $this->assertTrue($container->hasDefinition('payum.builder')); $builder = $container->getDefinition('payum.builder'); $calls = $builder->getMethodCalls(); $this->assertEquals('addGateway', $calls[7][0]); $this->assertEquals('a_gateway', $calls[7][1][0]); $this->assertEquals(['foo' => 'fooVal'], $calls[7][1][1]); $this->assertEquals('addGateway', $calls[8][0]); $this->assertEquals('another_gateway', $calls[8][1][0]); $this->assertEquals(['bar' => 'barVal'], $calls[8][1][1]); }