Skip to content

Commit

Permalink
Merge pull request #36 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
Added Laravel 10 compatibility
  • Loading branch information
andrey-helldar authored Jun 24, 2024
2 parents 0200b46 + 75ab5a7 commit 9dd987a
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: true
matrix:
php: [ "8.2", "8.3" ]
laravel: [ "11.0" ]
laravel: [ "10.0", "11.0" ]

name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@
"php": "^8.1",
"composer/class-map-generator": "^1.3",
"dragon-code/support": "^6.13",
"illuminate/database": "^11.4",
"illuminate/support": "^11.4",
"illuminate/database": "^10.0 || ^11.0",
"illuminate/support": "^10.0 || ^11.0",
"laravel-lang/config": "^1.6",
"laravel-lang/locales": "^2.9.1",
"laravel-lang/locales": "^2.9.2",
"laravel/prompts": "^0.1.24"
},
"require-dev": {
"orchestra/testbench": "^9.1",
"orchestra/testbench": "^8.0 || ^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.4",
"symfony/var-dumper": "^7.0"
"symfony/var-dumper": "^6.0 || ^7.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ModelGenerator extends Generator

protected string $casts = '\'%s\' => TrimCast::class,';

protected int $castsPad = 12;
protected int $castsPad = 8;

protected function finish(string $path): void
{
Expand Down
7 changes: 2 additions & 5 deletions stubs/model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class {{model}}{{suffix}} extends Translation
{{fillable}}
];

protected function casts(): array
{
return [
protected $casts = [
{{casts}}
];
}
];
}
2 changes: 1 addition & 1 deletion testbench.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
laravel: ./workbench
providers:
- App\Providers\AppServiceProvider
- LaravelLang\Config\ServiceProvider
- LaravelLang\Locales\ServiceProvider
- LaravelLang\Models\ServiceProvider
- App\Providers\AppServiceProvider
workbench:
welcome: false
install: false
Expand Down
2 changes: 2 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
uses(Tests\TestCase::class, RefreshDatabase::class, WithWorkbench::class)
->compact()
->beforeEach(function () {
Directory::ensureDirectory(database_path());

Directory::ensureDirectory(lang_path(FakeValue::LocaleMain));
Directory::ensureDirectory(lang_path(FakeValue::LocaleFallback));
Directory::ensureDirectory(lang_path(FakeValue::LocaleCustom));
Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use App\Foundation\Application;
use Illuminate\Config\Repository;
use Illuminate\Support\Facades\ParallelTesting;
use LaravelLang\Config\Enums\Name;
Expand All @@ -10,6 +11,11 @@

abstract class TestCase extends BaseTestCase
{
protected function resolveApplication(): Application
{
return new Application($this->getBasePath());
}

protected function defineEnvironment($app): void
{
tap($app['config'], function (Repository $config) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Console/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
->implode('');

$castsMatches = collect(['title', 'description'])
->map(fn (string $column) => sprintf('(\s{12}\'%s\'\s=>\sTrimCast::class,\r?\n?)', $column))
->map(fn (string $column) => sprintf('(\s{8}\'%s\'\s=>\sTrimCast::class,\r?\n?)', $column))
->implode('');

expect(file_get_contents($model))
Expand All @@ -62,7 +62,7 @@
->toMatch(sprintf('/protected\s\$fillable\s=\s\[\r?\n?%s\s+];/', $fillableMatches))
->toMatch(
sprintf(
'/\s{4}protected\s+function\s+casts\(\):\sarray\r?\n?\s{4}\{\r?\n?\s{8}return\s\[\r?\n?%s\s{8}\];\r?\n?\s{4}\}/',
'/\s{4}protected\s+\$casts\s+=\s+\[\r?\n?%s\r?\n?\s{4}\]/',
$castsMatches
)
);
Expand Down
11 changes: 4 additions & 7 deletions workbench/app/Models/TestModelTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ class TestModelTranslation extends Translation
'description',
];

protected function casts(): array
{
return [
'title' => TrimCast::class,
'description' => TrimCast::class,
];
}
protected $casts = [
'title' => TrimCast::class,
'description' => TrimCast::class,
];
}
2 changes: 2 additions & 0 deletions workbench/bootstrap/cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Empty file removed workbench/bootstrap/cache/.gitkeep
Empty file.
2 changes: 0 additions & 2 deletions workbench/bootstrap/cache/packages.php

This file was deleted.

236 changes: 0 additions & 236 deletions workbench/bootstrap/cache/services.php

This file was deleted.

0 comments on commit 9dd987a

Please sign in to comment.