From 2d2452728fffa4a49718b588c5bbcd177b4845df Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Fri, 26 Apr 2024 11:01:38 -0300 Subject: [PATCH] Add support laravel 11 --- .github/workflows/tests.yml | 26 +++++++++++++++++--------- composer.json | 16 +++++++--------- tests/CustomValuesTest.php | 9 +++++++-- tests/TestCase.php | 9 ++++++--- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c868886..4c5c839 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,26 +10,32 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [7.4, 8.0, 8.1] - laravel: [^8.0, ^9.0, ^10.0] + php: [7.4, 8.0, 8.1, 8.2] + laravel: [^8.0, ^9.0, ^10.0, ^11.0] #stability: [prefer-lowest, prefer-stable] stability: [prefer-stable] exclude: - php: 7.4 - laravel: 9 + laravel: ^9.0 - php: 7.4 - laravel: 10 + laravel: ^10.0 + - php: 7.4 + laravel: ^11.0 + - php: 8.0 + laravel: ^10.0 - php: 8.0 - laravel: 10 + laravel: ^11.0 + - php: 8.1 + laravel: ^11.0 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} @@ -45,7 +51,9 @@ jobs: run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-suggest - name: Execute tests - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit - name: Coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/composer.json b/composer.json index 4331c0c..8696135 100644 --- a/composer.json +++ b/composer.json @@ -24,15 +24,14 @@ "php": "^7.4|^8.0", "datalogix/laravel-translation": "^1.1|^2.0", "datalogix/laravel-validation": "^1.3|^2.0", - "illuminate/contracts": "^8.0|^9.0|^10.0", - "illuminate/database": "^8.0|^9.0|^10.0", - "illuminate/pagination": "^8.0|^9.0|^10.0", - "illuminate/support": "^8.0|^9.0|^10.0" + "illuminate/contracts": "^8.0|^9.0|^10.0|^11.0", + "illuminate/database": "^8.0|^9.0|^10.0|^11.0", + "illuminate/pagination": "^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0" }, "require-dev": { - "graham-campbell/testbench": "^6.0", - "phpunit/phpunit": "^9.5|^10.0", - "spatie/phpunit-watcher": "^1.23" + "graham-campbell/testbench": "^6.1", + "phpunit/phpunit": "^9.5|^10.5" }, "autoload": { "psr-4": { @@ -48,8 +47,7 @@ } }, "scripts": { - "test": "vendor/bin/phpunit", - "watch": "vendor/bin/phpunit-watcher watch" + "test": "vendor/bin/phpunit" }, "extra": { "laravel": { diff --git a/tests/CustomValuesTest.php b/tests/CustomValuesTest.php index 3a870d8..effae91 100644 --- a/tests/CustomValuesTest.php +++ b/tests/CustomValuesTest.php @@ -2,13 +2,14 @@ namespace Datalogix\Utils\Tests; +use Carbon\Carbon; use Datalogix\Utils\Http\Middleware\HttpsProtocolMiddleware; use Illuminate\Contracts\Http\Kernel; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Builder; use Illuminate\Pagination\Paginator; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\URL; +use Illuminate\Support\Str; class CustomValuesTest extends TestCase { @@ -47,8 +48,12 @@ public function testModelUnguarded() public function testLocale() { $this->app->setLocale('en'); + $this->assertEquals('en', Carbon::getLocale()); + $this->assertEquals('january', Str::lower(Carbon::parse('2020-01-01')->getTranslatedMonthName())); - $this->assertEquals('01 January 2020', Carbon::parse('2020-01-01')->formatLocalized('%d %B %Y')); + $this->app->setLocale('pt_BR'); + $this->assertEquals('pt_BR', Carbon::getLocale()); + $this->assertEquals('janeiro', Str::lower(Carbon::parse('2020-01-01')->getTranslatedMonthName())); } public function testSchemaDefaultStringLength() diff --git a/tests/TestCase.php b/tests/TestCase.php index 7dccddc..db341ef 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,16 +2,19 @@ namespace Datalogix\Utils\Tests; +use Carbon\Laravel\ServiceProvider as CarbonServiceProvider; use Datalogix\Utils\UtilsServiceProvider; use GrahamCampbell\TestBench\AbstractPackageTestCase; abstract class TestCase extends AbstractPackageTestCase { - /** - * Get the service provider class. - */ protected static function getServiceProviderClass(): string { return UtilsServiceProvider::class; } + + protected static function getRequiredServiceProviders(): array + { + return [CarbonServiceProvider::class]; + } }