diff --git a/.github/workflows/fix-php-code-style.yml b/.github/workflows/fix-php-code-style.yml index 28cf707..72339e9 100644 --- a/.github/workflows/fix-php-code-style.yml +++ b/.github/workflows/fix-php-code-style.yml @@ -2,6 +2,9 @@ name: Fix PHP code style on: [push] +permissions: + contents: write + jobs: php-code-styling: runs-on: ubuntu-latest diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 22920a0..ec9ee56 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.4" + php-version: "8.5" coverage: none - name: Install composer dependencies diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6b40a0e..3fb66e0 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, windows-latest] - php: [8.2, 8.3, 8.4] - laravel: [10.*, 11.*, 12.*] + php: [8.3, 8.4, 8.5] + laravel: [12.*, 13.*] stability: [prefer-stable] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index 3e739b4..c16a623 100644 --- a/composer.json +++ b/composer.json @@ -9,9 +9,9 @@ "homepage": "https://github.com/wotzebra/filament-seo", "license": "MIT", "require": { - "php": "^8.2", + "php": "^8.3", "filament/filament": "^4.0|^5.0", - "illuminate/contracts": "^10.0|^11.0|^12.0", + "illuminate/contracts": "^12.0|^13.0", "spatie/laravel-package-tools": "^1.12", "spatie/laravel-translatable": "^6.5", "wotz/filament-media-library": "^4.0", @@ -21,8 +21,8 @@ "require-dev": { "larastan/larastan": "^2.0|^3.0", "laravel/pint": "^1.0", - "nunomaduro/collision": "^7.0|^8.0", - "orchestra/testbench": "^8.0|^9.0|^10.0", + "nunomaduro/collision": "^8.0|^9.0", + "orchestra/testbench": "^10.0|^11.0", "pestphp/pest": "^2.0|^3.0|^4.0", "pestphp/pest-plugin-laravel": "^2.0|^3.0|^4.0", "phpstan/extension-installer": "^1.1|^2.0", diff --git a/config/filament-seo.php b/config/filament-seo.php index e4c6d58..bf56829 100644 --- a/config/filament-seo.php +++ b/config/filament-seo.php @@ -1,5 +1,6 @@ [ - 'seo-route' => \Wotz\Seo\Models\SeoRoute::class, + 'seo-route' => SeoRoute::class, ], 'default' => [ 'title_og' => [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3e5f508..f035ed3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,20 +1,10 @@ - + tests - - - - - - - - - - diff --git a/src/Filament/Resources/SeoRouteResource.php b/src/Filament/Resources/SeoRouteResource.php index 3dc9aa7..b2919a8 100644 --- a/src/Filament/Resources/SeoRouteResource.php +++ b/src/Filament/Resources/SeoRouteResource.php @@ -2,10 +2,12 @@ namespace Wotz\Seo\Filament\Resources; +use Filament\Actions\EditAction; use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Resources\Resource; +use Filament\Schemas\Schema; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Model; @@ -26,7 +28,7 @@ class SeoRouteResource extends Resource protected static string|\UnitEnum|null $navigationGroup = 'SEO'; - public static function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema + public static function form(Schema $schema): Schema { return $schema->components([ TranslatableTabs::make() @@ -73,10 +75,10 @@ static function (SeoRoute $record) { ->filters([ // ]) - ->actions([ - \Filament\Actions\EditAction::make(), + ->recordActions([ + EditAction::make(), ]) - ->bulkActions([]); + ->toolbarActions([]); } public static function getPages(): array diff --git a/src/Filament/SeoCard.php b/src/Filament/SeoCard.php index ddbe5fb..7bc6de0 100644 --- a/src/Filament/SeoCard.php +++ b/src/Filament/SeoCard.php @@ -4,6 +4,8 @@ use Filament\Forms\Components\Textarea; use Filament\Infolists\Components\TextEntry; +use Filament\Schemas\Components\Group; +use Filament\Schemas\Components\Section; use Illuminate\Database\Eloquent\Model; use Wotz\MediaLibrary\Filament\AttachmentInput; use Wotz\Seo\Formats\OgImage; @@ -12,7 +14,7 @@ class SeoCard { - public static function make(string $model, ?string $locale = null): \Filament\Schemas\Components\Section + public static function make(string $model, ?string $locale = null): Section { $model = app($model); @@ -31,18 +33,18 @@ public static function make(string $model, ?string $locale = null): \Filament\Sc ->rules($tag->getRules()); }); - return \Filament\Schemas\Components\Section::make() + return Section::make() ->columns(1) ->label('Seo') ->schema([ - \Filament\Schemas\Components\Group::make([ + Group::make([ TextEntry::make('Seo') ->hiddenLabel() ->state('Seo') ->extraAttributes(['class' => 'text-2xl font-bold']), ...$fields->toArray(), ]) - ->afterStateHydrated(function (\Filament\Schemas\Components\Group $component, ?Model $record) use ($locale): void { + ->afterStateHydrated(function (Group $component, ?Model $record) use ($locale): void { $component->getChildSchema()->fill($record?->fillSeoFieldState($locale)); }) ->statePath('seoFields'), diff --git a/src/Http/Middleware/SeoMiddleware.php b/src/Http/Middleware/SeoMiddleware.php index 581f77d..3927e98 100644 --- a/src/Http/Middleware/SeoMiddleware.php +++ b/src/Http/Middleware/SeoMiddleware.php @@ -4,6 +4,7 @@ use Closure; use Illuminate\Database\Eloquent\Model; +use Illuminate\Http\Request; use Illuminate\Support\Str; use Wotz\Seo\Models\SeoRoute; use Wotz\Seo\SeoRoutes; @@ -13,7 +14,7 @@ class SeoMiddleware /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request + * @param Request $request * @return mixed */ public function handle($request, Closure $next) diff --git a/src/Models/Traits/HasSeoFields.php b/src/Models/Traits/HasSeoFields.php index eefa7cc..fe7a5fa 100644 --- a/src/Models/Traits/HasSeoFields.php +++ b/src/Models/Traits/HasSeoFields.php @@ -3,6 +3,7 @@ namespace Wotz\Seo\Models\Traits; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\MorphMany; use Wotz\Seo\Facades\SeoBuilder; use Wotz\Seo\Models\SeoField; use Wotz\Seo\SeoTags; @@ -22,7 +23,7 @@ abstract public function getSeoTags(): SeoTags; /** * Set the polymorphic relation. * - * @return \Illuminate\Database\Eloquent\Relations\MorphMany + * @return MorphMany */ public function seoFields() { diff --git a/src/Tags/OpenGraphImage.php b/src/Tags/OpenGraphImage.php index 159e1f3..47bcbb1 100644 --- a/src/Tags/OpenGraphImage.php +++ b/src/Tags/OpenGraphImage.php @@ -2,6 +2,8 @@ namespace Wotz\Seo\Tags; +use Wotz\MediaLibrary\Models\Attachment; + class OpenGraphImage extends OpenGraph { public function getContent(bool $raw = false): string @@ -16,7 +18,7 @@ public function getContent(bool $raw = false): string return $content; } - $attachment = \Wotz\MediaLibrary\Models\Attachment::find($this->content); + $attachment = Attachment::find($this->content); if (! $attachment) { return ''; diff --git a/tests/Feature/Http/Middleware/SeoMiddlewareTest.php b/tests/Feature/Http/Middleware/SeoMiddlewareTest.php index 6579a75..2677be3 100644 --- a/tests/Feature/Http/Middleware/SeoMiddlewareTest.php +++ b/tests/Feature/Http/Middleware/SeoMiddlewareTest.php @@ -5,6 +5,7 @@ use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest; use Wotz\Seo\Facades\SeoBuilder; use Wotz\Seo\Http\Middleware\SeoMiddleware; +use Wotz\Seo\Models\SeoRoute; it('will not the seo routes if no route is found', function () { Route::get('', fn () => 'route'); @@ -19,7 +20,7 @@ $route = Route::get('test', fn () => 'route') ->name('test'); - \Wotz\Seo\Models\SeoRoute::create([ + SeoRoute::create([ 'route' => 'test', 'og_type' => 'site', 'description' => 'test', diff --git a/tests/Feature/SeoBuilderTest.php b/tests/Feature/SeoBuilderTest.php index a23551f..373ce99 100644 --- a/tests/Feature/SeoBuilderTest.php +++ b/tests/Feature/SeoBuilderTest.php @@ -2,10 +2,11 @@ use Wotz\Seo\SeoBuilder; use Wotz\Seo\Tags\BaseTag; +use Wotz\Seo\Tests\Fixtures\Models\Page; beforeEach(function () { $this->seoBuilder = new SeoBuilder; - $this->page = new \Wotz\Seo\Tests\Fixtures\Models\Page; + $this->page = new Page; }); it('can add a tag', function () { diff --git a/tests/Feature/Tags/BaseTagTest.php b/tests/Feature/Tags/BaseTagTest.php index bdf259c..dace500 100644 --- a/tests/Feature/Tags/BaseTagTest.php +++ b/tests/Feature/Tags/BaseTagTest.php @@ -3,9 +3,10 @@ use Illuminate\Support\Str; use Wotz\Seo\Tags\BaseTag; use Wotz\Seo\Tags\Tag; +use Wotz\Seo\Tests\Fixtures\Models\Page; beforeEach(function () { - $this->page = new \Wotz\Seo\Tests\Fixtures\Models\Page; + $this->page = new Page; }); it('can construct a class', function () { diff --git a/tests/Feature/Tags/MetaTest.php b/tests/Feature/Tags/MetaTest.php index 7514fc1..531e214 100644 --- a/tests/Feature/Tags/MetaTest.php +++ b/tests/Feature/Tags/MetaTest.php @@ -2,13 +2,14 @@ use Wotz\Seo\Tags\Meta; use Wotz\Seo\Tags\Tag; +use Wotz\Seo\Tests\Fixtures\Models\Page; it('can construct a class', function () { - expect(new Meta(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new Meta(new Page, 'key', 'content')) ->toBeInstanceOf(Tag::class); }); it('has a meta identifier prefix', function () { - expect(new Meta(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new Meta(new Page, 'key', 'content')) ->getIdentifier()->toBe('meta_key'); }); diff --git a/tests/Feature/Tags/OgUrlTest.php b/tests/Feature/Tags/OgUrlTest.php index 2543a88..51f8004 100644 --- a/tests/Feature/Tags/OgUrlTest.php +++ b/tests/Feature/Tags/OgUrlTest.php @@ -2,13 +2,14 @@ use Wotz\Seo\Tags\OgUrl; use Wotz\Seo\Tags\Tag; +use Wotz\Seo\Tests\Fixtures\Models\Page; it('can construct a class', function () { - expect(new OgUrl(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OgUrl(new Page, 'key', 'content')) ->toBeInstanceOf(Tag::class); }); it('has a meta identifier prefix', function () { - expect(new OgUrl(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OgUrl(new Page, 'key', 'content')) ->getContent()->toBe('http://localhost'); }); diff --git a/tests/Feature/Tags/OpenGraphImageTest.php b/tests/Feature/Tags/OpenGraphImageTest.php index 33cbaf2..e0d271b 100644 --- a/tests/Feature/Tags/OpenGraphImageTest.php +++ b/tests/Feature/Tags/OpenGraphImageTest.php @@ -2,30 +2,31 @@ use Wotz\Seo\Tags\OpenGraphImage; use Wotz\Seo\Tags\Tag; +use Wotz\Seo\Tests\Fixtures\Models\Page; it('can construct a class', function () { - expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OpenGraphImage(new Page, 'key', 'content')) ->toBeInstanceOf(Tag::class); }); it('will return content as is in the beforeSave', function () { $content = fake()->realTextBetween(280, 300); - expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', $content)) + expect(new OpenGraphImage(new Page, 'key', $content)) ->beforeSave($content)->toBe($content); }); it('returns empty string if content is null', function () { - expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', null)) + expect(new OpenGraphImage(new Page, 'key', null)) ->getContent()->toBe(''); }); it('can return the raw content', function () { - expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OpenGraphImage(new Page, 'key', 'content')) ->getContent(true)->toBe(''); }); it('can return the content', function () { - expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OpenGraphImage(new Page, 'key', 'content')) ->getContent()->toBe(''); }); diff --git a/tests/Feature/Tags/OpenGraphTest.php b/tests/Feature/Tags/OpenGraphTest.php index 857be90..06afe10 100644 --- a/tests/Feature/Tags/OpenGraphTest.php +++ b/tests/Feature/Tags/OpenGraphTest.php @@ -2,23 +2,24 @@ use Wotz\Seo\Tags\OpenGraph; use Wotz\Seo\Tags\Tag; +use Wotz\Seo\Tests\Fixtures\Models\Page; it('can construct a class', function () { - expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OpenGraph(new Page, 'key', 'content')) ->toBeInstanceOf(Tag::class); }); it('has an attribute', function () { - expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OpenGraph(new Page, 'key', 'content')) ->render()->toBe(''); }); it('has an og: prefix', function () { - expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OpenGraph(new Page, 'key', 'content')) ->getPrefixedKey()->toBe('og:key'); }); it('has an og_ identifier prefix', function () { - expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content')) + expect(new OpenGraph(new Page, 'key', 'content')) ->getIdentifier()->toBe('og_key'); }); diff --git a/tests/Pest.php b/tests/Pest.php index 73447ca..d28b713 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,6 @@ in('Feature'); +uses(TestCase::class, RefreshDatabase::class)->in('Feature');