-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathConsoleCommandPassTest.php
More file actions
57 lines (47 loc) · 1.87 KB
/
Copy pathConsoleCommandPassTest.php
File metadata and controls
57 lines (47 loc) · 1.87 KB
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
55
56
57
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\Tests\Bundle\Core\DependencyInjection\Compiler;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ConsoleCommandPass;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
final class ConsoleCommandPassTest extends AbstractCompilerPassTestCase
{
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new ConsoleCommandPass());
}
public function testAddSiteaccessOption(): void
{
$commandDefinition = new Definition(Command::class);
$serviceId = 'some_service_id';
$commandDefinition->addTag('console.command');
$this->setDefinition($serviceId, $commandDefinition);
$this->compile();
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
$serviceId,
'addOption',
[
'siteaccess',
null,
InputOption::VALUE_OPTIONAL,
'SiteAccess to use for operations. If not provided, default siteaccess will be used',
]
);
}
public function testSkipsSiteaccessOptionOnInvokables(): void
{
$commandDefinition = new Definition();
$serviceId = 'some_service_id';
$commandDefinition->addTag('console.command');
$this->setDefinition($serviceId, $commandDefinition);
$this->compile();
$this->assertContainerBuilderHasService($serviceId);
}
}