From eda6c29f243e28d34fae6a4fb2be6b53206466a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 09:03:08 +0000 Subject: [PATCH 1/7] Bump aglipanci/laravel-pint-action from 2.2.0 to 2.3.1 Bumps [aglipanci/laravel-pint-action](https://github.com/aglipanci/laravel-pint-action) from 2.2.0 to 2.3.1. - [Release notes](https://github.com/aglipanci/laravel-pint-action/releases) - [Commits](https://github.com/aglipanci/laravel-pint-action/compare/2.2.0...2.3.1) --- updated-dependencies: - dependency-name: aglipanci/laravel-pint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/fix-php-code-style-issues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 5b93749..05eb06d 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -16,7 +16,7 @@ jobs: ref: ${{ github.head_ref }} - name: Fix PHP code style issues - uses: aglipanci/laravel-pint-action@2.2.0 + uses: aglipanci/laravel-pint-action@2.3.1 - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v4 From 5ba39db6e21a20a7dd3573ea69542c47e5b8dabf Mon Sep 17 00:00:00 2001 From: Grant Holle Date: Wed, 20 Mar 2024 10:43:02 -0500 Subject: [PATCH 2/7] Add Laravel 11 support --- .gitignore | 2 + composer.json | 44 ++++++++++---- phpunit.xml.dist | 58 +++++++------------ src/Timezone.php | 4 +- src/helpers.php | 4 +- tests/Drivers/LocalTestDriver.php | 1 - tests/LocalConversionTest.php | 2 - tests/SetTimezoneTest.php | 2 - tests/TestCase.php | 7 ++- workbench/app/Models/.gitkeep | 0 .../Providers/WorkbenchServiceProvider.php | 24 ++++++++ workbench/bootstrap/.gitkeep | 0 workbench/bootstrap/app.php | 19 ++++++ workbench/database/factories/.gitkeep | 0 workbench/database/migrations/.gitkeep | 0 workbench/database/seeders/.gitkeep | 0 workbench/database/seeders/DatabaseSeeder.php | 17 ++++++ workbench/resources/views/.gitkeep | 0 workbench/routes/.gitkeep | 0 workbench/routes/console.php | 8 +++ workbench/routes/web.php | 7 +++ 21 files changed, 139 insertions(+), 60 deletions(-) create mode 100644 workbench/app/Models/.gitkeep create mode 100644 workbench/app/Providers/WorkbenchServiceProvider.php create mode 100644 workbench/bootstrap/.gitkeep create mode 100644 workbench/bootstrap/app.php create mode 100644 workbench/database/factories/.gitkeep create mode 100644 workbench/database/migrations/.gitkeep create mode 100644 workbench/database/seeders/.gitkeep create mode 100644 workbench/database/seeders/DatabaseSeeder.php create mode 100644 workbench/resources/views/.gitkeep create mode 100644 workbench/routes/.gitkeep create mode 100644 workbench/routes/console.php create mode 100644 workbench/routes/web.php diff --git a/.gitignore b/.gitignore index 83c9b9f..00771c1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ phpstan.neon testbench.yaml vendor node_modules +.phpunit.cache/test-results +phpunit.xml.dist.bak diff --git a/composer.json b/composer.json index 5ce58e3..bc56522 100644 --- a/composer.json +++ b/composer.json @@ -18,41 +18,61 @@ "require": { "php": "^8.1", "ext-intl": "*", - "illuminate/contracts": "^9.0|^10.0", - "illuminate/support": "^9.0|^10.0", + "illuminate/contracts": "^9.0|^10.0|^11.0", + "illuminate/support": "^9.0|^10.0|^11.0", "spatie/laravel-package-tools": "^1.14.0", "stevebauman/location": "^7.0" }, "require-dev": { "laravel/pint": "^1.0", - "nunomaduro/collision": "^6.0", - "nunomaduro/larastan": "^2.0.1", - "orchestra/testbench": "^7.0", - "pestphp/pest": "^1.21", - "pestphp/pest-plugin-laravel": "^1.1", + "nunomaduro/collision": "^8.0", + "orchestra/pest-plugin-testbench": "^2.0", + "orchestra/testbench": "^9.0", + "pestphp/pest": "^2.0", + "pestphp/pest-plugin-laravel": "^2.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5", "spatie/laravel-ray": "^1.26" }, "autoload": { "psr-4": { "GrantHolle\\Timezone\\": "src" }, - "files": ["src/helpers.php"] + "files": [ + "src/helpers.php" + ] }, "autoload-dev": { "psr-4": { - "GrantHolle\\Timezone\\Tests\\": "tests" + "GrantHolle\\Timezone\\Tests\\": "tests", + "Workbench\\App\\": "workbench/app/", + "Workbench\\Database\\Factories\\": "workbench/database/factories/", + "Workbench\\Database\\Seeders\\": "workbench/database/seeders/" } }, "scripts": { - "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", + "post-autoload-dump": [ + "@clear", + "@prepare", + "@php ./vendor/bin/testbench package:discover --ansi" + ], "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest --coverage", - "format": "vendor/bin/pint" + "format": "vendor/bin/pint", + "clear": "@php vendor/bin/testbench package:purge-skeleton --ansi", + "prepare": "@php vendor/bin/testbench package:discover --ansi", + "build": "@php vendor/bin/testbench workbench:build --ansi", + "serve": [ + "Composer\\Config::disableProcessTimeout", + "@build", + "@php vendor/bin/testbench serve" + ], + "lint": [ + "@php vendor/bin/pint", + "@php vendor/bin/phpstan analyse" + ] }, "config": { "sort-packages": true, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c68040f..e0cac45 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,23 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + ./src + + diff --git a/src/Timezone.php b/src/Timezone.php index ad37f5c..042d215 100755 --- a/src/Timezone.php +++ b/src/Timezone.php @@ -42,7 +42,7 @@ public function timezones(?string $timezone = null): Collection|string return $zones->get($timezone); } - public function toLocal(null|Carbon|CarbonImmutable $date, string $format = null): string|CarbonImmutable + public function toLocal(null|Carbon|CarbonImmutable $date, ?string $format = null): string|CarbonImmutable { $date = $date ?? now(); @@ -56,7 +56,7 @@ public function toLocal(null|Carbon|CarbonImmutable $date, string $format = null return $converted->format($format); } - public function toLocalFormatted(null|Carbon|CarbonImmutable $date, string $format = null): string + public function toLocalFormatted(null|Carbon|CarbonImmutable $date, ?string $format = null): string { $date = $date ?? now(); diff --git a/src/helpers.php b/src/helpers.php index f4ea05e..4724864 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -20,14 +20,14 @@ function timezone(): string * Gets a list of all timezones * or the formatted name of the given timezone */ - function timezones(string $timezone = null): Collection|string + function timezones(?string $timezone = null): Collection|string { return Timezone::timezones($timezone); } } if (!function_exists('to_local_timezone')) { - function to_local_timezone(null|Carbon\Carbon|CarbonImmutable $date, string $format = null): string + function to_local_timezone(null|Carbon\Carbon|CarbonImmutable $date, ?string $format = null): string { return Timezone::toLocalFormatted($date, $format); } diff --git a/tests/Drivers/LocalTestDriver.php b/tests/Drivers/LocalTestDriver.php index 37639ed..40a3cd3 100644 --- a/tests/Drivers/LocalTestDriver.php +++ b/tests/Drivers/LocalTestDriver.php @@ -9,7 +9,6 @@ class LocalTestDriver extends Driver { - protected function process(Request $request): Fluent|false { return new Fluent([ diff --git a/tests/LocalConversionTest.php b/tests/LocalConversionTest.php index f8caffe..29a4beb 100644 --- a/tests/LocalConversionTest.php +++ b/tests/LocalConversionTest.php @@ -5,8 +5,6 @@ use GrantHolle\Timezone\Facades\Timezone; use Illuminate\Support\Facades\Config; -uses(\Illuminate\Foundation\Testing\RefreshDatabase::class); - it('can detect user timezone', function (string $timezone) { expect(timezone())->toEqual($timezone); })->with([ diff --git a/tests/SetTimezoneTest.php b/tests/SetTimezoneTest.php index 924e763..8b62cdc 100644 --- a/tests/SetTimezoneTest.php +++ b/tests/SetTimezoneTest.php @@ -1,7 +1,5 @@ user = seedUser(['timezone' => null]); }); diff --git a/tests/TestCase.php b/tests/TestCase.php index e0e06e1..0d45ae1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,9 +7,12 @@ use GrantHolle\Timezone\TimezoneServiceProvider; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\DB; +use Orchestra\Testbench\Attributes\WithMigration; use Orchestra\Testbench\TestCase as Orchestra; use Stevebauman\Location\LocationServiceProvider; +#[WithMigration] class TestCase extends Orchestra { public User $user; @@ -32,8 +35,8 @@ protected function defineDatabaseMigrations(): void public function getEnvironmentSetUp($app): void { - config()->set('database.default', 'testing'); - config()->set('location.driver', LocalTestDriver::class); + $app['config']->set('database.default', 'testing'); + $app['config']->set('location.driver', LocalTestDriver::class); } public function defineRoutes($router) diff --git a/workbench/app/Models/.gitkeep b/workbench/app/Models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/workbench/app/Providers/WorkbenchServiceProvider.php b/workbench/app/Providers/WorkbenchServiceProvider.php new file mode 100644 index 0000000..e8cec9c --- /dev/null +++ b/workbench/app/Providers/WorkbenchServiceProvider.php @@ -0,0 +1,24 @@ +withRouting( + web: __DIR__.'/../routes/web.php', + commands: __DIR__.'/../routes/console.php', + ) + ->withMiddleware(function (Middleware $middleware) { + // + }) + ->withExceptions(function (Exceptions $exceptions) { + // + })->create(); diff --git a/workbench/database/factories/.gitkeep b/workbench/database/factories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/workbench/database/migrations/.gitkeep b/workbench/database/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/workbench/database/seeders/.gitkeep b/workbench/database/seeders/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/workbench/database/seeders/DatabaseSeeder.php b/workbench/database/seeders/DatabaseSeeder.php new file mode 100644 index 0000000..d2afce7 --- /dev/null +++ b/workbench/database/seeders/DatabaseSeeder.php @@ -0,0 +1,17 @@ +comment(Inspiring::quote()); +})->purpose('Display an inspiring quote')->hourly(); diff --git a/workbench/routes/web.php b/workbench/routes/web.php new file mode 100644 index 0000000..86a06c5 --- /dev/null +++ b/workbench/routes/web.php @@ -0,0 +1,7 @@ + Date: Wed, 20 Mar 2024 11:01:37 -0500 Subject: [PATCH 3/7] Clean up some stuff --- .github/workflows/phpstan.yml | 26 ----------------- .github/workflows/run-tests.yml | 7 +++-- .github/workflows/update-changelog.yml | 28 ------------------- composer.json | 6 +--- tests/TestCase.php | 1 - workbench/database/seeders/DatabaseSeeder.php | 1 - 6 files changed, 6 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/phpstan.yml delete mode 100644 .github/workflows/update-changelog.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index 9d41c0c..0000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: PHPStan - -on: - push: - paths: - - '**.php' - - 'phpstan.neon.dist' - -jobs: - phpstan: - name: phpstan - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - coverage: none - - - name: Install composer dependencies - uses: ramsey/composer-install@v2 - - - name: Run PHPStan - run: ./vendor/bin/phpstan --error-format=github diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d181f34..0276566 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,8 +13,8 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.2, 8.1] - laravel: [9.*, 10.*] + php: [8.2, 8.3] + laravel: [9.*, 10.*, 11.*] stability: [prefer-lowest, prefer-stable] include: - laravel: 9.* @@ -23,6 +23,9 @@ jobs: - laravel: 10.* testbench: 8.* carbon: ^2.63 + - laravel: 11.* + testbench: 9.* + carbon: ^2.63 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml deleted file mode 100644 index b20f3b6..0000000 --- a/.github/workflows/update-changelog.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: "Update Changelog" - -on: - release: - types: [released] - -jobs: - update: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - ref: main - - - name: Update Changelog - uses: stefanzweifel/changelog-updater-action@v1 - with: - latest-version: ${{ github.event.release.name }} - release-notes: ${{ github.event.release.body }} - - - name: Commit updated CHANGELOG - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: main - commit_message: Update CHANGELOG - file_pattern: CHANGELOG.md diff --git a/composer.json b/composer.json index bc56522..12808bd 100644 --- a/composer.json +++ b/composer.json @@ -30,9 +30,6 @@ "orchestra/testbench": "^9.0", "pestphp/pest": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", "spatie/laravel-ray": "^1.26" }, "autoload": { @@ -77,8 +74,7 @@ "config": { "sort-packages": true, "allow-plugins": { - "pestphp/pest-plugin": true, - "phpstan/extension-installer": true + "pestphp/pest-plugin": true } }, "extra": { diff --git a/tests/TestCase.php b/tests/TestCase.php index 0d45ae1..6d5053a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,7 +7,6 @@ use GrantHolle\Timezone\TimezoneServiceProvider; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\DB; use Orchestra\Testbench\Attributes\WithMigration; use Orchestra\Testbench\TestCase as Orchestra; use Stevebauman\Location\LocationServiceProvider; diff --git a/workbench/database/seeders/DatabaseSeeder.php b/workbench/database/seeders/DatabaseSeeder.php index d2afce7..9079f2d 100644 --- a/workbench/database/seeders/DatabaseSeeder.php +++ b/workbench/database/seeders/DatabaseSeeder.php @@ -2,7 +2,6 @@ namespace Workbench\Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder From 4bbc51b5b2bff848e1386d791ab1aaebee7e6279 Mon Sep 17 00:00:00 2001 From: Grant Holle Date: Wed, 20 Mar 2024 11:11:59 -0500 Subject: [PATCH 4/7] Try to get tests working --- .github/workflows/run-tests.yml | 2 +- composer.json | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 13a5a93..4c48370 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,7 +20,7 @@ jobs: - laravel: 9.* testbench: 7.* carbon: ^2.63 - - laravel: 10.* + - laravel: ^10.15 testbench: 8.* carbon: ^2.63 - laravel: 11.* diff --git a/composer.json b/composer.json index 12808bd..36654b6 100644 --- a/composer.json +++ b/composer.json @@ -25,11 +25,10 @@ }, "require-dev": { "laravel/pint": "^1.0", - "nunomaduro/collision": "^8.0", - "orchestra/pest-plugin-testbench": "^2.0", + "nunomaduro/collision": "^6.0|^7.0|^8.0", "orchestra/testbench": "^9.0", - "pestphp/pest": "^2.0", - "pestphp/pest-plugin-laravel": "^2.0", + "pestphp/pest": "^1.0|^2.0", + "pestphp/pest-plugin-laravel": "^1.0|^2.0", "spatie/laravel-ray": "^1.26" }, "autoload": { From 2b1c6d7bcb01d85da384434428fcdd5a34e7d981 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 09:47:06 +0000 Subject: [PATCH 5/7] Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.6.0 to 2.0.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.6.0...v2.0.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/dependabot-auto-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index ca2197d..67e66c6 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -13,7 +13,7 @@ jobs: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1.6.0 + uses: dependabot/fetch-metadata@v2.0.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" From 79e97531720b04549160651e803a93fafcf7e9dc Mon Sep 17 00:00:00 2001 From: Grant Holle Date: Mon, 25 Mar 2024 09:09:48 -0500 Subject: [PATCH 6/7] Adjust test running --- .github/workflows/run-tests.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4c48370..43dbcf2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -2,25 +2,26 @@ name: run-tests on: push: - branches: [main] - pull_request: - branches: [main] + paths: + - '**.php' + - '.github/workflows/run-tests.yml' + - 'phpunit.xml.dist' + - 'composer.json' + - 'composer.lock' jobs: test: runs-on: ${{ matrix.os }} + timeout-minutes: 5 strategy: fail-fast: true matrix: - os: [ubuntu-latest] - php: [8.2, 8.3] - laravel: [9.*, 10.*, 11.*] + os: [ubuntu-latest, windows-latest] + php: [8.3, 8.2, 8.1] + laravel: [10.*, 11.*] stability: [prefer-lowest, prefer-stable] include: - - laravel: 9.* - testbench: 7.* - carbon: ^2.63 - - laravel: ^10.15 + - laravel: 10.* testbench: 8.* carbon: ^2.63 - laravel: 11.* @@ -54,4 +55,4 @@ jobs: run: composer show -D - name: Execute tests - run: vendor/bin/pest + run: vendor/bin/pest --ci From 48d7731da4180a21555df70cc116bbd272521658 Mon Sep 17 00:00:00 2001 From: Grant Holle Date: Mon, 25 Mar 2024 09:19:08 -0500 Subject: [PATCH 7/7] Remove php 8.1 in tests --- .github/workflows/run-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 43dbcf2..d44a717 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -16,10 +16,10 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, windows-latest] - php: [8.3, 8.2, 8.1] + os: [ubuntu-latest] + php: [8.3, 8.2] laravel: [10.*, 11.*] - stability: [prefer-lowest, prefer-stable] + stability: [prefer-stable] include: - laravel: 10.* testbench: 8.*