diff --git a/tests/Feature/Concerns/HasDynamicLinkTest.php b/tests/Feature/Concerns/HasDynamicLinkTest.php index cfcf461..2b32081 100644 --- a/tests/Feature/Concerns/HasDynamicLinkTest.php +++ b/tests/Feature/Concerns/HasDynamicLinkTest.php @@ -2,6 +2,7 @@ namespace Esign\Linkable\Tests\Feature\Concerns; +use PHPUnit\Framework\Attributes\Test; use Esign\Linkable\Concerns\HasDynamicLink; use Esign\Linkable\Tests\Support\Models\MenuItem; use Esign\Linkable\Tests\Support\Models\ModelWithRegularMorphToRelation; @@ -11,7 +12,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Support\Facades\Schema; -class HasDynamicLinkTest extends TestCase +final class HasDynamicLinkTest extends TestCase { use DatabaseMigrations; @@ -34,8 +35,8 @@ protected function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_can_check_if_it_has_an_internal_link() + #[Test] + public function it_can_check_if_it_has_an_internal_link(): void { $post = Post::create(['title' => 'Hello World']); $menuItemA = MenuItem::create([ @@ -53,8 +54,8 @@ public function it_can_check_if_it_has_an_internal_link() $this->assertFalse($menuItemB->hasDynamicLink()); } - /** @test */ - public function it_can_check_if_it_has_an_external_link() + #[Test] + public function it_can_check_if_it_has_an_external_link(): void { $menuItemA = MenuItem::create([ 'dynamic_link_type' => HasDynamicLink::$linkTypeExternal, @@ -71,8 +72,8 @@ public function it_can_check_if_it_has_an_external_link() $this->assertFalse($menuItemB->hasDynamicLink()); } - /** @test */ - public function it_can_get_an_internal_link() + #[Test] + public function it_can_get_an_internal_link(): void { $post = Post::create(['title' => 'Hello World']); $menuItemA = MenuItem::create([ @@ -90,8 +91,8 @@ public function it_can_get_an_internal_link() $this->assertNull($menuItemB->dynamicLink()); } - /** @test */ - public function it_can_get_null_as_a_link_when_the_link_type_isnt_internal_or_external() + #[Test] + public function it_can_get_null_as_a_link_when_the_link_type_isnt_internal_or_external(): void { $menuItem = MenuItem::create([ 'dynamic_link_type' => null, @@ -102,8 +103,8 @@ public function it_can_get_null_as_a_link_when_the_link_type_isnt_internal_or_ex $this->assertNull($menuItem->dynamicLink()); } - /** @test */ - public function it_can_get_an_external_url() + #[Test] + public function it_can_get_an_external_url(): void { $post = Post::create(['title' => 'Hello World']); $menuItemA = MenuItem::create([ @@ -121,8 +122,8 @@ public function it_can_get_an_external_url() $this->assertNull($menuItemB->dynamicLink()); } - /** @test */ - public function it_can_check_if_a_link_is_of_type() + #[Test] + public function it_can_check_if_a_link_is_of_type(): void { $menuItem = MenuItem::create([ 'dynamic_link_type' => HasDynamicLink::$linkTypeExternal, @@ -136,8 +137,8 @@ public function it_can_check_if_a_link_is_of_type() $this->assertFalse($menuItem->dynamicLinkIsOfType([HasDynamicLink::$linkTypeInternal])); } - /** @test */ - public function it_can_get_the_dynamic_link_type() + #[Test] + public function it_can_get_the_dynamic_link_type(): void { $menuItem = MenuItem::create([ 'dynamic_link_type' => HasDynamicLink::$linkTypeExternal, @@ -148,8 +149,8 @@ public function it_can_get_the_dynamic_link_type() $this->assertEquals(HasDynamicLink::$linkTypeExternal, $menuItem->dynamicLinkType()); } - /** @test */ - public function it_can_get_the_dynamic_link_url() + #[Test] + public function it_can_get_the_dynamic_link_url(): void { $menuItem = MenuItem::create([ 'dynamic_link_type' => HasDynamicLink::$linkTypeExternal, @@ -160,8 +161,8 @@ public function it_can_get_the_dynamic_link_url() $this->assertEquals('http://localhost', $menuItem->dynamicLinkUrl()); } - /** @test */ - public function it_can_use_a_regular_morph_to_relation() + #[Test] + public function it_can_use_a_regular_morph_to_relation(): void { $post = Post::create(['title' => 'Hello World']); $menuItem = ModelWithRegularMorphToRelation::create([ diff --git a/tests/Feature/Relations/SingleColumnMorphToTest.php b/tests/Feature/Relations/SingleColumnMorphToTest.php index e9f6922..890d19a 100644 --- a/tests/Feature/Relations/SingleColumnMorphToTest.php +++ b/tests/Feature/Relations/SingleColumnMorphToTest.php @@ -2,6 +2,7 @@ namespace Esign\Linkable\Tests\Feature\Relations; +use PHPUnit\Framework\Attributes\Test; use Error; use Esign\Linkable\Tests\Support\Models\MenuItem; use Esign\Linkable\Tests\Support\Models\Post; @@ -9,12 +10,12 @@ use Illuminate\Foundation\Testing\DatabaseMigrations; use PDOException; -class SingleColumnMorphToTest extends TestCase +final class SingleColumnMorphToTest extends TestCase { use DatabaseMigrations; - /** @test */ - public function it_can_query_a_related_model() + #[Test] + public function it_can_query_a_related_model(): void { $post = Post::create(['title' => 'Hello World']); $menuItem = MenuItem::create(['dynamic_link_linkable_model' => "post:{$post->id}"]); @@ -22,24 +23,24 @@ public function it_can_query_a_related_model() $this->assertTrue($menuItem->dynamicLinkLinkable->is($post)); } - /** @test */ - public function it_can_return_null_if_a_related_model_does_not_exist() + #[Test] + public function it_can_return_null_if_a_related_model_does_not_exist(): void { $menuItem = MenuItem::create(['dynamic_link_linkable_model' => "post:non-existing-id"]); $this->assertNull($menuItem->dynamicLinkLinkable); } - /** @test */ - public function it_can_return_null_if_the_foreign_key_is_null() + #[Test] + public function it_can_return_null_if_the_foreign_key_is_null(): void { $menuItem = MenuItem::create(['dynamic_link_linkable_model' => null]); $this->assertNull($menuItem->dynamicLinkLinkable); } - /** @test */ - public function it_can_throw_an_exception_if_the_foreign_key_is_empty() + #[Test] + public function it_can_throw_an_exception_if_the_foreign_key_is_empty(): void { $this->expectException(PDOException::class); @@ -48,8 +49,8 @@ public function it_can_throw_an_exception_if_the_foreign_key_is_empty() $this->assertNull($menuItem->dynamicLinkLinkable); } - /** @test */ - public function it_can_throw_an_exception_if_the_model_does_not_exist() + #[Test] + public function it_can_throw_an_exception_if_the_model_does_not_exist(): void { $this->expectException(Error::class); $this->expectExceptionMessage('Class "article" not found'); @@ -58,8 +59,8 @@ public function it_can_throw_an_exception_if_the_model_does_not_exist() $this->assertNull($menuItem->dynamicLinkLinkable); } - /** @test */ - public function it_can_eager_load_related_models() + #[Test] + public function it_can_eager_load_related_models(): void { $postA = Post::create(['title' => 'Hello World']); $postB = Post::create(['title' => 'Hello World 2']); @@ -72,8 +73,8 @@ public function it_can_eager_load_related_models() $this->assertTrue($menuItemLinkables->contains($postB)); } - /** @test */ - public function it_can_associate_a_model() + #[Test] + public function it_can_associate_a_model(): void { $post = Post::create(['title' => 'Hello World']); $menuItem = MenuItem::create(['dynamic_link_linkable_model' => null]); @@ -83,8 +84,8 @@ public function it_can_associate_a_model() $this->assertTrue($menuItem->dynamicLinkLinkable->is($post)); } - /** @test */ - public function it_can_associate_a_null_value() + #[Test] + public function it_can_associate_a_null_value(): void { $post = Post::create(['title' => 'Hello World']); $menuItem = MenuItem::create(['dynamic_link_linkable_model' => "post:{$post->id}"]); @@ -94,8 +95,8 @@ public function it_can_associate_a_null_value() $this->assertNull($menuItem->dynamicLinkLinkable); } - /** @test */ - public function it_can_dissociate_a_model() + #[Test] + public function it_can_dissociate_a_model(): void { $post = Post::create(['title' => 'Hello World']); $menuItem = MenuItem::create(['dynamic_link_linkable_model' => "post:{$post->id}"]); diff --git a/tests/Feature/View/Components/DynamicLinkTest.php b/tests/Feature/View/Components/DynamicLinkTest.php index 2bfcc4c..d727b58 100644 --- a/tests/Feature/View/Components/DynamicLinkTest.php +++ b/tests/Feature/View/Components/DynamicLinkTest.php @@ -2,6 +2,7 @@ namespace Esign\Linkable\Tests\Feature\View\Components; +use PHPUnit\Framework\Attributes\Test; use Esign\Linkable\Concerns\HasDynamicLink; use Esign\Linkable\Tests\Support\Models\MenuItem; use Esign\Linkable\Tests\Support\Models\ModelWithoutDynamicLinkTrait; @@ -10,12 +11,12 @@ use Illuminate\Foundation\Testing\Concerns\InteractsWithViews; use Illuminate\View\ViewException; -class DynamicLinkTest extends TestCase +final class DynamicLinkTest extends TestCase { use InteractsWithViews; - /** @test */ - public function it_can_render_the_view_for_an_external_link() + #[Test] + public function it_can_render_the_view_for_an_external_link(): void { $menuItem = MenuItem::create([ 'dynamic_link_type' => HasDynamicLink::$linkTypeExternal, @@ -34,8 +35,8 @@ public function it_can_render_the_view_for_an_external_link() ); } - /** @test */ - public function it_can_render_the_view_for_an_internal_link() + #[Test] + public function it_can_render_the_view_for_an_internal_link(): void { $post = Post::create(['title' => 'Hello World']); $menuItem = MenuItem::create([ @@ -55,8 +56,8 @@ public function it_can_render_the_view_for_an_internal_link() ); } - /** @test */ - public function it_can_render_null_for_a_non_existing_dynamic_link_type() + #[Test] + public function it_can_render_null_for_a_non_existing_dynamic_link_type(): void { $menuItem = MenuItem::create([ 'dynamic_link_type' => 'non-existing-link-type', @@ -72,8 +73,8 @@ public function it_can_render_null_for_a_non_existing_dynamic_link_type() $component->assertSee(null); } - /** @test */ - public function it_can_throw_an_exception_when_given_a_model_that_does_not_implement_the_dynamic_link_trait() + #[Test] + public function it_can_throw_an_exception_when_given_a_model_that_does_not_implement_the_dynamic_link_trait(): void { $this->expectException(ViewException::class); $this->expectExceptionMessage(sprintf(