Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update run-tests.yml #111

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0633e32
Update run-tests.yml
askdkc Jan 16, 2024
aa7ae71
Update run-tests.yml
askdkc Jan 16, 2024
3d20762
Update composer.json
askdkc Jan 16, 2024
aa55527
Update composer.json
askdkc Jan 16, 2024
5956821
Update install command for Laravel 11
askdkc Jan 16, 2024
843a825
Fix styling
askdkc Jan 16, 2024
7f60983
Update test to support Laravel 11
askdkc Jan 16, 2024
72c8e5c
Merge branch 'laravel11' of github.com:askdkc/breezejp into laravel11
askdkc Jan 16, 2024
f083efc
Fix styling
askdkc Jan 16, 2024
d96130c
Fix to adopt Laravel 11 .env
askdkc Jan 16, 2024
e116fce
Fix styling
askdkc Jan 16, 2024
6126252
Using Laravel version for test
askdkc Jan 16, 2024
fdba968
Merge branch 'laravel11' of github.com:askdkc/breezejp into laravel11
askdkc Jan 16, 2024
1aca61c
Fix styling
askdkc Jan 16, 2024
b4905e2
Fix condition
askdkc Jan 16, 2024
4385358
Fix condition
askdkc Jan 16, 2024
fba9937
Merge branch 'laravel11' of github.com:askdkc/breezejp into laravel11
askdkc Jan 16, 2024
92ff933
Update run-tests.yml
askdkc Jan 16, 2024
95f976f
Update test case for 11
askdkc Jan 16, 2024
2a3f8b0
Fix styling
askdkc Jan 16, 2024
f95f848
Update CommandTest.php
askdkc Jan 16, 2024
c0e1a78
Merge branch 'laravel11' of github.com:askdkc/breezejp into laravel11
askdkc Jan 16, 2024
a75cd7f
debug
askdkc Jan 17, 2024
a42b217
Update CommandTest.php
askdkc Jan 17, 2024
5ae1d96
Fix styling
askdkc Jan 17, 2024
952dc88
Update BreezejpCommand.php
askdkc Jan 17, 2024
2042c83
Merge branch 'laravel11' of github.com:askdkc/breezejp into laravel11
askdkc Jan 17, 2024
24562bb
Fix styling
askdkc Jan 17, 2024
4acfa5a
Update BreezejpCommand.php
askdkc Jan 17, 2024
807f0c0
Fix Laravel 11 Issue
askdkc Jan 17, 2024
7b8658b
Fix styling
askdkc Jan 17, 2024
a039b23
Update run-tests.yml
askdkc Jan 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ jobs:
matrix:
os: [ubuntu-latest]
php: [8.0, 8.1, 8.2, 8.3]
laravel: [10.*, 9.*]
stability: [prefer-lowest, prefer-stable]
laravel: [11.*, 10.*, 9.*]
stability: [prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"require": {
"php": "^8.0",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^9.28|^10.0"
"illuminate/contracts": "^9.28|^10.0|^11.0"
},
"require-dev": {
"laravel/pint": "^1.4",
"nunomaduro/collision": "^6.0|^7.0",
"nunomaduro/larastan": "^2.0",
"orchestra/testbench": "^7.7|^8.0",
"pestphp/pest": "^1.22|^2.0",
"nunomaduro/collision": "^6.0|^7.0|^8.0",
"larastan/larastan": "^2.0",
"orchestra/testbench": "^7.7|^8.0|^9.0",
"pestphp/pest": "^1.22|^2.0|^3.0",
"phpstan/extension-installer": "^1.2",
"phpunit/phpunit": "^9.5.27|^10.0"
"phpunit/phpunit": "^9.5.27|^10.0|^11.0"
},
"autoload": {
"psr-4": {
Expand Down
51 changes: 45 additions & 6 deletions src/Commands/BreezejpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,55 @@ public function handle(): int
(new Filesystem)->ensureDirectoryExists(lang_path());
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/lang/', lang_path());

$this->info('config/app.phpのlocaleをjaにします');
$envfile = file_get_contents(base_path('.env'));

if (strpos($envfile, 'APP_FAKER_LOCALE') == false) {
$this->info('config/app.phpのlocaleをjaにします');
// Read the contents of the file into a string
$configfile = file_get_contents(base_path('config/app.php'));

// Modify the contents of the string
$configfile = str_replace("'locale' => 'en'", "'locale' => 'ja'", $configfile);
$configfile = str_replace("'faker_locale' => 'en_US'", "'faker_locale' => 'ja_JP'", $configfile);
$configfile = str_replace("'timezone' => 'UTC'", "'timezone' => 'Asia/Tokyo'", $configfile);

// Save the modified contents back to the file
file_put_contents(base_path('config/app.php'), $configfile);

if ($this->confirm('GitHubリポジトリにスターの御協力をお願いします🙏', true)) {
$repoUrl = 'https://github.com/askdkc/breezejp';

if (PHP_OS_FAMILY == 'Darwin') {
exec("open {$repoUrl}");
}
if (PHP_OS_FAMILY == 'Windows') {
exec("start {$repoUrl}");
}
if (PHP_OS_FAMILY == 'Linux') {
exec("xdg-open {$repoUrl}");
}

$this->line('Thank you! / ありがとう💓');
}

$this->info('日本語ファイルのインストールが完了しました!');

return self::SUCCESS;

}

// For Laravel 11 and above
$this->info('.envのAPP_LOCALEやTAPP_IMEZONEを日本にします');
// Read the contents of the file into a string
$configfile = file_get_contents(base_path('config/app.php'));
$configfile = file_get_contents(base_path('.env'));

// Modify the contents of the string
$configfile = str_replace("'locale' => 'en'", "'locale' => 'ja'", $configfile);
$configfile = str_replace("'faker_locale' => 'en_US'", "'faker_locale' => 'ja_JP'", $configfile);
$configfile = str_replace("'timezone' => 'UTC'", "'timezone' => 'Asia/Tokyo'", $configfile);
$configfile = str_replace('APP_LOCALE=en', 'APP_LOCALE=ja', $configfile);
$configfile = str_replace('APP_FAKER_LOCALE=en_US', 'APP_FAKER_LOCALE=ja_JP', $configfile);
$configfile = str_replace('APP_TIMEZONE=UTC', 'APP_TIMEZONE=Asia/Tokyo', $configfile);

// Save the modified contents back to the file
file_put_contents(base_path('config/app.php'), $configfile);
file_put_contents(base_path('.env'), $configfile);

if ($this->confirm('GitHubリポジトリにスターの御協力をお願いします🙏', true)) {
$repoUrl = 'https://github.com/askdkc/breezejp';
Expand All @@ -56,5 +94,6 @@ public function handle(): int
$this->info('日本語ファイルのインストールが完了しました!');

return self::SUCCESS;

}
}
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);
}
});
2 changes: 2 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ protected function setUp(): void
{
parent::setUp();

copy(__DIR__.'/../vendor/orchestra/testbench-core/laravel/.env.example', __DIR__.'/../vendor/orchestra/testbench-core/laravel/.env');

// テスト用のファイルが残ってたら消す(web.php)
if (is_file(__DIR__.'/../vendor/orchestra/testbench-core/laravel/routes/web.php')) {
unlink(__DIR__.'/../vendor/orchestra/testbench-core/laravel/routes/web.php');
Expand Down
Loading