|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dtc\QueueBundle\Tests\DependencyInjection\Compiler; |
|
4
|
|
|
|
|
5
|
|
|
use Dtc\QueueBundle\Beanstalkd\JobManager; |
|
6
|
|
|
use Dtc\QueueBundle\DependencyInjection\Compiler\BeanstalkdCompilerPass; |
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
10
|
|
|
|
|
11
|
|
|
class BeanstalkdCompilerPassTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
public function testProcess() |
|
14
|
|
|
{ |
|
15
|
|
|
$container = new ContainerBuilder(); |
|
16
|
|
|
|
|
17
|
|
|
$count = count($container->getDefinitions()); |
|
18
|
|
|
$compilerPass = new BeanstalkdCompilerPass(); |
|
19
|
|
|
$compilerPass->process($container); |
|
20
|
|
|
self::assertEquals($count, count($container->getDefinitions())); |
|
21
|
|
|
|
|
22
|
|
|
$container = new ContainerBuilder(); |
|
23
|
|
|
$count = count($container->getDefinitions()); |
|
24
|
|
|
$definition = new Definition(); |
|
25
|
|
|
$definition->setClass(JobManager::class); |
|
26
|
|
|
$container->addDefinitions(['dtc_queue.job_manager.beanstalkd' => $definition]); |
|
27
|
|
|
$container->setParameter('dtc_queue.beanstalkd.host', 'somehost'); |
|
28
|
|
|
$compilerPass = new BeanstalkdCompilerPass(); |
|
29
|
|
|
$compilerPass->process($container); |
|
30
|
|
|
|
|
31
|
|
|
self::assertGreaterThan($count, count($container->getDefinitions())); |
|
32
|
|
|
self::assertTrue($container->hasDefinition('dtc_queue.beanstalkd')); |
|
33
|
|
|
|
|
34
|
|
|
$definition = $container->getDefinition('dtc_queue.job_manager.beanstalkd'); |
|
35
|
|
|
self::assertNotEmpty($definition->getMethodCalls()); |
|
36
|
|
|
self::assertCount(1, $definition->getMethodCalls()); |
|
37
|
|
|
|
|
38
|
|
|
$container = new ContainerBuilder(); |
|
39
|
|
|
$definition = new Definition(); |
|
40
|
|
|
$definition->setClass(JobManager::class); |
|
41
|
|
|
$container->addDefinitions(['dtc_queue.job_manager.beanstalkd' => $definition]); |
|
42
|
|
|
$container->setParameter('dtc_queue.beanstalkd.host', 'somehost'); |
|
43
|
|
|
$container->setParameter('dtc_queue.beanstalkd.tube', 'seomthing'); |
|
44
|
|
|
$compilerPass = new BeanstalkdCompilerPass(); |
|
45
|
|
|
$compilerPass->process($container); |
|
46
|
|
|
|
|
47
|
|
|
self::assertNotEmpty($container->getDefinitions()); |
|
48
|
|
|
self::assertTrue($container->hasDefinition('dtc_queue.beanstalkd')); |
|
49
|
|
|
|
|
50
|
|
|
$definition = $container->getDefinition('dtc_queue.job_manager.beanstalkd'); |
|
51
|
|
|
self::assertNotEmpty($definition->getMethodCalls()); |
|
52
|
|
|
self::assertCount(2, $definition->getMethodCalls()); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|