Skip to content

Commit

Permalink
Test when the 2FA buttons should be visible
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorvack committed Mar 15, 2024
1 parent cf32237 commit 8b7240e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Modules/Backend/tests/Backend/Actions/UserEditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use ForkCMS\Modules\Backend\DataFixtures\UserFixture;
use ForkCMS\Modules\Backend\DataFixtures\UserGroupFixture;
use ForkCMS\Modules\Backend\Domain\Action\ActionServices;
use ForkCMS\Modules\Backend\tests\BackendWebTestCase;
use ForkCMS\Modules\Extensions\Domain\Module\ModuleName;

final class UserEditTest extends BackendWebTestCase
{
Expand Down Expand Up @@ -89,6 +91,28 @@ public function testSubmittedFormRedirectsToIndex(): void
self::assertResponseContains('The settings for "Jelmer Prins" were saved.');
}

public function testEnableTwoFactorAuthenticationVisible(): void
{
/** @var ActionServices $actionServices */
$actionServices = self::getContainer()->get(ActionServices::class);
$actionServices->moduleSettings->set(ModuleName::backend(), '2fa_enabled', true);

self::loadPage();

self::assertResponseContains('data-role="enable-two-factor-authorization-button"');
}

public function testEnableTwoFactorAuthenticationNotVisible(): void
{
/** @var ActionServices $actionServices */
$actionServices = self::getContainer()->get(ActionServices::class);
$actionServices->moduleSettings->set(ModuleName::backend(), '2fa_enabled', false);

self::loadPage();

self::assertResponseDoesNotHaveContent('data-role="enable-two-factor-authorization-button"');
}

protected static function getClassFixtures(): array
{
return [
Expand Down

0 comments on commit 8b7240e

Please sign in to comment.