From 1536fe03c991efcca02fdf56780c763e9a9382ed Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Sun, 15 Sep 2024 20:33:47 -0400 Subject: [PATCH 1/4] Adding updates to tests --- tests/Browser/ConfirmPasswordTest.php | 2 +- tests/Browser/ForgotPasswordTest.php | 2 +- tests/Browser/LogoutTest.php | 0 tests/Browser/Pages/ConfirmPassword.php | 2 +- tests/Browser/Pages/Login.php | 2 +- tests/Browser/Pages/PasswordResetRequest.php | 2 +- tests/Browser/Pages/Register.php | 2 +- tests/Browser/Pages/TwoFactorAuth.php | 2 +- tests/Browser/Pages/TwoFactorChallenge.php | 2 +- tests/Browser/Pages/VerifyEmail.php | 2 +- tests/Browser/RegisterTest.php | 2 +- tests/Browser/Traits.php | 2 +- tests/Browser/TwoFactorAuthTest.php | 2 +- tests/Browser/TwoFactorChallengeTest.php | 2 +- tests/Browser/VerifyEmailTest.php | 2 +- tests/Datasets/Urls.php | 2 +- tests/DuskTestCase.php | 9 ++------- tests/Pest.php | 13 +++++-------- tests/TestCase.php | 8 +------- 19 files changed, 23 insertions(+), 37 deletions(-) delete mode 100644 tests/Browser/LogoutTest.php diff --git a/tests/Browser/ConfirmPasswordTest.php b/tests/Browser/ConfirmPasswordTest.php index a3fdfa6..1435092 100644 --- a/tests/Browser/ConfirmPasswordTest.php +++ b/tests/Browser/ConfirmPasswordTest.php @@ -52,4 +52,4 @@ ->clickAndWaitForReload('@submit-button') ->assertSee('Test Confirmed'); }); -}); +}); \ No newline at end of file diff --git a/tests/Browser/ForgotPasswordTest.php b/tests/Browser/ForgotPasswordTest.php index b977a4f..67682bc 100644 --- a/tests/Browser/ForgotPasswordTest.php +++ b/tests/Browser/ForgotPasswordTest.php @@ -70,4 +70,4 @@ ->waitFor('@auth-login') ->assertPathIs('/auth/login'); }); -}); +}); \ No newline at end of file diff --git a/tests/Browser/LogoutTest.php b/tests/Browser/LogoutTest.php deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Browser/Pages/ConfirmPassword.php b/tests/Browser/Pages/ConfirmPassword.php index 2a85bd1..7b1a8e9 100644 --- a/tests/Browser/Pages/ConfirmPassword.php +++ b/tests/Browser/Pages/ConfirmPassword.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/password/confirm'; } -} +} \ No newline at end of file diff --git a/tests/Browser/Pages/Login.php b/tests/Browser/Pages/Login.php index ab9ddff..800244b 100644 --- a/tests/Browser/Pages/Login.php +++ b/tests/Browser/Pages/Login.php @@ -27,4 +27,4 @@ public function formLoginAsJohnDoe(Browser $browser) return $this; } -} +} \ No newline at end of file diff --git a/tests/Browser/Pages/PasswordResetRequest.php b/tests/Browser/Pages/PasswordResetRequest.php index 3834074..3aa986f 100644 --- a/tests/Browser/Pages/PasswordResetRequest.php +++ b/tests/Browser/Pages/PasswordResetRequest.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/password/reset'; } -} +} \ No newline at end of file diff --git a/tests/Browser/Pages/Register.php b/tests/Browser/Pages/Register.php index 3c4a306..e14fe1e 100644 --- a/tests/Browser/Pages/Register.php +++ b/tests/Browser/Pages/Register.php @@ -43,4 +43,4 @@ public function assertUserReceivedEmail() return $mail->hasTo($user->email); }); } -} +} \ No newline at end of file diff --git a/tests/Browser/Pages/TwoFactorAuth.php b/tests/Browser/Pages/TwoFactorAuth.php index 5da8ef3..6546c38 100644 --- a/tests/Browser/Pages/TwoFactorAuth.php +++ b/tests/Browser/Pages/TwoFactorAuth.php @@ -13,4 +13,4 @@ public function url(): string { return '/user/two-factor-authentication'; } -} +} \ No newline at end of file diff --git a/tests/Browser/Pages/TwoFactorChallenge.php b/tests/Browser/Pages/TwoFactorChallenge.php index f778491..4840914 100644 --- a/tests/Browser/Pages/TwoFactorChallenge.php +++ b/tests/Browser/Pages/TwoFactorChallenge.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/two-factor-challenge'; } -} +} \ No newline at end of file diff --git a/tests/Browser/Pages/VerifyEmail.php b/tests/Browser/Pages/VerifyEmail.php index 8da865d..fea562e 100644 --- a/tests/Browser/Pages/VerifyEmail.php +++ b/tests/Browser/Pages/VerifyEmail.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/verify'; } -} +} \ No newline at end of file diff --git a/tests/Browser/RegisterTest.php b/tests/Browser/RegisterTest.php index 09279ff..7df391c 100644 --- a/tests/Browser/RegisterTest.php +++ b/tests/Browser/RegisterTest.php @@ -64,4 +64,4 @@ }); }); -// Add more tests to test when the Name field is shown on the register page, or if the user keeps the password on a separate screen +// Add more tests to test when the Name field is shown on the register page, or if the user keeps the password on a separate screen \ No newline at end of file diff --git a/tests/Browser/Traits.php b/tests/Browser/Traits.php index f1dc961..24a724e 100644 --- a/tests/Browser/Traits.php +++ b/tests/Browser/Traits.php @@ -10,4 +10,4 @@ public function disableEmailVerification() { Config::set('devdojo.auth.settings.registration_require_email_verification', false); } -} +} \ No newline at end of file diff --git a/tests/Browser/TwoFactorAuthTest.php b/tests/Browser/TwoFactorAuthTest.php index bd61e69..8514f23 100644 --- a/tests/Browser/TwoFactorAuthTest.php +++ b/tests/Browser/TwoFactorAuthTest.php @@ -27,4 +27,4 @@ ->assertSee('Finish enabling two factor authentication'); }); $this->resetConfig(); -}); +}); \ No newline at end of file diff --git a/tests/Browser/TwoFactorChallengeTest.php b/tests/Browser/TwoFactorChallengeTest.php index 7ad9359..596f8a8 100644 --- a/tests/Browser/TwoFactorChallengeTest.php +++ b/tests/Browser/TwoFactorChallengeTest.php @@ -25,4 +25,4 @@ ->assertPathIs('/auth/two-factor-challenge'); }); $this->resetConfig(); -}); +}); \ No newline at end of file diff --git a/tests/Browser/VerifyEmailTest.php b/tests/Browser/VerifyEmailTest.php index 55f1f9d..52d9836 100644 --- a/tests/Browser/VerifyEmailTest.php +++ b/tests/Browser/VerifyEmailTest.php @@ -52,4 +52,4 @@ }); $this->resetConfig(); -}); +}); \ No newline at end of file diff --git a/tests/Datasets/Urls.php b/tests/Datasets/Urls.php index 9673208..a98f8b1 100644 --- a/tests/Datasets/Urls.php +++ b/tests/Datasets/Urls.php @@ -6,4 +6,4 @@ '/auth/verify', '/auth/password/reset', '/auth/password/SomeReallyLongtoken', -]); +]); \ No newline at end of file diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index e2e8590..9bf19b8 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -6,6 +6,7 @@ use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\RemoteWebDriver; +use Illuminate\Support\Collection; use Laravel\Dusk\TestCase as BaseTestCase; use PHPUnit\Framework\Attributes\BeforeClass; @@ -13,12 +14,6 @@ abstract class DuskTestCase extends BaseTestCase { use UsesDuskApiConfig; - // protected function setUp(): void - // { - // // $this->resetConfig(); - // parent::setUp(); - // } - /** * Prepare for Dusk test execution. */ @@ -26,7 +21,7 @@ abstract class DuskTestCase extends BaseTestCase public static function prepare(): void { if (! static::runningInSail()) { - static::startChromeDriver(); + static::startChromeDriver(['--port=9515']); } } diff --git a/tests/Pest.php b/tests/Pest.php index 50e4fe7..2966726 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -5,8 +5,6 @@ // Illuminate\Foundation\Testing\DatabaseMigrations::class, )->in('Browser'); -use Illuminate\Foundation\Testing\RefreshDatabase; - /* |-------------------------------------------------------------------------- | Test Case @@ -14,14 +12,13 @@ | | The closure you provide to your test functions is always bound to a specific PHPUnit test | case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may -| need to change it using the "uses()" function to bind a different classes or traits. +| need to change it using the "pest()" function to bind a different classes or traits. | */ -uses( - Tests\TestCase::class, - RefreshDatabase::class, -)->in('Feature'); +pest()->extend(Tests\TestCase::class) + ->use(Illuminate\Foundation\Testing\RefreshDatabase::class) + ->in('Feature'); /* |-------------------------------------------------------------------------- @@ -72,4 +69,4 @@ function createUser($data) function withANewUser() { return test()->actingAs(User::factory()->create()); -} +} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index f1ac0a1..fe1ffc2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,14 +3,8 @@ namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; -use Illuminate\Support\Facades\Artisan; abstract class TestCase extends BaseTestCase { - protected function setUp(): void - { - parent::setUp(); - Artisan::call('view:clear'); - - } + // } From 5bb827075996a20b9be5e26de945d376a237f33b Mon Sep 17 00:00:00 2001 From: tnylea Date: Mon, 16 Sep 2024 00:34:18 +0000 Subject: [PATCH 2/4] Fixes coding style --- src/Actions/TwoFactorAuth/GenerateQrCodeAndSecretKey.php | 4 ++-- src/AuthServiceProvider.php | 2 +- src/Traits/HasConfigs.php | 2 +- tests/Browser/ConfirmPasswordTest.php | 2 +- tests/Browser/ForgotPasswordTest.php | 2 +- tests/Browser/Pages/ConfirmPassword.php | 2 +- tests/Browser/Pages/Login.php | 2 +- tests/Browser/Pages/PasswordResetRequest.php | 2 +- tests/Browser/Pages/Register.php | 2 +- tests/Browser/Pages/TwoFactorAuth.php | 2 +- tests/Browser/Pages/TwoFactorChallenge.php | 2 +- tests/Browser/Pages/VerifyEmail.php | 2 +- tests/Browser/RegisterTest.php | 2 +- tests/Browser/Traits.php | 2 +- tests/Browser/TwoFactorAuthTest.php | 2 +- tests/Browser/TwoFactorChallengeTest.php | 2 +- tests/Browser/VerifyEmailTest.php | 2 +- tests/Datasets/Urls.php | 2 +- tests/DuskTestCase.php | 1 - tests/Pest.php | 2 +- 20 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/Actions/TwoFactorAuth/GenerateQrCodeAndSecretKey.php b/src/Actions/TwoFactorAuth/GenerateQrCodeAndSecretKey.php index a4860df..af3227c 100644 --- a/src/Actions/TwoFactorAuth/GenerateQrCodeAndSecretKey.php +++ b/src/Actions/TwoFactorAuth/GenerateQrCodeAndSecretKey.php @@ -21,7 +21,7 @@ class GenerateQrCodeAndSecretKey public function __invoke($user): array { - $google2fa = new Google2FA(); + $google2fa = new Google2FA; $secret_key = $google2fa->generateSecretKey(); $this->companyName = 'Auth'; @@ -38,7 +38,7 @@ public function __invoke($user): array $writer = new Writer( new ImageRenderer( new RendererStyle(800), - new ImagickImageBackEnd() + new ImagickImageBackEnd ) ); diff --git a/src/AuthServiceProvider.php b/src/AuthServiceProvider.php index 4e0e185..081c5ed 100644 --- a/src/AuthServiceProvider.php +++ b/src/AuthServiceProvider.php @@ -144,7 +144,7 @@ public function register() // Bind a singleton for the Google2FA service $this->app->singleton(Google2FA::class, function ($app) { - return new Google2FA(); + return new Google2FA; }); // Register the DuskServiceProvider diff --git a/src/Traits/HasConfigs.php b/src/Traits/HasConfigs.php index 38f5bfb..6220b2b 100644 --- a/src/Traits/HasConfigs.php +++ b/src/Traits/HasConfigs.php @@ -30,7 +30,7 @@ private function arrayToObject($array) return $array; } - $object = new \stdClass(); + $object = new \stdClass; foreach ($array as $key => $value) { $object->$key = $this->arrayToObject($value); } diff --git a/tests/Browser/ConfirmPasswordTest.php b/tests/Browser/ConfirmPasswordTest.php index 1435092..a3fdfa6 100644 --- a/tests/Browser/ConfirmPasswordTest.php +++ b/tests/Browser/ConfirmPasswordTest.php @@ -52,4 +52,4 @@ ->clickAndWaitForReload('@submit-button') ->assertSee('Test Confirmed'); }); -}); \ No newline at end of file +}); diff --git a/tests/Browser/ForgotPasswordTest.php b/tests/Browser/ForgotPasswordTest.php index 67682bc..b977a4f 100644 --- a/tests/Browser/ForgotPasswordTest.php +++ b/tests/Browser/ForgotPasswordTest.php @@ -70,4 +70,4 @@ ->waitFor('@auth-login') ->assertPathIs('/auth/login'); }); -}); \ No newline at end of file +}); diff --git a/tests/Browser/Pages/ConfirmPassword.php b/tests/Browser/Pages/ConfirmPassword.php index 7b1a8e9..2a85bd1 100644 --- a/tests/Browser/Pages/ConfirmPassword.php +++ b/tests/Browser/Pages/ConfirmPassword.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/password/confirm'; } -} \ No newline at end of file +} diff --git a/tests/Browser/Pages/Login.php b/tests/Browser/Pages/Login.php index 800244b..ab9ddff 100644 --- a/tests/Browser/Pages/Login.php +++ b/tests/Browser/Pages/Login.php @@ -27,4 +27,4 @@ public function formLoginAsJohnDoe(Browser $browser) return $this; } -} \ No newline at end of file +} diff --git a/tests/Browser/Pages/PasswordResetRequest.php b/tests/Browser/Pages/PasswordResetRequest.php index 3aa986f..3834074 100644 --- a/tests/Browser/Pages/PasswordResetRequest.php +++ b/tests/Browser/Pages/PasswordResetRequest.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/password/reset'; } -} \ No newline at end of file +} diff --git a/tests/Browser/Pages/Register.php b/tests/Browser/Pages/Register.php index e14fe1e..3c4a306 100644 --- a/tests/Browser/Pages/Register.php +++ b/tests/Browser/Pages/Register.php @@ -43,4 +43,4 @@ public function assertUserReceivedEmail() return $mail->hasTo($user->email); }); } -} \ No newline at end of file +} diff --git a/tests/Browser/Pages/TwoFactorAuth.php b/tests/Browser/Pages/TwoFactorAuth.php index 6546c38..5da8ef3 100644 --- a/tests/Browser/Pages/TwoFactorAuth.php +++ b/tests/Browser/Pages/TwoFactorAuth.php @@ -13,4 +13,4 @@ public function url(): string { return '/user/two-factor-authentication'; } -} \ No newline at end of file +} diff --git a/tests/Browser/Pages/TwoFactorChallenge.php b/tests/Browser/Pages/TwoFactorChallenge.php index 4840914..f778491 100644 --- a/tests/Browser/Pages/TwoFactorChallenge.php +++ b/tests/Browser/Pages/TwoFactorChallenge.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/two-factor-challenge'; } -} \ No newline at end of file +} diff --git a/tests/Browser/Pages/VerifyEmail.php b/tests/Browser/Pages/VerifyEmail.php index fea562e..8da865d 100644 --- a/tests/Browser/Pages/VerifyEmail.php +++ b/tests/Browser/Pages/VerifyEmail.php @@ -13,4 +13,4 @@ public function url(): string { return '/auth/verify'; } -} \ No newline at end of file +} diff --git a/tests/Browser/RegisterTest.php b/tests/Browser/RegisterTest.php index 7df391c..09279ff 100644 --- a/tests/Browser/RegisterTest.php +++ b/tests/Browser/RegisterTest.php @@ -64,4 +64,4 @@ }); }); -// Add more tests to test when the Name field is shown on the register page, or if the user keeps the password on a separate screen \ No newline at end of file +// Add more tests to test when the Name field is shown on the register page, or if the user keeps the password on a separate screen diff --git a/tests/Browser/Traits.php b/tests/Browser/Traits.php index 24a724e..f1dc961 100644 --- a/tests/Browser/Traits.php +++ b/tests/Browser/Traits.php @@ -10,4 +10,4 @@ public function disableEmailVerification() { Config::set('devdojo.auth.settings.registration_require_email_verification', false); } -} \ No newline at end of file +} diff --git a/tests/Browser/TwoFactorAuthTest.php b/tests/Browser/TwoFactorAuthTest.php index 8514f23..bd61e69 100644 --- a/tests/Browser/TwoFactorAuthTest.php +++ b/tests/Browser/TwoFactorAuthTest.php @@ -27,4 +27,4 @@ ->assertSee('Finish enabling two factor authentication'); }); $this->resetConfig(); -}); \ No newline at end of file +}); diff --git a/tests/Browser/TwoFactorChallengeTest.php b/tests/Browser/TwoFactorChallengeTest.php index 596f8a8..7ad9359 100644 --- a/tests/Browser/TwoFactorChallengeTest.php +++ b/tests/Browser/TwoFactorChallengeTest.php @@ -25,4 +25,4 @@ ->assertPathIs('/auth/two-factor-challenge'); }); $this->resetConfig(); -}); \ No newline at end of file +}); diff --git a/tests/Browser/VerifyEmailTest.php b/tests/Browser/VerifyEmailTest.php index 52d9836..55f1f9d 100644 --- a/tests/Browser/VerifyEmailTest.php +++ b/tests/Browser/VerifyEmailTest.php @@ -52,4 +52,4 @@ }); $this->resetConfig(); -}); \ No newline at end of file +}); diff --git a/tests/Datasets/Urls.php b/tests/Datasets/Urls.php index a98f8b1..9673208 100644 --- a/tests/Datasets/Urls.php +++ b/tests/Datasets/Urls.php @@ -6,4 +6,4 @@ '/auth/verify', '/auth/password/reset', '/auth/password/SomeReallyLongtoken', -]); \ No newline at end of file +]); diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index 9bf19b8..8b4e479 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -6,7 +6,6 @@ use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\RemoteWebDriver; -use Illuminate\Support\Collection; use Laravel\Dusk\TestCase as BaseTestCase; use PHPUnit\Framework\Attributes\BeforeClass; diff --git a/tests/Pest.php b/tests/Pest.php index 2966726..1db7284 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -69,4 +69,4 @@ function createUser($data) function withANewUser() { return test()->actingAs(User::factory()->create()); -} \ No newline at end of file +} From b65089c1a9c383a52e2f19ecf864518a7ad7b533 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Sun, 15 Sep 2024 20:36:08 -0400 Subject: [PATCH 3/4] Adding updates to tests --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 6ed2435..081a6f4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,7 +25,7 @@ }); Route::middleware(['web'])->group(function () { - // Add social routes + // Add social redirect and callback routes Route::get('auth/{driver}/redirect', [SocialController::class, 'redirect']); Route::get('auth/{driver}/callback', [SocialController::class, 'callback']); From 82e250f0b74471db1a69970a6df76f59f6b87c85 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Sun, 15 Sep 2024 20:40:57 -0400 Subject: [PATCH 4/4] Adding updates to tests --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f7b9ad0..ed63dbd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -151,13 +151,13 @@ jobs: - name: Upload Screenshots if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: screenshots path: tests/Browser/screenshots - name: Upload Console Logs if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: console path: tests/Browser/console