1
1
<?php
2
2
namespace bazilio \async \tests \unit ;
3
3
4
+ use bazilio \async \commands \AsyncWorkerCommand ;
4
5
use bazilio \async \Exception ;
5
6
use bazilio \async \models \AsyncExecuteTask ;
6
7
use bazilio \async \models \AsyncTask ;
8
+ use yii \base \Module ;
7
9
8
10
class TestTask extends AsyncTask
9
11
{
@@ -218,4 +220,32 @@ public function testSubscribe()
218
220
219
221
$ this ->assertNotFalse (\Yii::$ app ->async ->receiveTask ($ task ::$ queueName , true ));
220
222
}
221
- }
223
+
224
+ public function testConsoleCommandDaemon () {
225
+ if (get_called_class () == 'bazilio\async\tests\unit\AmqpTest ' ) {
226
+ $ this ->markTestSkipped ('No support for AMQP yet ' );
227
+ return ;
228
+ }
229
+
230
+ $ task = new TestTask ();
231
+ \Yii::$ app ->async ->sendTask ($ task );
232
+
233
+ $ controller = new AsyncWorkerCommand ('id ' , new Module ('id ' ));
234
+
235
+ $ this ->setExpectedException ('yii\db\Exception ' );
236
+ $ controller ->actionDaemon ($ task ::$ queueName );
237
+
238
+ $ this ->assertFalse ($ this ->async ->receiveTask ($ task ::$ queueName ));
239
+ }
240
+
241
+ public function testConsoleCommandExecute () {
242
+ $ task = new TestTask ();
243
+ \Yii::$ app ->async ->sendTask ($ task );
244
+
245
+ $ controller = new AsyncWorkerCommand ('id ' , new Module ('id ' ));
246
+
247
+ $ controller ->actionExecute ($ task ::$ queueName );
248
+
249
+ $ this ->assertFalse ($ this ->async ->receiveTask ($ task ::$ queueName ));
250
+ }
251
+ }
0 commit comments