From 2d4a1518014c517a0aad1b54153a22ac94e60f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20L=C3=B6sken?= Date: Mon, 1 Jul 2024 17:30:22 +0200 Subject: [PATCH] Fix --- phpunit.xml.dist | 25 ++++++------------------- tests/Auth/LoginTest.php | 4 +++- tests/CP/Links/LinksTest.php | 5 +++-- tests/CP/Settings/SettingsTest.php | 15 ++++++++------- tests/MagicLink/MagicLinkFormTest.php | 13 +++++++------ 5 files changed, 27 insertions(+), 35 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5ff395e..ca3afc3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,23 +1,5 @@ - - - - src/ - - + tests @@ -32,4 +14,9 @@ + + + src/ + + diff --git a/tests/Auth/LoginTest.php b/tests/Auth/LoginTest.php index 7666af1..d5a9846 100644 --- a/tests/Auth/LoginTest.php +++ b/tests/Auth/LoginTest.php @@ -4,9 +4,11 @@ namespace Codedge\MagicLink\Tests; +use PHPUnit\Framework\Attributes\Test; + class LoginTest extends TestCase { - /** @test */ + #[Test] public function can_see_magic_link_link(): void { $this->get(cp_route('login')) diff --git a/tests/CP/Links/LinksTest.php b/tests/CP/Links/LinksTest.php index e46087b..3478ce5 100644 --- a/tests/CP/Links/LinksTest.php +++ b/tests/CP/Links/LinksTest.php @@ -5,6 +5,7 @@ namespace Codedge\MagicLink\Tests\CP\Links; use Codedge\MagicLink\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class LinksTest extends TestCase { @@ -14,7 +15,7 @@ public function setUp(): void $this->signInAdmin(); } - /** @test */ + #[Test] public function can_see_links() { $this->get(cp_route('magiclink.links.index')) @@ -22,7 +23,7 @@ public function can_see_links() ->assertSee(__('magiclinks::cp.links.no_links')); } - public function cannot_see_links_when_no_permissions() + public function cannot_see_links_when_no_permissions(): void { $this->signInUser(); diff --git a/tests/CP/Settings/SettingsTest.php b/tests/CP/Settings/SettingsTest.php index 9497e13..c849a72 100644 --- a/tests/CP/Settings/SettingsTest.php +++ b/tests/CP/Settings/SettingsTest.php @@ -6,6 +6,7 @@ use Codedge\MagicLink\Repositories\SettingsRepository; use Codedge\MagicLink\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class SettingsTest extends TestCase { @@ -23,7 +24,7 @@ public function can_see_settings(): void ->assertSee(__('magiclink::cp.settings.ml_enabled')); } - /** @test */ + #[Test] public function cannot_see_settings_with_no_permissions(): void { $this->signInUser(); @@ -32,7 +33,7 @@ public function cannot_see_settings_with_no_permissions(): void ->assertRedirect(cp_route('index')); } - /** @test */ + #[Test] public function can_update_settings_without_error(): void { $payload = [ @@ -48,7 +49,7 @@ public function can_update_settings_without_error(): void ->assertSee(999); } - /** @test */ + #[Test] public function cannot_update_settings_with_all_errors(): void { $payload = [ @@ -63,7 +64,7 @@ public function cannot_update_settings_with_all_errors(): void ->assertSessionHasErrors(['enabled', 'expireTime', 'allowedAddresses.0']); } - /** @test */ + #[Test] public function cannot_update_settings_with_enabled_errors(): void { $payload = [ @@ -84,7 +85,7 @@ public function cannot_update_settings_with_enabled_errors(): void ->assertSessionHasErrors(['enabled']); } - /** @test */ + #[Test] public function cannot_update_settings_with_expire_time_errors(): void { $payload = [ @@ -105,7 +106,7 @@ public function cannot_update_settings_with_expire_time_errors(): void ->assertSessionHasErrors(['expireTime']); } - /** @test */ + #[Test] public function can_set_enabled_to_true_false(): void { $repository = $this->app->make(SettingsRepository::class); @@ -131,7 +132,7 @@ public function can_set_enabled_to_true_false(): void $this->assertFalse($repository->isEnabled()); } - /** @test */ + #[Test] public function can_set_expireTime_to_values(): void { $repository = $this->app->make(SettingsRepository::class); diff --git a/tests/MagicLink/MagicLinkFormTest.php b/tests/MagicLink/MagicLinkFormTest.php index 4d39a96..908c29b 100644 --- a/tests/MagicLink/MagicLinkFormTest.php +++ b/tests/MagicLink/MagicLinkFormTest.php @@ -9,11 +9,12 @@ use Codedge\MagicLink\Mail\MagicLink\LinkInformation; use Codedge\MagicLink\Tests\TestCase; use Illuminate\Support\Facades\Mail; +use PHPUnit\Framework\Attributes\Test; use Statamic\Facades\User; class MagicLinkFormTest extends TestCase { - /** @test */ + #[Test] public function can_show_magic_link_form(): void { $this->get(route('magiclink.show-send-link-form')) @@ -21,7 +22,7 @@ public function can_show_magic_link_form(): void ->assertSee(__('magiclink::web.back_to_classic_login')); } - /** @test */ + #[Test] public function cannot_get_link_for_invalid_address(): void { $payload = [ @@ -39,7 +40,7 @@ public function cannot_get_link_for_invalid_address(): void ->assertSessionHasErrors(['email']); } - /** @test */ + #[Test] public function can_request_link_for_non_existing_but_allowed_domain_user(): void { $this->expectsEvents([LinkCreated::class]); @@ -68,7 +69,7 @@ public function can_request_link_for_non_existing_but_allowed_domain_user(): voi ->assertSessionHas('success', __('magiclink::web.address_exists_then_email')); } - /** @test */ + #[Test] public function can_request_link_for_non_existing_and_non_allowed_user(): void { $this->doesntExpectEvents([LinkCreated::class]); @@ -82,7 +83,7 @@ public function can_request_link_for_non_existing_and_non_allowed_user(): void ->assertSessionHas('success', __('magiclink::web.address_exists_then_email')); } - /** @test */ + #[Test] public function can_request_link_for_existing_user(): void { $this->expectsEvents([LinkCreated::class]); @@ -100,7 +101,7 @@ public function can_request_link_for_existing_user(): void ->assertSessionHas('success', __('magiclink::web.address_exists_then_email')); } - /** @test */ + #[Test] public function can_sent_email_with_requested_link(): void { $user = User::make();