2015-12-31 10:24:46 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-19 00:30:12 +00:00
|
|
|
namespace Tests\Wallabag\Import;
|
2015-12-31 10:24:46 +00:00
|
|
|
|
2017-12-16 21:17:42 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2015-12-31 10:24:46 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
2024-02-19 00:30:12 +00:00
|
|
|
use Wallabag\Import\ImportChain;
|
|
|
|
use Wallabag\Import\ImportCompilerPass;
|
2015-12-31 10:24:46 +00:00
|
|
|
|
2017-12-16 21:17:42 +00:00
|
|
|
class ImportCompilerPassTest extends TestCase
|
2015-12-31 10:24:46 +00:00
|
|
|
{
|
|
|
|
public function testProcessNoDefinition()
|
|
|
|
{
|
|
|
|
$container = new ContainerBuilder();
|
|
|
|
$res = $this->process($container);
|
|
|
|
|
|
|
|
$this->assertNull($res);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testProcess()
|
|
|
|
{
|
|
|
|
$container = new ContainerBuilder();
|
|
|
|
$container
|
2022-04-24 15:24:24 +00:00
|
|
|
->register(ImportChain::class)
|
2015-12-31 10:24:46 +00:00
|
|
|
->setPublic(false)
|
|
|
|
;
|
|
|
|
|
|
|
|
$container
|
|
|
|
->register('foo')
|
2024-02-19 23:47:53 +00:00
|
|
|
->addTag('wallabag.import', ['alias' => 'pocket'])
|
2015-12-31 10:24:46 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
$this->process($container);
|
|
|
|
|
2022-04-24 15:24:24 +00:00
|
|
|
$this->assertTrue($container->hasDefinition(ImportChain::class));
|
2015-12-31 10:24:46 +00:00
|
|
|
|
2022-04-24 15:24:24 +00:00
|
|
|
$definition = $container->getDefinition(ImportChain::class);
|
2015-12-31 10:24:46 +00:00
|
|
|
$this->assertTrue($definition->hasMethodCall('addImport'));
|
|
|
|
|
|
|
|
$calls = $definition->getMethodCalls();
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame('pocket', $calls[0][1][1]);
|
2015-12-31 10:24:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function process(ContainerBuilder $container)
|
|
|
|
{
|
|
|
|
$repeatedPass = new ImportCompilerPass();
|
|
|
|
$repeatedPass->process($container);
|
|
|
|
}
|
|
|
|
}
|