Skip to content

Commit 3890337

Browse files
committed
Add testing for messaging
1 parent bdf92ff commit 3890337

6 files changed

Lines changed: 260 additions & 99 deletions

File tree

src/Console/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Command extends AbstractCommand
5757
"add:validation" => GenerateValidationCommand::class,
5858
"add:event" => GenerateAppEventCommand::class,
5959
"add:listener" => GenerateEventListenerCommand::class,
60-
"add:producer" => GenerateJobCommand::class,
60+
"add:job" => GenerateJobCommand::class,
6161
"add:command" => GenerateConsoleCommand::class,
6262
"add:message" => GenerateMessagingCommand::class,
6363
"run:console" => ReplCommand::class,

src/Console/Console.php

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -72,40 +72,46 @@ class Console
7272
* @var array
7373
*/
7474
private static array $registers = [];
75+
7576
/**
7677
* The console instance
7778
*
7879
* @var ?Console
7980
*/
8081
private static ?Console $instance = null;
82+
8183
/**
8284
* The Setting instance
8385
*
8486
* @var Setting
8587
*/
8688
private Setting $setting;
89+
8790
/**
88-
* The COMMAND instance
91+
* The Command instance
8992
*
9093
* @var Command
9194
*/
9295
private Command $command;
96+
9397
/**
9498
* The Loader instance
9599
*
96100
* @var Loader
97101
*/
98102
private Loader $kernel;
103+
99104
/**
100-
* Defines if console booted
105+
* Define if console booted
101106
*
102107
* @var bool
103108
*/
104109
private bool $booted = false;
110+
105111
/**
106112
* The Argument instance
107113
*
108-
* @return Argument
114+
* @var Argument
109115
*/
110116
private Argument $arg;
111117

@@ -487,7 +493,7 @@ private function flush(): void
487493
private function getVersion(): void
488494
{
489495
$version = <<<USAGE
490-
Console running for BowPHP: \033[0;32m%s\033[00m - PHP Version: \033[0;32m%s\033[0;33m
496+
Console running for Bow Framework: \033[0;32m%s\033[00m - PHP Version: \033[0;32m%s\033[0;33m
491497
492498
USAGE;
493499
echo sprintf($version, Console::VERSION, PHP_VERSION);
@@ -511,16 +517,16 @@ private function help(?string $command = null): int
511517
512518
\033[0;32mCOMMAND\033[00m:
513519
514-
\033[0;33mhelp\033[00m display command helper
520+
\033[0;33mhelp\033[00m Display command helper
515521
516-
\033[0;32mGENERATE\033[00m create a new app key and resources
522+
\033[0;32mGENERATE\033[00m Create new app key and resources
517523
\033[0;33mgenerate:resource\033[00m Create new REST controller
518-
\033[0;33mgenerate:session-table\033[00m For generate the preset table for session
519-
\033[0;33mgenerate:cache-table\033[00m For generate the preset table for cache
520-
\033[0;33mgenerate:queue-table\033[00m For generate the preset table for queue
521-
\033[0;33mgenerate:notification-table\033[00m For generate the preset table for notification
524+
\033[0;33mgenerate:session-table\033[00m Generate preset table for session
525+
\033[0;33mgenerate:cache-table\033[00m Generate preset table for cache
526+
\033[0;33mgenerate:queue-table\033[00m Generate preset table for queue
527+
\033[0;33mgenerate:notification-table\033[00m Generate preset table for notification
522528
\033[0;33mgenerate:key\033[00m Create new app key
523-
\033[0;33mflush:worker\033[00m Flush all queues
529+
\033[0;33mflush:worker\033[00m Flush all queues
524530
525531
\033[0;32mADD\033[00m Create a user class
526532
\033[0;33madd:middleware\033[00m Create new middleware
@@ -535,30 +541,30 @@ private function help(?string $command = null): int
535541
\033[0;33madd:event\033[00m Create a new event
536542
\033[0;33madd:listener\033[00m Create a new event listener
537543
\033[0;33madd:job\033[00m Create a new job
538-
\033[0;33madd:command\033[00m Create a new bow console command
539-
\033[0;33madd:message\033[00m Create a new bow messaging
544+
\033[0;33madd:command\033[00m Create a new console command
545+
\033[0;33madd:message\033[00m Create a new messaging handler
540546
541-
\033[0;32mMIGRATION\033[00m apply a migration in user model
542-
\033[0;33mmigration:migrate\033[00m Make migration
543-
\033[0;33mmigration:reset\033[00m Reset all migration
547+
\033[0;32mMIGRATION\033[00m Apply migration to database
548+
\033[0;33mmigration:migrate\033[00m Run migrations
549+
\033[0;33mmigration:reset\033[00m Reset all migrations
544550
\033[0;33mmigration:rollback\033[00m Rollback to previous migration
545551
\033[0;33mmigrate\033[00m Alias of \033[0;33mmigration:migrate\033[00m
546552
547-
\033[0;32mCLEAR\033[00m for clear cache information
548-
\033[0;33mclear:view\033[00m Clear view cached information
549-
\033[0;33mclear:cache\033[00m Clear cache information
550-
\033[0;33mclear:session\033[00m Clear session cache information
551-
\033[0;33mclear:log\033[00m Clear logs cache information
552-
\033[0;33mclear:all\033[00m Clear all cache information
553+
\033[0;32mCLEAR\033[00m Clear cache information
554+
\033[0;33mclear:view\033[00m Clear view cached files
555+
\033[0;33mclear:cache\033[00m Clear cache files
556+
\033[0;33mclear:session\033[00m Clear session cache files
557+
\033[0;33mclear:log\033[00m Clear log files
558+
\033[0;33mclear:all\033[00m Clear all cache files
553559
554-
\033[0;32mSEED\033[00m Make seeding
555-
\033[0;33mseed:file\033[00m [class_name] Make seeding for one file
556-
\033[0;33mseed:all\033[00m Make seeding for all
560+
\033[0;32mSEED\033[00m Run database seeders
561+
\033[0;33mseed:file\033[00m [class_name] Run specific seeder file
562+
\033[0;33mseed:all\033[00m Run all seeders
557563
558-
\033[0;32mRUN\033[00m Launch process
559-
\033[0;33mrun:console\033[00m show psysh php REPL for debug you code.
560-
\033[0;33mrun:server\033[00m run a local web server.
561-
\033[0;33mrun:worker\033[00m run a consumer/worker for handle queue.
564+
\033[0;32mRUN\033[00m Launch development tools
565+
\033[0;33mrun:console\033[00m Show PsySH PHP REPL for debugging code
566+
\033[0;33mrun:server\033[00m Start local development server
567+
\033[0;33mrun:worker\033[00m Start consumer/worker to handle queue jobs
562568
563569
USAGE;
564570
echo $usage;
@@ -577,20 +583,20 @@ private function help(?string $command = null): int
577583
578584
* you can use --no-plain --with-model in same command
579585
580-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:controller name [option] For create a new controller
581-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:middleware name For create a new middleware
582-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:configuration name For create a new configuration
583-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:service name For create a new service
584-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:exception name For create a new exception
585-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:model name [option] For create a new model
586-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:validation name For create a new validation
587-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:seeder name [--seed=n] For create a new seeder
588-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:migration name For create a new migration
589-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:event name For create a new event listener
590-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:job name For create a new queue job
591-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:command name For create a new bow console command
592-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:message name For create a new bow messaging
593-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add help For display this
586+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:controller name [option] Create a new controller
587+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:middleware name Create a new middleware
588+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:configuration name Create a new configuration
589+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:service name Create a new service
590+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:exception name Create a new exception
591+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:model name [option] Create a new model
592+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:validation name Create a new validation
593+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:seeder name [--seed=n] Create a new seeder
594+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:migration name Create a new migration
595+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:event name Create a new event listener
596+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:job name Create a new queue job
597+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:command name Create a new console command
598+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:message name Create a new messaging handler
599+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add help Display this help
594600
595601
U;
596602

@@ -602,13 +608,13 @@ private function help(?string $command = null): int
602608
[option]
603609
--model=[model_name] Define the usable model
604610
605-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:resource name [option] For create a new REST controller
606-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:session-table For generate the table for session
607-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:cache-table For generate the table for cache
608-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:queue-table For generate the table for queue
609-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:notification-table For generate the table for notification
610-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:key For generate a new APP KEY
611-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate help For display this
611+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:resource name [option] Create a new REST controller
612+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:session-table Generate the table for session
613+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:cache-table Generate the table for cache
614+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:queue-table Generate the table for queue
615+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:notification-table Generate the table for notification
616+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:key Generate a new APP KEY
617+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m generate help Display this help
612618
\033[0;33mgen\033[00m Alias of \033[0;33mgenerate\033[00m
613619
614620
U;
@@ -617,11 +623,11 @@ private function help(?string $command = null): int
617623
echo <<<U
618624
\n\033[0;32mmigration\033[00m apply a migration in user model\n
619625
620-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migration:migrate Make migration
621-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migration:reset Reset all migration
626+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migration:migrate Run migrations
627+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migration:reset Reset all migrations
622628
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migration:rollback Rollback to previous migration
623629
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migrate Alias of \033[0;33mmigration:migrate\033[00m
624-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migration help For display this
630+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m migration help Display this help
625631
626632
U;
627633
break;
@@ -634,9 +640,9 @@ private function help(?string $command = null): int
634640
run:console [--include=filename.php] [--prompt=prompt_name]
635641
run:worker [--queue=default] [--connexion=beanstalkd,sqs,redis,database] [--tries=duration] [--sleep=duration] [--timeout=duration]
636642
637-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:console\033[00m Show psysh php REPL for debug you code
638-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:server\033[00m [option] Start local development server
639-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:worker\033[00m [option] Start workerr for handle the queue jobs
643+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:console Show PsySH PHP REPL for debugging code
644+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:server [option] Start local development server
645+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:worker [option] Start worker to handle queue jobs
640646
641647
U; // phpcs:enable
642648
break;
@@ -664,7 +670,7 @@ private function help(?string $command = null): int
664670

665671
case 'flush':
666672
echo <<<U
667-
\n\033[0;32mMFlush all queues content\033[00m\n
673+
\n\033[0;32mFlush all queues content\033[00m\n
668674
[option]
669675
flush:worker [connection] [--queue=queue_name]
670676

src/Messaging/CanSendMessage.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function sendMessage(Messaging $message): void
2323
*/
2424
public function setMessageQueue(Messaging $message): void
2525
{
26-
$producer = new MessagingQueueProducer($this, $message);
26+
$producer = new MessagingQueueJob($this, $message);
2727

2828
queue($producer);
2929
}
@@ -37,7 +37,7 @@ public function setMessageQueue(Messaging $message): void
3737
*/
3838
public function sendMessageQueueOn(string $queue, Messaging $message): void
3939
{
40-
$producer = new MessagingQueueProducer($this, $message);
40+
$producer = new MessagingQueueJob($this, $message);
4141

4242
$producer->setQueue($queue);
4343

@@ -53,7 +53,7 @@ public function sendMessageQueueOn(string $queue, Messaging $message): void
5353
*/
5454
public function sendMessageLater(int $delay, Messaging $message): void
5555
{
56-
$producer = new MessagingQueueProducer($this, $message);
56+
$producer = new MessagingQueueJob($this, $message);
5757

5858
$producer->setDelay($delay);
5959

@@ -70,7 +70,7 @@ public function sendMessageLater(int $delay, Messaging $message): void
7070
*/
7171
public function sendMessageLaterOn(int $delay, string $queue, Messaging $message): void
7272
{
73-
$producer = new MessagingQueueProducer($this, $message);
73+
$producer = new MessagingQueueJob($this, $message);
7474

7575
$producer->setQueue($queue);
7676
$producer->setDelay($delay);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Bow\Queue\QueueJob;
77
use Throwable;
88

9-
class MessagingQueueProducer extends QueueJob
9+
class MessagingQueueJob extends QueueJob
1010
{
1111
/**
1212
* The message bag
@@ -16,7 +16,7 @@ class MessagingQueueProducer extends QueueJob
1616
private array $bags = [];
1717

1818
/**
19-
* MessagingQueueProducer constructor
19+
* MessagingQueueJob constructor
2020
*
2121
* @param Model $context
2222
* @param Messaging $message

0 commit comments

Comments
 (0)