From 0f21144a2805bb0490824b44c9ebf5ae78e4fbe8 Mon Sep 17 00:00:00 2001 From: askdkc Date: Wed, 17 Jan 2024 10:27:00 +0900 Subject: [PATCH] Test for Laravel 11 --- tests/CommandTest.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 1c0c284..09d7bfd 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -1,5 +1,9 @@ assertFileExists(base_path('.env')); +}); + test('breezejp command successfully run and see all the published files', closure: function () { $this->artisan('breezejp') ->expectsOutput('Laravel Breeze用に日本語翻訳ファイルを準備します') @@ -21,10 +25,17 @@ ->expectsOutput('日本語ファイルのインストールが完了しました!') ->assertExitCode(0); - $configfile = file_get_contents(base_path('config/app.php')); - $this->assertStringContainsString("'locale' => 'ja'", $configfile); - $this->assertStringContainsString("'faker_locale' => 'ja_JP'", $configfile); - $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + if ((int) substr(Illuminate\Foundation\Application::VERSION, 0, 2) < 11) { + $configfile = file_get_contents(base_path('config/app.php')); + $this->assertStringContainsString("'locale' => 'ja'", $configfile); + $this->assertStringContainsString("'faker_locale' => 'ja_JP'", $configfile); + $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + } else { // For Laravel 11 and above + $configfile = file_get_contents(base_path('.env')); + $this->assertStringContainsString('APP_LOCALE=ja', $configfile); + $this->assertStringContainsString('APP_FAKER_LOCALE=ja_JP', $configfile); + $this->assertStringContainsString('APP_TIMEZONE=Asia/Tokyo', $configfile); + } }); test('breezejp command successfully update config/app.php timezone to Asia/Tokyo', function () { @@ -34,6 +45,11 @@ ->expectsOutput('日本語ファイルのインストールが完了しました!') ->assertExitCode(0); - $configfile = file_get_contents(base_path('config/app.php')); - $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + if ((int) substr(Illuminate\Foundation\Application::VERSION, 0, 2) < 11) { + $configfile = file_get_contents(base_path('config/app.php')); + $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + } else { // For Laravel 11 and above + $configfile = file_get_contents(base_path('.env')); + $this->assertStringContainsString('APP_TIMEZONE=Asia/Tokyo', $configfile); + } });