|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dtc\QueueBundle\Tests\DependencyInjection\Compiler; |
|
4
|
|
|
|
|
5
|
|
|
use Dtc\QueueBundle\DependencyInjection\Compiler\WorkerCompilerPass; |
|
6
|
|
|
use Dtc\QueueBundle\EventDispatcher\EventDispatcher; |
|
7
|
|
|
use Dtc\QueueBundle\Model\WorkerManager; |
|
8
|
|
|
use Dtc\QueueBundle\ODM\JobManager; |
|
9
|
|
|
use Dtc\QueueBundle\ODM\RunManager; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
13
|
|
|
|
|
14
|
|
|
class WorkerCompilerPassTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
public function testProcess() |
|
17
|
|
|
{ |
|
18
|
|
|
$container = new ContainerBuilder(); |
|
19
|
|
|
|
|
20
|
|
|
$count = count($container->getDefinitions()); |
|
21
|
|
|
$compilerPass = new WorkerCompilerPass(); |
|
22
|
|
|
$compilerPass->process($container); |
|
23
|
|
|
self::assertEquals($count, count($container->getDefinitions())); |
|
24
|
|
|
|
|
25
|
|
|
$container = new ContainerBuilder(); |
|
26
|
|
|
$definition1 = new Definition(); |
|
27
|
|
|
$definition1->setClass(WorkerManager::class); |
|
28
|
|
|
$container->setParameter('dtc_queue.default_manager', 'odm'); |
|
29
|
|
|
$container->setParameter('dtc_queue.run_manager', 'odm'); |
|
30
|
|
|
$container->setParameter('dtc_queue.class_job', null); |
|
31
|
|
|
$container->setParameter('dtc_queue.class_job_archive', null); |
|
32
|
|
|
$container->setParameter('dtc_queue.document_manager', 'default'); |
|
33
|
|
|
$container->setParameter('dtc_queue.entity_manager', 'default'); |
|
34
|
|
|
$definition2 = new Definition(); |
|
35
|
|
|
$definition2->setClass(JobManager::class); |
|
36
|
|
|
$definition3 = new Definition(); |
|
37
|
|
|
$definition3->setClass(RunManager::class); |
|
38
|
|
|
$definition4 = new Definition(); |
|
39
|
|
|
$definition4->setClass(EventDispatcher::class); |
|
40
|
|
|
$container->addDefinitions([ |
|
41
|
|
|
'dtc_queue.worker_manager' => $definition1, |
|
42
|
|
|
'dtc_queue.job_manager.odm' => $definition2, |
|
43
|
|
|
'dtc_queue.run_manager.odm' => $definition3, |
|
44
|
|
|
'dtc_queue.event_dispatcher' => $definition4, |
|
45
|
|
|
]); |
|
46
|
|
|
|
|
47
|
|
|
$count = count($container->getAliases()); |
|
48
|
|
|
$compilerPass = new WorkerCompilerPass(); |
|
49
|
|
|
$compilerPass->process($container); |
|
50
|
|
|
|
|
51
|
|
|
self::assertNotEquals($count, count($container->getAliases())); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|