Skip to content

Commit

Permalink
Test for Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
askdkc committed Jan 17, 2024
1 parent 594456a commit 0f21144
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

test('.env file exists', function () {
$this->assertFileExists(base_path('.env'));
});

test('breezejp command successfully run and see all the published files', closure: function () {
$this->artisan('breezejp')
->expectsOutput('Laravel Breeze用に日本語翻訳ファイルを準備します')
Expand All @@ -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 () {
Expand All @@ -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);
}
});

0 comments on commit 0f21144

Please sign in to comment.