Skip to content

Commit 414fa2d

Browse files
authored
Merge pull request #77 from amayer5125/queue-work-command
Namespace Worker Command
2 parents 7fe687e + 127fd8d commit 414fa2d

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

docs/en/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ options this array holds are the same options as those available for
228228
Run the worker
229229
==============
230230

231-
Once a message is queued, you may run a worker via the included ``worker`` shell:
231+
Once a message is queued, you may run a worker via the included ``queue worker`` shell:
232232

233233
.. code-block:: bash
234234
235-
bin/cake worker
235+
bin/cake queue worker
236236
237237
This shell can take a few different options:
238238

src/Command/WorkerCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
*/
3434
class WorkerCommand extends Command
3535
{
36+
/**
37+
* Get the command name.
38+
*
39+
* @return string
40+
*/
41+
public static function defaultName(): string
42+
{
43+
return 'queue worker';
44+
}
45+
3646
/**
3747
* Gets the option parser instance and configures it.
3848
*

src/Plugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public function bootstrap(PluginApplicationInterface $app): void
6464
*/
6565
public function console(CommandCollection $commands): CommandCollection
6666
{
67-
return $commands->add('worker', WorkerCommand::class);
67+
return $commands
68+
->add('queue worker', WorkerCommand::class)
69+
->add('worker', WorkerCommand::class);
6870
}
6971
}

tests/TestCase/Command/WorkerCommandTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setUp(): void
4444
*/
4545
public function testDescriptionOutput()
4646
{
47-
$this->exec('worker --help');
47+
$this->exec('queue worker --help');
4848
$this->assertOutputContains('Runs a queue worker');
4949
}
5050

@@ -62,7 +62,7 @@ public function testQueueProcessesStart()
6262
],
6363
],
6464
]);
65-
$this->exec('worker --max-runtime=1');
65+
$this->exec('queue worker --max-runtime=1');
6666
$this->assertEmpty($this->getActualOutput());
6767
}
6868

@@ -81,7 +81,7 @@ public function testQueueProcessesWithListener()
8181
],
8282
],
8383
]);
84-
$this->exec('worker --max-runtime=1');
84+
$this->exec('queue worker --max-runtime=1');
8585
$this->assertEmpty($this->getActualOutput());
8686
}
8787

@@ -101,7 +101,7 @@ public function testQueueWillAbortWithMissingConfig()
101101
],
102102
]);
103103

104-
$this->exec('worker --config=invalid_config --max-runtime=1');
104+
$this->exec('queue worker --config=invalid_config --max-runtime=1');
105105
$this->assertErrorContains('Configuration key "invalid_config" was not found');
106106
}
107107

@@ -121,7 +121,7 @@ public function testQueueProcessesWithInvalidListener()
121121
],
122122
]);
123123

124-
$this->exec('worker --max-runtime=1');
124+
$this->exec('queue worker --max-runtime=1');
125125
$this->assertErrorContains('Listener class InvalidListener not found');
126126
}
127127

@@ -145,7 +145,7 @@ public function testQueueProcessesWithLogger()
145145
'levels' => ['notice', 'info', 'debug'],
146146
]);
147147

148-
$this->exec('worker --max-runtime=1 --logger=debug --verbose');
148+
$this->exec('queue worker --max-runtime=1 --logger=debug --verbose');
149149
$this->assertDebugLogContains('Max Iterations: 0');
150150
}
151151

@@ -177,7 +177,7 @@ public function testQueueProcessesJob()
177177
QueueManager::push($callable, $arguments, $options);
178178
QueueManager::drop('default');
179179

180-
$this->exec('worker --max-runtime=3 --logger=debug --verbose');
180+
$this->exec('queue worker --max-runtime=3 --logger=debug --verbose');
181181

182182
$this->assertDebugLogContains('Welcome mail sent');
183183
}
@@ -209,7 +209,7 @@ public function testQueueProcessesJobWithProcessor()
209209
QueueManager::push($callable, $arguments, $options);
210210
QueueManager::drop('default');
211211

212-
$this->exec('worker --max-runtime=3 --processor=processor-name --logger=debug --verbose');
212+
$this->exec('queue worker --max-runtime=3 --processor=processor-name --logger=debug --verbose');
213213

214214
$this->assertDebugLogContains('Welcome mail sent');
215215
}
@@ -242,7 +242,7 @@ public function testQueueProcessesJobWithOtherQueue()
242242
QueueManager::push($callable, $arguments, $options);
243243
QueueManager::drop('other');
244244

245-
$this->exec('worker --config=other --max-runtime=3 --processor=processor-name --logger=debug --verbose');
245+
$this->exec('queue worker --config=other --max-runtime=3 --processor=processor-name --logger=debug --verbose');
246246

247247
$this->assertDebugLogContains('Welcome mail sent');
248248
}

0 commit comments

Comments
 (0)