]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Import; | |
4 | ||
5 | use PHPUnit\Framework\TestCase; | |
6 | use Symfony\Component\DependencyInjection\ContainerBuilder; | |
7 | use Wallabag\ImportBundle\Import\ImportCompilerPass; | |
8 | ||
9 | class ImportCompilerPassTest extends TestCase | |
10 | { | |
11 | public function testProcessNoDefinition() | |
12 | { | |
13 | $container = new ContainerBuilder(); | |
14 | $res = $this->process($container); | |
15 | ||
16 | $this->assertNull($res); | |
17 | } | |
18 | ||
19 | public function testProcess() | |
20 | { | |
21 | $container = new ContainerBuilder(); | |
22 | $container | |
23 | ->register('wallabag_import.chain') | |
24 | ->setPublic(false) | |
25 | ; | |
26 | ||
27 | $container | |
28 | ->register('foo') | |
29 | ->addTag('wallabag_import.import', ['alias' => 'pocket']) | |
30 | ; | |
31 | ||
32 | $this->process($container); | |
33 | ||
34 | $this->assertTrue($container->hasDefinition('wallabag_import.chain')); | |
35 | ||
36 | $definition = $container->getDefinition('wallabag_import.chain'); | |
37 | $this->assertTrue($definition->hasMethodCall('addImport')); | |
38 | ||
39 | $calls = $definition->getMethodCalls(); | |
40 | $this->assertSame('pocket', $calls[0][1][1]); | |
41 | } | |
42 | ||
43 | protected function process(ContainerBuilder $container) | |
44 | { | |
45 | $repeatedPass = new ImportCompilerPass(); | |
46 | $repeatedPass->process($container); | |
47 | } | |
48 | } |