From f952fc1f4776668126d87f3d87c5dcce477d71c2 Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Sun, 19 Jan 2025 01:10:22 +0000 Subject: [PATCH 1/3] feat: create command for notication and messaging --- composer.json | 3 +- src/Console/Argument.php | 2 +- src/Console/Command.php | 8 ++-- .../Command/GenerateNotificationCommand.php | 35 ++++++++++++++++ src/Console/Command/GenerateQueueCommand.php | 2 +- src/Console/Command/MessagingCommand.php | 42 +++++++++++++++++++ src/Console/Console.php | 24 +++++++---- src/Console/Setting.php | 30 ++++++++++++- src/Console/stubs/messaging.stub | 42 +++++++++++++++++++ src/Console/stubs/model/cache.stub | 4 +- src/Console/stubs/model/create.stub | 4 +- src/Console/stubs/model/notification.stub | 35 ++++++++++++++++ src/Console/stubs/model/queue.stub | 7 ++-- src/Console/stubs/model/session.stub | 4 +- src/Console/stubs/model/standard.stub | 4 +- src/Console/stubs/model/table.stub | 4 +- src/Console/stubs/validation.stub | 2 +- src/Messaging/CanSendMessaging.php | 17 ++++++++ src/Messaging/Channel/DatabaseChannel.php | 32 ++++++++++++++ .../Channel/MailChannel.php | 7 +++- src/Messaging/Contracts/ChannelInterface.php | 16 +++++++ .../Messaging.php} | 21 +++++++--- src/Notification/CanSendNotification.php | 17 -------- src/Notification/Channel/ChannelInterface.php | 13 ------ src/Notification/Channel/DatabaseChannel.php | 23 ---------- 25 files changed, 309 insertions(+), 89 deletions(-) create mode 100644 src/Console/Command/GenerateNotificationCommand.php create mode 100644 src/Console/Command/MessagingCommand.php create mode 100644 src/Console/stubs/messaging.stub create mode 100644 src/Console/stubs/model/notification.stub create mode 100644 src/Messaging/CanSendMessaging.php create mode 100644 src/Messaging/Channel/DatabaseChannel.php rename src/{Notification => Messaging}/Channel/MailChannel.php (69%) create mode 100644 src/Messaging/Contracts/ChannelInterface.php rename src/{Notification/Notification.php => Messaging/Messaging.php} (78%) delete mode 100644 src/Notification/CanSendNotification.php delete mode 100644 src/Notification/Channel/ChannelInterface.php delete mode 100644 src/Notification/Channel/DatabaseChannel.php diff --git a/composer.json b/composer.json index 44922a26..724232cc 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "ramsey/uuid": "^4.7", "ext-ftp": "*", "ext-openssl": "*", - "ext-pcntl": "*" + "ext-pcntl": "*", + "ext-readline": "*" }, "require-dev": { "pda/pheanstalk": "^5.0", diff --git a/src/Console/Argument.php b/src/Console/Argument.php index 7a2ac779..2e99c41b 100644 --- a/src/Console/Argument.php +++ b/src/Console/Argument.php @@ -176,7 +176,7 @@ public function hasTrash(): bool */ private function initCommand(string $param): void { - if (!preg_match('/^[a-z]+:[a-z]+$/', $param)) { + if (!preg_match('/^[a-z-]+[a-z]+:[a-z-]+[a-z]+$/', $param)) { $this->command = $param; $this->action = null; } else { diff --git a/src/Console/Command.php b/src/Console/Command.php index f206bc73..e952d192 100644 --- a/src/Console/Command.php +++ b/src/Console/Command.php @@ -31,13 +31,15 @@ class Command extends AbstractCommand "listener" => \Bow\Console\Command\EventListenerCommand::class, "producer" => \Bow\Console\Command\ProducerCommand::class, "command" => \Bow\Console\Command\ConsoleCommand::class, + "messaging" => \Bow\Console\Command\MessagingCommand::class, ], "generator" => [ "key" => \Bow\Console\Command\GenerateKeyCommand::class, "resource" => \Bow\Console\Command\GenerateResourceControllerCommand::class, - "session" => \Bow\Console\Command\GenerateSessionCommand::class, - "queue" => \Bow\Console\Command\GenerateQueueCommand::class, - "cache" => \Bow\Console\Command\GenerateCacheCommand::class, + "session-table" => \Bow\Console\Command\GenerateSessionCommand::class, + "queue-table" => \Bow\Console\Command\GenerateQueueCommand::class, + "cache-table" => \Bow\Console\Command\GenerateCacheCommand::class, + "notification-table" => \Bow\Console\Command\GenerateCacheCommand::class, ], "runner" => [ "console" => \Bow\Console\Command\ReplCommand::class, diff --git a/src/Console/Command/GenerateNotificationCommand.php b/src/Console/Command/GenerateNotificationCommand.php new file mode 100644 index 00000000..9792146d --- /dev/null +++ b/src/Console/Command/GenerateNotificationCommand.php @@ -0,0 +1,35 @@ +setting->getMigrationDirectory(), + $filename + ); + + $generator->write('model/notification', [ + 'className' => $filename + ]); + + echo Color::green('Notification migration created.'); + } +} diff --git a/src/Console/Command/GenerateQueueCommand.php b/src/Console/Command/GenerateQueueCommand.php index d7b655df..08aac7e3 100644 --- a/src/Console/Command/GenerateQueueCommand.php +++ b/src/Console/Command/GenerateQueueCommand.php @@ -19,7 +19,7 @@ class GenerateQueueCommand extends AbstractCommand public function generate(): void { $create_at = date("YmdHis"); - $filename = sprintf("Version%s%sTable", $create_at, ucfirst(Str::camel('queue'))); + $filename = sprintf("Version%s%sTable", $create_at, ucfirst(Str::camel('queues'))); $generator = new Generator( $this->setting->getMigrationDirectory(), diff --git a/src/Console/Command/MessagingCommand.php b/src/Console/Command/MessagingCommand.php new file mode 100644 index 00000000..59f4058b --- /dev/null +++ b/src/Console/Command/MessagingCommand.php @@ -0,0 +1,42 @@ +setting->getMessagingDirectory(), + $messaging + ); + + if ($generator->fileExists()) { + echo Color::red("The messaging already exists"); + + exit(1); + } + + $generator->write('messaging', [ + 'baseNamespace' => $this->namespaces['messaging'] ?? "App\\Messaging", + ]); + + echo Color::green("The messaging has been well created."); + + exit(0); + } +} diff --git a/src/Console/Console.php b/src/Console/Console.php index 0807ae84..605765ea 100644 --- a/src/Console/Console.php +++ b/src/Console/Console.php @@ -407,7 +407,7 @@ private function generate(): void { $action = $this->arg->getAction(); - if (!in_array($action, ['key', 'resource', 'session', 'cache', 'queue'])) { + if (!in_array($action, ['key', 'resource', 'session-table', 'cache-table', 'queue-table'])) { $this->throwFailsCommand('This action is not exists', 'help generate'); } @@ -476,10 +476,13 @@ private function help(?string $command = null): int \033[0;33mhelp\033[00m display command helper \033[0;32mGENERATE\033[00m create a new app key and resources - \033[0;33mgenerate:resource\033[00m Create new REST controller - \033[0;33mgenerate:table\033[00m For generate the preset table for session, cache, queue - \033[0;33mgenerate:key\033[00m Create new app key - \033[0;33mflush:worker\033[00m Flush all queues + \033[0;33mgenerate:resource\033[00m Create new REST controller + \033[0;33mgenerate:session-table\033[00m For generate the preset table for session + \033[0;33mgenerate:cache-table\033[00m For generate the preset table for cache + \033[0;33mgenerate:queue-table\033[00m For generate the preset table for queue + \033[0;33mgenerate:notification-table\033[00m For generate the preset table for notification + \033[0;33mgenerate:key\033[00m Create new app key + \033[0;33mflush:worker\033[00m Flush all queues \033[0;32mADD\033[00m Create a user class \033[0;33madd:middleware\033[00m Create new middleware @@ -495,6 +498,7 @@ private function help(?string $command = null): int \033[0;33madd:listener\033[00m Create a new event listener \033[0;33madd:producer\033[00m Create a new producer \033[0;33madd:command\033[00m Create a new bow console command + \033[0;33madd:messaging\033[00m Create a new bow messaging \033[0;32mMIGRATION\033[00m apply a migration in user model \033[0;33mmigration:migrate\033[00m Make migration @@ -538,7 +542,7 @@ private function help(?string $command = null): int * you can use --no-plain --with-model in same command - \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:controller name [option] For create a new controlleur + \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:controller name [option] For create a new controller \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:middleware name For create a new middleware \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:configuration name For create a new configuration \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:service name For create a new service @@ -550,6 +554,7 @@ private function help(?string $command = null): int \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:event name For create a new event listener \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:producer name For create a new queue producer \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:command name For create a new bow console command + \033[0;33m$\033[00m php \033[0;34mbow\033[00m add:messaging name For create a new bow messaging \033[0;33m$\033[00m php \033[0;34mbow\033[00m add help For display this U; @@ -564,7 +569,10 @@ private function help(?string $command = null): int --model=[model_name] Define the usable model \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:resource name [option] For create a new REST controller - \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:table For generate the table for session, cache, queue + \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:session-table For generate the table for session + \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:cache-table For generate the table for cache + \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:queue-table For generate the table for queue + \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:notification-table For generate the table for notification \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate:key For generate a new APP KEY \033[0;33m$\033[00m php \033[0;34mbow\033[00m generate help For display this @@ -592,7 +600,7 @@ private function help(?string $command = null): int run:worker [--queue=default] [--connexion=beanstalkd,sqs,redis,database] [--tries=duration] [--sleep=duration] [--timeout=duration] \033[0;33m$\033[00m php \033[0;34mbow\033[00m run:console\033[00m Show psysh php REPL - \033[0;33m$\033[00m php \033[0;34mbow\033[00m run:server\033[00m [option] Start local developpement server + \033[0;33m$\033[00m php \033[0;34mbow\033[00m run:server\033[00m [option] Start local development server \033[0;33m$\033[00m php \033[0;34mbow\033[00m run:worker\033[00m [option] Start worker/consumer for handle the producer U; // phpcs:enable diff --git a/src/Console/Setting.php b/src/Console/Setting.php index bb398b66..42136bf5 100644 --- a/src/Console/Setting.php +++ b/src/Console/Setting.php @@ -171,6 +171,13 @@ class Setting */ private array $namespaces = []; + /** + * The messaging directory + * + * @var string + */ + private string $messaging_directory; + /** * Command constructor. * @@ -303,6 +310,17 @@ public function setMiddlewareDirectory(string $middleware_directory): void $this->middleware_directory = $middleware_directory; } + /** + * Set the messaging directory + * + * @param string $messaging_directory + * @return void + */ + public function setMessagingDirectory(string $messaging_directory): void + { + $this->messaging_directory = $messaging_directory; + } + /** * Set the application directory * @@ -546,7 +564,7 @@ public function getEventListenerDirectory(): string } /** - * Get the service directory + * Get the middleware directory * * @return string */ @@ -555,6 +573,16 @@ public function getMiddlewareDirectory(): string return $this->middleware_directory; } + /** + * Get the messaging directory + * + * @return string + */ + public function getMessagingDirectory(): string + { + return $this->messaging_directory; + } + /** * Get the model directory * diff --git a/src/Console/stubs/messaging.stub b/src/Console/stubs/messaging.stub new file mode 100644 index 00000000..f4a67884 --- /dev/null +++ b/src/Console/stubs/messaging.stub @@ -0,0 +1,42 @@ +create("caches", function (SQLGenerator $table) { + $this->create("caches", function (Table $table) { $table->addString('keyname', ['primary' => true, 'size' => 500]); $table->addText('data'); $table->addDatetime('expire', ['nullable' => true]); diff --git a/src/Console/stubs/model/create.stub b/src/Console/stubs/model/create.stub index e08558c3..001aa63e 100644 --- a/src/Console/stubs/model/create.stub +++ b/src/Console/stubs/model/create.stub @@ -1,7 +1,7 @@ create("{table}", function (SQLGenerator $table) { + $this->create("{table}", function (Table $table) { $table->addIncrement('id'); $table->addTimestamps(); }); diff --git a/src/Console/stubs/model/notification.stub b/src/Console/stubs/model/notification.stub new file mode 100644 index 00000000..c5abe0e0 --- /dev/null +++ b/src/Console/stubs/model/notification.stub @@ -0,0 +1,35 @@ +create("notifications", function (Table $table) { + $table->addString('id', ["primary" => true]); + $table->addString('type'); + $table->addString('concern_id'); + $table->addString('concern_type'); + $table->addText('data'); + $table->addDatetime('read_at', ['nullable' => true); + $table->addTimestamps(); + }); + } + + /** + * Rollback migration + */ + public function rollback(): void + { + $this->dropIfExists("queues"); + + if ($this->getAdapterName() === 'pgsql') { + $this->addSql("DROP TYPE IF EXISTS queue_status"); + } + } +} diff --git a/src/Console/stubs/model/queue.stub b/src/Console/stubs/model/queue.stub index e6239761..417571b2 100644 --- a/src/Console/stubs/model/queue.stub +++ b/src/Console/stubs/model/queue.stub @@ -1,7 +1,7 @@ create("queues", function (SQLGenerator $table) { + $this->create("queues", function (Table $table) { $table->addString('id', ["primary" => true]); $table->addString('queue'); $table->addText('payload'); @@ -31,7 +31,8 @@ class {className} extends Migration public function rollback(): void { $this->dropIfExists("queues"); - if ($this->adapter->getName() === 'pgsql') { + + if ($this->getAdapterName() === 'pgsql') { $this->addSql("DROP TYPE IF EXISTS queue_status"); } } diff --git a/src/Console/stubs/model/session.stub b/src/Console/stubs/model/session.stub index a754ca1d..980dcee3 100644 --- a/src/Console/stubs/model/session.stub +++ b/src/Console/stubs/model/session.stub @@ -1,7 +1,7 @@ create("sessions", function (SQLGenerator $table) { + $this->create("sessions", function (Table $table) { $table->addColumn('id', 'string', ['primary' => true]); $table->addColumn('time', 'timestamp'); $table->addColumn('data', 'text'); diff --git a/src/Console/stubs/model/standard.stub b/src/Console/stubs/model/standard.stub index acb25a29..f707746c 100644 --- a/src/Console/stubs/model/standard.stub +++ b/src/Console/stubs/model/standard.stub @@ -1,7 +1,7 @@ create("{table}", function (SQLGenerator $table) { + $this->create("{table}", function (Table $table) { // }); } diff --git a/src/Console/stubs/model/table.stub b/src/Console/stubs/model/table.stub index d232d509..563d2d17 100644 --- a/src/Console/stubs/model/table.stub +++ b/src/Console/stubs/model/table.stub @@ -1,7 +1,7 @@ alter("{table}", function (SQLGenerator $table) { + $this->alter("{table}", function (Table $table) { // }); } diff --git a/src/Console/stubs/validation.stub b/src/Console/stubs/validation.stub index ab3d5480..1c394091 100644 --- a/src/Console/stubs/validation.stub +++ b/src/Console/stubs/validation.stub @@ -11,7 +11,7 @@ class {className} extends RequestValidation * * @return array */ - protected function rules() + protected function rules(): array { return [ // Your roles here diff --git a/src/Messaging/CanSendMessaging.php b/src/Messaging/CanSendMessaging.php new file mode 100644 index 00000000..2f4b9095 --- /dev/null +++ b/src/Messaging/CanSendMessaging.php @@ -0,0 +1,17 @@ +process($this); + } +} diff --git a/src/Messaging/Channel/DatabaseChannel.php b/src/Messaging/Channel/DatabaseChannel.php new file mode 100644 index 00000000..46ce8ed9 --- /dev/null +++ b/src/Messaging/Channel/DatabaseChannel.php @@ -0,0 +1,32 @@ +insert([ + 'id' => str_uuid(), + 'data' => $this->database['data'], + 'concern_id' => $notifiable->getKey(), + 'concern_type' => get_class($notifiable), + 'type' => $this->database['type'], + ]); + } +} diff --git a/src/Notification/Channel/MailChannel.php b/src/Messaging/Channel/MailChannel.php similarity index 69% rename from src/Notification/Channel/MailChannel.php rename to src/Messaging/Channel/MailChannel.php index 16fca7e8..b7afa4af 100644 --- a/src/Notification/Channel/MailChannel.php +++ b/src/Messaging/Channel/MailChannel.php @@ -1,9 +1,11 @@ send($this->message); } diff --git a/src/Messaging/Contracts/ChannelInterface.php b/src/Messaging/Contracts/ChannelInterface.php new file mode 100644 index 00000000..80c504d7 --- /dev/null +++ b/src/Messaging/Contracts/ChannelInterface.php @@ -0,0 +1,16 @@ +channels)) { $result = $this->{"to" . ucfirst($channel)}($notifiable); $target_channel = new $this->channels[$channel]($result); - $target_channel->send(); + $target_channel->send($notifiable); } } } diff --git a/src/Notification/CanSendNotification.php b/src/Notification/CanSendNotification.php deleted file mode 100644 index 5081a344..00000000 --- a/src/Notification/CanSendNotification.php +++ /dev/null @@ -1,17 +0,0 @@ -process($this); - } -} diff --git a/src/Notification/Channel/ChannelInterface.php b/src/Notification/Channel/ChannelInterface.php deleted file mode 100644 index 390ae240..00000000 --- a/src/Notification/Channel/ChannelInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -insert($this->database); - } -} From 9b24caac3cce211cc3edfcc31cb54da8d04b3bff Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Sun, 19 Jan 2025 07:46:47 +0000 Subject: [PATCH 2/3] refactor: code formatting --- src/Application/Application.php | 27 +++++++++++++++------------ src/Auth/Auth.php | 4 ++++ src/Auth/Guards/SessionGuard.php | 1 - 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Application/Application.php b/src/Application/Application.php index 555f4860..6ed04c77 100644 --- a/src/Application/Application.php +++ b/src/Application/Application.php @@ -75,7 +75,6 @@ class Application extends Router * * @param Request $request * @param Response $response - * @return void * @throws BadRequestException */ public function __construct(Request $request, Response $response) @@ -172,10 +171,11 @@ public function isRunningOnCli(): bool /** * Launcher of the application * - * @return ?bool - * @throws RouterException|ReflectionException + * @return bool + * @throws ReflectionException + * @throws RouterException */ - public function send(): ?bool + public function send(): bool { if ($this->config->isCli()) { return true; @@ -227,21 +227,24 @@ public function send(): ?bool // Error management if ($resolved) { - return $this->sendResponse($response); + $this->sendResponse($response); + return true; } // We apply the 404 error code $this->response->status(404); - if (array_key_exists(404, $this->error_code)) { - $response = Action::getInstance()->execute($this->error_code[404], []); - - return $this->sendResponse($response, 404); + if (!array_key_exists(404, $this->error_code)) { + throw new RouterException( + sprintf('Route "%s" not found', $this->request->path()) + ); } - throw new RouterException( - sprintf('Route "%s" not found', $this->request->path()) - ); + $response = Action::getInstance()->execute($this->error_code[404], []); + + $this->sendResponse($response, 404); + + return false; } /** diff --git a/src/Auth/Auth.php b/src/Auth/Auth.php index 27651c43..84ba648b 100644 --- a/src/Auth/Auth.php +++ b/src/Auth/Auth.php @@ -116,5 +116,9 @@ public static function __callStatic(string $method, array $params) if (method_exists(static::$instance, $method)) { return call_user_func_array([static::$instance, $method], $params); } + + throw new ErrorException( + "Method [$method] does not exists" + ); } } diff --git a/src/Auth/Guards/SessionGuard.php b/src/Auth/Guards/SessionGuard.php index 658e0f28..bfe32bcf 100644 --- a/src/Auth/Guards/SessionGuard.php +++ b/src/Auth/Guards/SessionGuard.php @@ -29,7 +29,6 @@ class SessionGuard extends GuardContract */ private string $session_key; - /** * SessionGuard constructor. * From 1625e271367b354dd875812b7ec746002d307231 Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Mon, 20 Jan 2025 01:18:56 +0000 Subject: [PATCH 3/3] test: update snapshots --- src/View/View.php | 11 ----------- tests/Application/ApplicationTest.php | 2 +- tests/Console/GeneratorDeepTest.php | 2 +- ...epTest__test_generate_cache_migration_stubs__1.txt | 4 ++-- ...pTest__test_generate_create_migration_stubs__1.txt | 4 ++-- ...epTest__test_generate_queue_migration_stubs__1.txt | 7 ++++--- ...Test__test_generate_session_migration_stubs__1.txt | 4 ++-- ...est__test_generate_standard_migration_stubs__1.txt | 4 ++-- ...epTest__test_generate_table_migration_stubs__1.txt | 4 ++-- ...torDeepTest__test_generate_validation_stubs__1.txt | 2 +- tests/View/ViewTest.php | 6 +++--- 11 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/View/View.php b/src/View/View.php index b8e75872..0f923ad8 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -157,17 +157,6 @@ public function setEngine(string $engine): View return static::getInstance(); } - /** - * Set the availability of caching system - * - * @param bool $cachabled - * @return void - */ - public function cachable(bool $cachabled): void - { - $this->cachabled = $cachabled; - } - /** * @param string $extension * @return View diff --git a/tests/Application/ApplicationTest.php b/tests/Application/ApplicationTest.php index 1f88526b..52e5451e 100644 --- a/tests/Application/ApplicationTest.php +++ b/tests/Application/ApplicationTest.php @@ -118,7 +118,7 @@ public function test_send_application_with_matched_route() return "work"; }); - $this->assertNull($app->send()); + $this->assertIsBool($app->send()); } public function test_send_application_with_no_matched_route() diff --git a/tests/Console/GeneratorDeepTest.php b/tests/Console/GeneratorDeepTest.php index a497ec2e..19c75878 100644 --- a/tests/Console/GeneratorDeepTest.php +++ b/tests/Console/GeneratorDeepTest.php @@ -190,7 +190,7 @@ public function test_generate_queue_migration_stubs() $this->assertNotNull($content); $this->assertMatchesSnapshot($content); $this->assertMatchesRegularExpression("@\nclass\sQueueTableMigration\sextends\sMigration\n@", $content); - $this->assertStringContainsString("\$this->create(\"queues\", function (SQLGenerator \$table) {", $content); + $this->assertStringContainsString("\$this->create(\"queues\", function (Table \$table) {", $content); $this->assertStringContainsString("\$table->addInteger('attempts', [\"default\" => 3]);\n", $content); } diff --git a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_cache_migration_stubs__1.txt b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_cache_migration_stubs__1.txt index 7cc6db8c..fd8289ff 100644 --- a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_cache_migration_stubs__1.txt +++ b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_cache_migration_stubs__1.txt @@ -1,7 +1,7 @@ create("caches", function (SQLGenerator $table) { + $this->create("caches", function (Table $table) { $table->addString('keyname', ['primary' => true, 'size' => 500]); $table->addText('data'); $table->addDatetime('expire', ['nullable' => true]); diff --git a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_create_migration_stubs__1.txt b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_create_migration_stubs__1.txt index 258f828f..20764e7d 100644 --- a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_create_migration_stubs__1.txt +++ b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_create_migration_stubs__1.txt @@ -1,7 +1,7 @@ create("fakers", function (SQLGenerator $table) { + $this->create("fakers", function (Table $table) { $table->addIncrement('id'); $table->addTimestamps(); }); diff --git a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_queue_migration_stubs__1.txt b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_queue_migration_stubs__1.txt index 698f3cbd..26e052b5 100644 --- a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_queue_migration_stubs__1.txt +++ b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_queue_migration_stubs__1.txt @@ -1,7 +1,7 @@ create("queues", function (SQLGenerator $table) { + $this->create("queues", function (Table $table) { $table->addString('id', ["primary" => true]); $table->addString('queue'); $table->addText('payload'); @@ -31,7 +31,8 @@ class QueueTableMigration extends Migration public function rollback(): void { $this->dropIfExists("queues"); - if ($this->adapter->getName() === 'pgsql') { + + if ($this->getAdapterName() === 'pgsql') { $this->addSql("DROP TYPE IF EXISTS queue_status"); } } diff --git a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_session_migration_stubs__1.txt b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_session_migration_stubs__1.txt index 85e78fbd..f42f779b 100644 --- a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_session_migration_stubs__1.txt +++ b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_session_migration_stubs__1.txt @@ -1,7 +1,7 @@ create("sessions", function (SQLGenerator $table) { + $this->create("sessions", function (Table $table) { $table->addColumn('id', 'string', ['primary' => true]); $table->addColumn('time', 'timestamp'); $table->addColumn('data', 'text'); diff --git a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_standard_migration_stubs__1.txt b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_standard_migration_stubs__1.txt index 6caa7629..3e5ca7a7 100644 --- a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_standard_migration_stubs__1.txt +++ b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_standard_migration_stubs__1.txt @@ -1,7 +1,7 @@ create("fakers", function (SQLGenerator $table) { + $this->create("fakers", function (Table $table) { // }); } diff --git a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_table_migration_stubs__1.txt b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_table_migration_stubs__1.txt index 40154ff9..5d730813 100644 --- a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_table_migration_stubs__1.txt +++ b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_table_migration_stubs__1.txt @@ -1,7 +1,7 @@ alter("fakers", function (SQLGenerator $table) { + $this->alter("fakers", function (Table $table) { // }); } diff --git a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_validation_stubs__1.txt b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_validation_stubs__1.txt index 682d7c3d..5efd82bd 100644 --- a/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_validation_stubs__1.txt +++ b/tests/Console/__snapshots__/GeneratorDeepTest__test_generate_validation_stubs__1.txt @@ -11,7 +11,7 @@ class FakeValidationRequest extends RequestValidation * * @return array */ - protected function rules() + protected function rules(): array { return [ // Your roles here diff --git a/tests/View/ViewTest.php b/tests/View/ViewTest.php index 19409a0b..82ce1e2a 100644 --- a/tests/View/ViewTest.php +++ b/tests/View/ViewTest.php @@ -28,7 +28,7 @@ public static function tearDownAfterClass(): void public function test_twig_compilation() { - View::getInstance()->cachable(false); + View::getInstance(); $result = View::parse('twig', ['name' => 'bow', 'engine' => 'twig']); @@ -37,7 +37,7 @@ public function test_twig_compilation() public function test_tintin_compilation() { - View::getInstance()->setEngine('tintin')->setExtension('.tintin.php')->cachable(false); + View::getInstance()->setEngine('tintin')->setExtension('.tintin.php'); $result = View::parse('tintin', ['name' => 'bow', 'engine' => 'tintin']); @@ -46,7 +46,7 @@ public function test_tintin_compilation() public function test_php_compilation() { - View::getInstance()->setEngine('php')->setExtension('.php')->cachable(false); + View::getInstance()->setEngine('php')->setExtension('.php'); $result = View::parse('php', ['name' => 'bow', 'engine' => 'php']);