Skip to content

Commit 1536a35

Browse files
authored
Merge pull request #9 from driftphp/feature/update-command-name
Fixed debug command name
2 parents c1ba5a5 + 78b7eab commit 1536a35

File tree

4 files changed

+105
-13
lines changed

4 files changed

+105
-13
lines changed

Console/CommandConsumer.php renamed to Console/CommandConsumerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
* Class CommandConsumer.
2929
*/
30-
class CommandConsumer extends Command
30+
class CommandConsumerCommand extends Command
3131
{
3232
/**
3333
* @var AsyncAdapter

Console/BusDebugger.php renamed to Console/DebugCommandBusCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
use Symfony\Component\Console\Output\OutputInterface;
2626

2727
/**
28-
* Class BusDebugger.
28+
* Class DebugCommandBusCommand.
2929
*/
30-
class BusDebugger extends Command
30+
class DebugCommandBusCommand extends Command
3131
{
32+
protected static $defaultName = 'debug:command-bus';
3233
/**
3334
* @var CommandBus
3435
*/

DependencyInjection/CompilerPass/BusCompilerPass.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
use Drift\CommandBus\Bus\CommandBus;
2323
use Drift\CommandBus\Bus\InlineCommandBus;
2424
use Drift\CommandBus\Bus\QueryBus;
25-
use Drift\CommandBus\Console\BusDebugger;
26-
use Drift\CommandBus\Console\CommandConsumer;
25+
use Drift\CommandBus\Console\CommandConsumerCommand;
26+
use Drift\CommandBus\Console\DebugCommandBusCommand;
2727
use Drift\CommandBus\Exception\InvalidMiddlewareException;
2828
use Drift\CommandBus\Middleware\AsyncMiddleware;
2929
use Drift\CommandBus\Middleware\HandlerMiddleware;
@@ -178,7 +178,9 @@ private function createQueryBus(ContainerBuilder $container)
178178
false
179179
),
180180
]
181-
))->addTag('preload')
181+
))
182+
->addTag('preload')
183+
->setLazy(true)
182184
);
183185

184186
$container->setAlias(QueryBus::class, 'drift.query_bus');
@@ -202,7 +204,9 @@ private function createCommandBus(
202204
$asyncBus
203205
),
204206
]
205-
))->addTag('preload')
207+
))
208+
->addTag('preload')
209+
->setLazy(true)
206210
);
207211

208212
$container->setAlias(CommandBus::class, 'drift.command_bus');
@@ -223,7 +227,9 @@ private function createInlineCommandBus(ContainerBuilder $container)
223227
false
224228
),
225229
]
226-
))->addTag('preload')
230+
))
231+
->addTag('preload')
232+
->setLazy(true)
227233
);
228234

229235
$container->setAlias(InlineCommandBus::class, 'drift.inline_command_bus');
@@ -339,7 +345,7 @@ private function createHandlersMap(
339345
*/
340346
private function createCommandConsumer(ContainerBuilder $container)
341347
{
342-
$consumer = new Definition(CommandConsumer::class, [
348+
$consumer = new Definition(CommandConsumerCommand::class, [
343349
new Reference(AsyncAdapter::class),
344350
new Reference('drift.inline_command_bus'),
345351
new Reference('reactphp.event_loop'),
@@ -349,7 +355,7 @@ private function createCommandConsumer(ContainerBuilder $container)
349355
'command' => 'bus:consume-commands',
350356
]);
351357

352-
$container->setDefinition(CommandConsumer::class, $consumer);
358+
$container->setDefinition(CommandConsumerCommand::class, $consumer);
353359
}
354360

355361
/**
@@ -359,17 +365,17 @@ private function createCommandConsumer(ContainerBuilder $container)
359365
*/
360366
private function createBusDebugger(ContainerBuilder $container)
361367
{
362-
$consumer = new Definition(BusDebugger::class, [
368+
$consumer = new Definition(DebugCommandBusCommand::class, [
363369
new Reference('drift.command_bus'),
364370
new Reference('drift.inline_command_bus'),
365371
new Reference('drift.query_bus'),
366372
]);
367373

368374
$consumer->addTag('console.command', [
369-
'command' => 'debug:bus',
375+
'command' => 'debug:command-bus',
370376
]);
371377

372-
$container->setDefinition(BusDebugger::class, $consumer);
378+
$container->setDefinition(DebugCommandBusCommand::class, $consumer);
373379
}
374380

375381
/**

Tests/Console/CommandsListTest.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the DriftPHP Project
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Feel free to edit as you please, and have fun.
10+
*
11+
* @author Marc Morera <[email protected]>
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace Drift\CommandBus\Tests\Console;
17+
18+
use Drift\AMQP\AMQPBundle;
19+
use Drift\CommandBus\Tests\BusFunctionalTest;
20+
21+
/**
22+
* Class CommandsListTest.
23+
*/
24+
class CommandsListTest extends BusFunctionalTest
25+
{
26+
/**
27+
* Decorate bundles.
28+
*
29+
* @param array $bundles
30+
*
31+
* @return array
32+
*/
33+
protected static function decorateBundles(array $bundles): array
34+
{
35+
$bundles[] = AMQPBundle::class;
36+
37+
return $bundles;
38+
}
39+
40+
/**
41+
* Decorate configuration.
42+
*
43+
* @param array $configuration
44+
*
45+
* @return array
46+
*/
47+
protected static function decorateConfiguration(array $configuration): array
48+
{
49+
$configuration = parent::decorateConfiguration($configuration);
50+
51+
$configuration['amqp'] = [
52+
'clients' => [
53+
'amqp_1' => [
54+
'host' => '127.0.0.99',
55+
],
56+
],
57+
];
58+
59+
$configuration['command_bus'] = [
60+
'command_bus' => [
61+
'async_adapter' => [
62+
'amqp' => [
63+
'client' => 'amqp_1',
64+
'queue' => 'commands',
65+
],
66+
],
67+
],
68+
];
69+
70+
return $configuration;
71+
}
72+
73+
/**
74+
* Test that simple commands list works as expected.
75+
*/
76+
public function testCommandsList()
77+
{
78+
$output = $this->runCommand([
79+
'',
80+
]);
81+
82+
$this->assertContains('debug:command-bus', $output);
83+
$this->assertContains('bus:consume-commands', $output);
84+
}
85+
}

0 commit comments

Comments
 (0)