forked from Payum/PayumBundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BuildGatewayFactoriesPassTest.php
54 lines (40 loc) · 1.95 KB
/
BuildGatewayFactoriesPassTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Payum\Bundle\PayumBundle\Tests\DependencyInjection\Compiler;
use Payum\Bundle\PayumBundle\DependencyInjection\Compiler\BuildConfigsPass;
use Payum\Bundle\PayumBundle\DependencyInjection\Compiler\BuildGatewayFactoriesPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
class BuildGatewayFactoriesPassTest extends \PHPUnit\Framework\TestCase
{
public function testShouldImplementCompilerPassInterface(): void
{
$rc = new \ReflectionClass(BuildConfigsPass::class);
$this->assertTrue($rc->implementsInterface(CompilerPassInterface::class));
}
public function testShouldAddServiceWithTagToStaticRegistry(): void
{
$service = new Definition();
$service->addTag('payum.gateway_factory', ['factory' => 'foo']);
$registry = new Definition(null, [null, null, null]);
$container = new ContainerBuilder();
$container->setDefinition('payum.static_registry', $registry);
$container->setDefinition('aservice', $service);
$pass = new BuildGatewayFactoriesPass();
$pass->process($container);
$this->assertEquals(['foo' => 'aservice'], $registry->getArgument(2));
}
public function testThrowIfTagMissFactoryAttribute(): void
{
$this->expectException(\Payum\Core\Exception\LogicException::class);
$this->expectExceptionMessage("The payum.gateway_factory tag require factory attribute.");
$service = new Definition();
$service->addTag('payum.gateway_factory');
$registry = new Definition(null, [null, null, null]);
$container = new ContainerBuilder();
$container->setDefinition('payum.static_registry', $registry);
$container->setDefinition('aservice', $service);
$pass = new BuildGatewayFactoriesPass();
$pass->process($container);
}
}