From f3e054a20b0717d9fd2cf313a635938b35834303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Skowro=C5=84ski?= Date: Wed, 27 Dec 2023 16:20:37 +0100 Subject: [PATCH] Add mod list tests --- .../ModList/CupModListFixture.php | 86 +++++ .../ModList/DefaultModListFixture.php | 5 +- .../ModList/RhsModListFixture.php | 86 +++++ ...{AdminUserFixture.php => AdminFixture.php} | 10 +- ...egularUserFixture.php => User1Fixture.php} | 12 +- src/DataFixtures/User/User2Fixture.php | 40 +++ src/DataFixtures/User/User3Fixture.php | 40 +++ src/Form/ModList/Dto/ModListFormDto.php | 4 +- .../ModList/UniqueModListNameValidator.php | 6 +- tests/functional/Web/Dlc/CreateDlcCest.php | 22 +- tests/functional/Web/Dlc/DeleteDlcCest.php | 6 +- tests/functional/Web/Dlc/ListDlcsCest.php | 12 +- tests/functional/Web/Dlc/UpdateDlcCest.php | 22 +- .../Web/Mod/CreateDirectoryModCest.php | 16 +- .../Web/Mod/CreateSteamWorkshopModCest.php | 22 +- tests/functional/Web/Mod/DeleteModCest.php | 6 +- tests/functional/Web/Mod/ListModsCest.php | 12 +- .../Web/Mod/UpdateDirectoryModCest.php | 16 +- .../Web/Mod/UpdateSteamWorkshopModCest.php | 22 +- .../Web/ModGroup/CreateModGroupCest.php | 12 +- .../Web/ModGroup/DeleteModGroupCest.php | 6 +- .../Web/ModGroup/ListModGroupsCest.php | 12 +- .../Web/ModGroup/UpdateModGroupCest.php | 12 +- .../Web/ModList/CreateModListCest.php | 246 ++++++++++++++ .../Web/ModList/DeleteModListCest.php | 67 ++++ .../Web/ModList/ListModListsCest.php | 133 ++++++++ .../Web/ModList/UpdateModListCest.php | 316 ++++++++++++++++++ 27 files changed, 1135 insertions(+), 114 deletions(-) create mode 100644 src/DataFixtures/ModList/CupModListFixture.php create mode 100644 src/DataFixtures/ModList/RhsModListFixture.php rename src/DataFixtures/User/{AdminUserFixture.php => AdminFixture.php} (79%) rename src/DataFixtures/User/{RegularUserFixture.php => User1Fixture.php} (68%) create mode 100644 src/DataFixtures/User/User2Fixture.php create mode 100644 src/DataFixtures/User/User3Fixture.php create mode 100644 tests/functional/Web/ModList/CreateModListCest.php create mode 100644 tests/functional/Web/ModList/DeleteModListCest.php create mode 100644 tests/functional/Web/ModList/ListModListsCest.php create mode 100644 tests/functional/Web/ModList/UpdateModListCest.php diff --git a/src/DataFixtures/ModList/CupModListFixture.php b/src/DataFixtures/ModList/CupModListFixture.php new file mode 100644 index 00000000..8cd606ff --- /dev/null +++ b/src/DataFixtures/ModList/CupModListFixture.php @@ -0,0 +1,86 @@ +withTimeFrozenAt('2020-01-01T00:00:00+00:00', function () use ($manager): void { + $modList = new ModList( + Uuid::fromString(self::ID), + self::NAME, + null, + [ + $this->getReference(R3ModFixture::ID), + $this->getReference(ArmaScriptProfilerModFixture::ID), + + $this->getReference(AceInteractionMenuExpansionModFixture::ID), + $this->getReference(ArmaForcesAceMedicalModFixture::ID), + $this->getReference(LegacyArmaForcesModsModFixture::ID), + $this->getReference(ArmaForcesJbadBuildingFixModFixture::ID), + $this->getReference(ArmaForcesMedicalModFixture::ID), + ], + [ + $this->getReference(CupModGroupFixture::ID), + ], + [ + $this->getReference(CslaIronCurtainDlcFixture::ID), + ], + $this->getReference(self::OWNER_ID), + true, + false, + ); + + $manager->persist($modList); + $manager->flush(); + + $this->addReference(self::ID, $modList); + }); + } + + public function getDependencies(): array + { + return [ + User1Fixture::class, // owner + + R3ModFixture::class, + ArmaScriptProfilerModFixture::class, + + AceInteractionMenuExpansionModFixture::class, + ArmaForcesAceMedicalModFixture::class, + LegacyArmaForcesModsModFixture::class, + ArmaForcesJbadBuildingFixModFixture::class, + ArmaForcesMedicalModFixture::class, + + CupModGroupFixture::class, + + CslaIronCurtainDlcFixture::class, + ]; + } +} diff --git a/src/DataFixtures/ModList/DefaultModListFixture.php b/src/DataFixtures/ModList/DefaultModListFixture.php index b3948619..90b0046e 100644 --- a/src/DataFixtures/ModList/DefaultModListFixture.php +++ b/src/DataFixtures/ModList/DefaultModListFixture.php @@ -37,13 +37,14 @@ class DefaultModListFixture extends Fixture implements DependentFixtureInterface use TimeTrait; public const ID = 'f3e04dae-18a8-4533-99ea-d6d763ebabcf'; + public const NAME = 'Default'; public function load(ObjectManager $manager): void { $this->withTimeFrozenAt('2020-01-01T00:00:00+00:00', function () use ($manager): void { $modList = new ModList( Uuid::fromString(self::ID), - 'Default', + self::NAME, null, [ $this->getReference(R3ModFixture::ID), @@ -77,7 +78,7 @@ public function load(ObjectManager $manager): void ], null, true, - false, + true, ); $manager->persist($modList); diff --git a/src/DataFixtures/ModList/RhsModListFixture.php b/src/DataFixtures/ModList/RhsModListFixture.php new file mode 100644 index 00000000..16de8400 --- /dev/null +++ b/src/DataFixtures/ModList/RhsModListFixture.php @@ -0,0 +1,86 @@ +withTimeFrozenAt('2020-01-01T00:00:00+00:00', function () use ($manager): void { + $modList = new ModList( + Uuid::fromString(self::ID), + self::NAME, + null, + [ + $this->getReference(R3ModFixture::ID), + $this->getReference(ArmaScriptProfilerModFixture::ID), + + $this->getReference(AceInteractionMenuExpansionModFixture::ID), + $this->getReference(ArmaForcesAceMedicalModFixture::ID), + $this->getReference(LegacyArmaForcesModsModFixture::ID), + $this->getReference(ArmaForcesJbadBuildingFixModFixture::ID), + $this->getReference(ArmaForcesMedicalModFixture::ID), + ], + [ + $this->getReference(RhsModGroupFixture::ID), + ], + [ + $this->getReference(CslaIronCurtainDlcFixture::ID), + ], + $this->getReference(self::OWNER_ID), + false, + false, + ); + + $manager->persist($modList); + $manager->flush(); + + $this->addReference(self::ID, $modList); + }); + } + + public function getDependencies(): array + { + return [ + User2Fixture::class, // owner + + R3ModFixture::class, + ArmaScriptProfilerModFixture::class, + + AceInteractionMenuExpansionModFixture::class, + ArmaForcesAceMedicalModFixture::class, + LegacyArmaForcesModsModFixture::class, + ArmaForcesJbadBuildingFixModFixture::class, + ArmaForcesMedicalModFixture::class, + + RhsModGroupFixture::class, + + CslaIronCurtainDlcFixture::class, + ]; + } +} diff --git a/src/DataFixtures/User/AdminUserFixture.php b/src/DataFixtures/User/AdminFixture.php similarity index 79% rename from src/DataFixtures/User/AdminUserFixture.php rename to src/DataFixtures/User/AdminFixture.php index 6fdfb10a..63f16639 100644 --- a/src/DataFixtures/User/AdminUserFixture.php +++ b/src/DataFixtures/User/AdminFixture.php @@ -10,9 +10,11 @@ use Doctrine\Persistence\ObjectManager; use Ramsey\Uuid\Uuid; -class AdminUserFixture extends Fixture +class AdminFixture extends Fixture { public const ID = '31c9769f-4195-4fa8-b78d-0b54a1ceb8df'; + public const USERNAME = 'admin#0'; + public const EMAIL = 'admin@example.com'; public function load(ObjectManager $manager): void { @@ -21,9 +23,9 @@ public function load(ObjectManager $manager): void $user = new User( Uuid::fromString(self::ID), - 'admin#0', - 'admin@example.com', - self::ID, + self::USERNAME, + self::EMAIL, + str_repeat('0', 18), $permissions, [], null, diff --git a/src/DataFixtures/User/RegularUserFixture.php b/src/DataFixtures/User/User1Fixture.php similarity index 68% rename from src/DataFixtures/User/RegularUserFixture.php rename to src/DataFixtures/User/User1Fixture.php index f469e5da..6faa6a6b 100644 --- a/src/DataFixtures/User/RegularUserFixture.php +++ b/src/DataFixtures/User/User1Fixture.php @@ -10,19 +10,21 @@ use Doctrine\Persistence\ObjectManager; use Ramsey\Uuid\Uuid; -class RegularUserFixture extends Fixture +class User1Fixture extends Fixture { public const ID = '03f6066e-2fe9-44ac-b853-2921483f1950'; + public const USERNAME = 'user#1'; + public const EMAIL = 'user1@example.com'; public function load(ObjectManager $manager): void { - $permissions = new UserPermissions(Uuid::fromString('35874dd8-8230-41ca-ab18-1acb3419c177')); + $permissions = new UserPermissions(Uuid::fromString('b62733f6-97dc-4031-b74a-ecb080c09658')); $user = new User( Uuid::fromString(self::ID), - 'regular#0', - 'regular@example.com', - self::ID, + self::USERNAME, + self::EMAIL, + str_repeat('1', 18), $permissions, [], null, diff --git a/src/DataFixtures/User/User2Fixture.php b/src/DataFixtures/User/User2Fixture.php new file mode 100644 index 00000000..ec5e524a --- /dev/null +++ b/src/DataFixtures/User/User2Fixture.php @@ -0,0 +1,40 @@ +persist($permissions); + $manager->persist($user); + $manager->flush(); + + $this->addReference(self::ID, $user); + } +} diff --git a/src/DataFixtures/User/User3Fixture.php b/src/DataFixtures/User/User3Fixture.php new file mode 100644 index 00000000..043a1cee --- /dev/null +++ b/src/DataFixtures/User/User3Fixture.php @@ -0,0 +1,40 @@ +persist($permissions); + $manager->persist($user); + $manager->flush(); + + $this->addReference(self::ID, $user); + } +} diff --git a/src/Form/ModList/Dto/ModListFormDto.php b/src/Form/ModList/Dto/ModListFormDto.php index 90d37190..e3e72e3c 100644 --- a/src/Form/ModList/Dto/ModListFormDto.php +++ b/src/Form/ModList/Dto/ModListFormDto.php @@ -15,9 +15,7 @@ use Ramsey\Uuid\UuidInterface; use Symfony\Component\Validator\Constraints as Assert; -/** - * @UniqueModListName(errorPath="name") - */ +#[UniqueModListName(errorPath: 'name')] class ModListFormDto extends AbstractFormDto { protected ?UuidInterface $id = null; diff --git a/src/Validator/ModList/UniqueModListNameValidator.php b/src/Validator/ModList/UniqueModListNameValidator.php index e31e9e98..2ce9638c 100644 --- a/src/Validator/ModList/UniqueModListNameValidator.php +++ b/src/Validator/ModList/UniqueModListNameValidator.php @@ -23,8 +23,12 @@ public function validate(mixed $value, Constraint $constraint): void } $name = $value->getName(); + if ('' === $name || null === $name) { + return; + } + $id = $value->getId(); - if (!$name || $this->isColumnValueUnique(ModList::class, ['name' => $name], $id)) { + if ($this->isColumnValueUnique(ModList::class, ['name' => $name], $id)) { return; } diff --git a/tests/functional/Web/Dlc/CreateDlcCest.php b/tests/functional/Web/Dlc/CreateDlcCest.php index 5df002ae..d3628efe 100644 --- a/tests/functional/Web/Dlc/CreateDlcCest.php +++ b/tests/functional/Web/Dlc/CreateDlcCest.php @@ -4,7 +4,7 @@ namespace App\Tests\Functional\Web\Dlc; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Dlc\Dlc; use App\Entity\User\User; use App\Service\SteamApiClient\Helper\SteamHelper; @@ -27,7 +27,7 @@ public function createDlcAsUnauthenticatedUser(FunctionalTester $I): void public function createDlcAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage('/dlc/create'); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -35,7 +35,7 @@ public function createDlcAsUnauthorizedUser(FunctionalTester $I): void public function createDlcAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -71,7 +71,7 @@ public function createDlcAsAuthorizedUser(FunctionalTester $I): void public function createDlcAsAuthorizedUserWithNameProvidedBySteamWorkshop(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -107,7 +107,7 @@ public function createDlcAsAuthorizedUserWithNameProvidedBySteamWorkshop(Functio public function createDlcAsAuthorizedUserWhenDlcAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -125,7 +125,7 @@ public function createDlcAsAuthorizedUserWhenDlcAlreadyExists(FunctionalTester $ public function createDlcAsAuthorizedUserWithInvalidDlcUrl(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -140,7 +140,7 @@ public function createDlcAsAuthorizedUserWithInvalidDlcUrl(FunctionalTester $I): public function createDlcAsAuthorizedUserWhenDlcDoesNotExist(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -156,7 +156,7 @@ public function createDlcAsAuthorizedUserWhenDlcDoesNotExist(FunctionalTester $I public function createDlcAsAuthorizedUserWhenUrlIsNotAnArma3Dlc(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -172,7 +172,7 @@ public function createDlcAsAuthorizedUserWhenUrlIsNotAnArma3Dlc(FunctionalTester public function createDlcAsAuthorizedUserWithInvalidDirectoryName(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -187,7 +187,7 @@ public function createDlcAsAuthorizedUserWithInvalidDirectoryName(FunctionalTest public function createDlcAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); @@ -203,7 +203,7 @@ public function createDlcAsAuthorizedUserWithoutRequiredData(FunctionalTester $I public function createDlcAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcCreate = true; }); diff --git a/tests/functional/Web/Dlc/DeleteDlcCest.php b/tests/functional/Web/Dlc/DeleteDlcCest.php index 7b1368c4..1483dbec 100644 --- a/tests/functional/Web/Dlc/DeleteDlcCest.php +++ b/tests/functional/Web/Dlc/DeleteDlcCest.php @@ -5,7 +5,7 @@ namespace App\Tests\Functional\Web\Dlc; use App\DataFixtures\Dlc\SogPrairieFireDlcFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Dlc\Dlc; use App\Entity\User\User; use App\Tests\FunctionalTester; @@ -29,7 +29,7 @@ public function deleteDlcAsUnauthenticatedUser(FunctionalTester $I): void public function deleteDlcAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $id = SogPrairieFireDlcFixture::ID; $I->amOnPage(sprintf('/dlc/%s/delete', $id)); @@ -40,7 +40,7 @@ public function deleteDlcAsUnauthorizedUser(FunctionalTester $I): void public function deleteDlcAsAuthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcDelete = true; }); diff --git a/tests/functional/Web/Dlc/ListDlcsCest.php b/tests/functional/Web/Dlc/ListDlcsCest.php index e7dd0a8f..e157686f 100644 --- a/tests/functional/Web/Dlc/ListDlcsCest.php +++ b/tests/functional/Web/Dlc/ListDlcsCest.php @@ -4,7 +4,7 @@ namespace App\Tests\Functional\Web\Dlc; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\User\User; use App\Tests\FunctionalTester; use Symfony\Component\HttpFoundation\Response; @@ -24,7 +24,7 @@ public function listDlcsAsUnauthenticatedUser(FunctionalTester $I): void public function listDlcsAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage('/dlc/list'); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -32,7 +32,7 @@ public function listDlcsAsUnauthorizedUser(FunctionalTester $I): void public function listDlcsAsAuthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcList = true; }); @@ -45,7 +45,7 @@ public function listDlcsAsAuthorizedUser(FunctionalTester $I): void public function listDlcsAsAuthorizedUserWithCreateDlcPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcList = true; $user->getPermissions()->dlcCreate = true; }); @@ -60,7 +60,7 @@ public function listDlcsAsAuthorizedUserWithCreateDlcPermission(FunctionalTester public function listDlcsAsAuthorizedUserWithUpdateDlcPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcList = true; $user->getPermissions()->dlcUpdate = true; }); @@ -75,7 +75,7 @@ public function listDlcsAsAuthorizedUserWithUpdateDlcPermission(FunctionalTester public function listDlcsAsAuthorizedUserWithDeleteDlcPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcList = true; $user->getPermissions()->dlcDelete = true; }); diff --git a/tests/functional/Web/Dlc/UpdateDlcCest.php b/tests/functional/Web/Dlc/UpdateDlcCest.php index 236cde80..31b89a96 100644 --- a/tests/functional/Web/Dlc/UpdateDlcCest.php +++ b/tests/functional/Web/Dlc/UpdateDlcCest.php @@ -6,7 +6,7 @@ use App\DataFixtures\Dlc\CslaIronCurtainDlcFixture; use App\DataFixtures\Dlc\SogPrairieFireDlcFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Dlc\Dlc; use App\Entity\User\User; use App\Service\SteamApiClient\Helper\SteamHelper; @@ -29,7 +29,7 @@ public function updateDlcAsUnauthenticatedUser(FunctionalTester $I): void public function updateDlcAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage(sprintf('/dlc/%s/update', SogPrairieFireDlcFixture::ID)); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -37,7 +37,7 @@ public function updateDlcAsUnauthorizedUser(FunctionalTester $I): void public function updateDlcAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -73,7 +73,7 @@ public function updateDlcAsAuthorizedUser(FunctionalTester $I): void public function updateDlcAsAuthorizedUserWithNameProvidedBySteamWorkshop(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -109,7 +109,7 @@ public function updateDlcAsAuthorizedUserWithNameProvidedBySteamWorkshop(Functio public function updateDlcAsAuthorizedUserWhenDlcAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -127,7 +127,7 @@ public function updateDlcAsAuthorizedUserWhenDlcAlreadyExists(FunctionalTester $ public function updateDlcAsAuthorizedUserWithInvalidDlcUrl(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -142,7 +142,7 @@ public function updateDlcAsAuthorizedUserWithInvalidDlcUrl(FunctionalTester $I): public function updateDlcAsAuthorizedUserWhenDlcDoesNotExist(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -158,7 +158,7 @@ public function updateDlcAsAuthorizedUserWhenDlcDoesNotExist(FunctionalTester $I public function updateDlcAsAuthorizedUserWhenUrlIsNotAnArma3Dlc(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -174,7 +174,7 @@ public function updateDlcAsAuthorizedUserWhenUrlIsNotAnArma3Dlc(FunctionalTester public function updateDlcAsAuthorizedUserWithInvalidDirectoryName(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -189,7 +189,7 @@ public function updateDlcAsAuthorizedUserWithInvalidDirectoryName(FunctionalTest public function updateDlcAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); @@ -205,7 +205,7 @@ public function updateDlcAsAuthorizedUserWithoutRequiredData(FunctionalTester $I public function updateDlcAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->dlcUpdate = true; }); diff --git a/tests/functional/Web/Mod/CreateDirectoryModCest.php b/tests/functional/Web/Mod/CreateDirectoryModCest.php index 6bd94422..4f685b47 100644 --- a/tests/functional/Web/Mod/CreateDirectoryModCest.php +++ b/tests/functional/Web/Mod/CreateDirectoryModCest.php @@ -5,7 +5,7 @@ namespace App\Tests\Functional\Web\Mod; use App\DataFixtures\Mod\Directory\ArmaScriptProfilerModFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Mod\DirectoryMod; use App\Entity\Mod\Enum\ModStatusEnum; use App\Entity\User\User; @@ -28,7 +28,7 @@ public function createDirectoryModAsUnauthenticatedUser(FunctionalTester $I): vo public function createDirectoryModAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage('/mod/create'); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -36,7 +36,7 @@ public function createDirectoryModAsUnauthorizedUser(FunctionalTester $I): void public function createDirectoryModAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -72,7 +72,7 @@ public function createDirectoryModAsAuthorizedUser(FunctionalTester $I): void public function createDirectoryModAsAuthorizedUserWithChangeModStatusPermission(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; $user->getPermissions()->modChangeStatus = true; }); @@ -110,7 +110,7 @@ public function createDirectoryModAsAuthorizedUserWithChangeModStatusPermission( public function createDirectoryModAsAuthorizedUserWhenModAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -126,7 +126,7 @@ public function createDirectoryModAsAuthorizedUserWhenModAlreadyExists(Functiona public function createDirectoryModAsAuthorizedUserWithInvalidDirectoryName(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -142,7 +142,7 @@ public function createDirectoryModAsAuthorizedUserWithInvalidDirectoryName(Funct public function createDirectoryModAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -159,7 +159,7 @@ public function createDirectoryModAsAuthorizedUserWithoutRequiredData(Functional public function createDirectoryModAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); diff --git a/tests/functional/Web/Mod/CreateSteamWorkshopModCest.php b/tests/functional/Web/Mod/CreateSteamWorkshopModCest.php index af05cae6..38053185 100644 --- a/tests/functional/Web/Mod/CreateSteamWorkshopModCest.php +++ b/tests/functional/Web/Mod/CreateSteamWorkshopModCest.php @@ -5,7 +5,7 @@ namespace App\Tests\Functional\Web\Mod; use App\DataFixtures\Mod\SteamWorkshop\Required\ArmaForcesMedicalModFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Mod\Enum\ModStatusEnum; use App\Entity\Mod\Enum\ModTypeEnum; use App\Entity\Mod\SteamWorkshopMod; @@ -30,7 +30,7 @@ public function createSteamWorkshopModAsUnauthenticatedUser(FunctionalTester $I) public function createSteamWorkshopModAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage('/mod/create'); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -38,7 +38,7 @@ public function createSteamWorkshopModAsUnauthorizedUser(FunctionalTester $I): v public function createSteamWorkshopModAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -77,7 +77,7 @@ public function createSteamWorkshopModAsAuthorizedUser(FunctionalTester $I): voi public function createSteamWorkshopModAsAuthorizedUserWithNameProvidedBySteamWorkshop(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -116,7 +116,7 @@ public function createSteamWorkshopModAsAuthorizedUserWithNameProvidedBySteamWor public function createSteamWorkshopModAsAuthorizedUserWithChangeModStatusPermission(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; $user->getPermissions()->modChangeStatus = true; }); @@ -157,7 +157,7 @@ public function createSteamWorkshopModAsAuthorizedUserWithChangeModStatusPermiss public function createSteamWorkshopModAsAuthorizedUserWhenModAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -173,7 +173,7 @@ public function createSteamWorkshopModAsAuthorizedUserWhenModAlreadyExists(Funct public function createSteamWorkshopModAsAuthorizedUserWithInvalidModUrl(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -187,7 +187,7 @@ public function createSteamWorkshopModAsAuthorizedUserWithInvalidModUrl(Function public function createSteamWorkshopModAsAuthorizedUserWhenModDoesNotExist(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -202,7 +202,7 @@ public function createSteamWorkshopModAsAuthorizedUserWhenModDoesNotExist(Functi public function createSteamWorkshopModAsAuthorizedUserWhenUrlIsNotAnArma3Mod(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -217,7 +217,7 @@ public function createSteamWorkshopModAsAuthorizedUserWhenUrlIsNotAnArma3Mod(Fun public function createSteamWorkshopModAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); @@ -231,7 +231,7 @@ public function createSteamWorkshopModAsAuthorizedUserWithoutRequiredData(Functi public function createSteamWorkshopModAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modCreate = true; }); diff --git a/tests/functional/Web/Mod/DeleteModCest.php b/tests/functional/Web/Mod/DeleteModCest.php index cea784d2..28c5143a 100644 --- a/tests/functional/Web/Mod/DeleteModCest.php +++ b/tests/functional/Web/Mod/DeleteModCest.php @@ -5,7 +5,7 @@ namespace App\Tests\Functional\Web\Mod; use App\DataFixtures\Mod\SteamWorkshop\Required\ArmaForcesMedicalModFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Mod\AbstractMod; use App\Entity\User\User; use App\Tests\FunctionalTester; @@ -29,7 +29,7 @@ public function deleteModAsUnauthenticatedUser(FunctionalTester $I): void public function deleteModAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $id = ArmaForcesMedicalModFixture::ID; $I->amOnPage(sprintf('/mod/%s/delete', $id)); @@ -40,7 +40,7 @@ public function deleteModAsUnauthorizedUser(FunctionalTester $I): void public function deleteModAsAuthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modDelete = true; }); diff --git a/tests/functional/Web/Mod/ListModsCest.php b/tests/functional/Web/Mod/ListModsCest.php index dc0112d0..80db30c2 100644 --- a/tests/functional/Web/Mod/ListModsCest.php +++ b/tests/functional/Web/Mod/ListModsCest.php @@ -4,7 +4,7 @@ namespace App\Tests\Functional\Web\Mod; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\User\User; use App\Tests\FunctionalTester; use Symfony\Component\HttpFoundation\Response; @@ -24,7 +24,7 @@ public function listModsAsUnauthenticatedUser(FunctionalTester $I): void public function listModsAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage('/mod/list'); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -32,7 +32,7 @@ public function listModsAsUnauthorizedUser(FunctionalTester $I): void public function listModsAsAuthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modList = true; }); @@ -46,7 +46,7 @@ public function listModsAsAuthorizedUser(FunctionalTester $I): void public function listModsAsAuthorizedUserWithCreateModPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modList = true; $user->getPermissions()->modCreate = true; }); @@ -61,7 +61,7 @@ public function listModsAsAuthorizedUserWithCreateModPermission(FunctionalTester public function listModsAsAuthorizedUserWithUpdateModPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modList = true; $user->getPermissions()->modUpdate = true; }); @@ -76,7 +76,7 @@ public function listModsAsAuthorizedUserWithUpdateModPermission(FunctionalTester public function listModsAsAuthorizedUserWithDeleteModPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modList = true; $user->getPermissions()->modDelete = true; }); diff --git a/tests/functional/Web/Mod/UpdateDirectoryModCest.php b/tests/functional/Web/Mod/UpdateDirectoryModCest.php index 974b9151..15f304f6 100644 --- a/tests/functional/Web/Mod/UpdateDirectoryModCest.php +++ b/tests/functional/Web/Mod/UpdateDirectoryModCest.php @@ -6,7 +6,7 @@ use App\DataFixtures\Mod\Directory\ArmaScriptProfilerModFixture; use App\DataFixtures\Mod\Directory\Deprecated\R3ModFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Mod\DirectoryMod; use App\Entity\Mod\Enum\ModStatusEnum; use App\Entity\User\User; @@ -29,7 +29,7 @@ public function updateDirectoryModAsUnauthenticatedUser(FunctionalTester $I): vo public function updateDirectoryModAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage(sprintf('/mod/%s/update', ArmaScriptProfilerModFixture::ID)); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -37,7 +37,7 @@ public function updateDirectoryModAsUnauthorizedUser(FunctionalTester $I): void public function updateDirectoryModAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -72,7 +72,7 @@ public function updateDirectoryModAsAuthorizedUser(FunctionalTester $I): void public function updateDirectoryModAsAuthorizedUserWithChangeModStatusPermission(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; $user->getPermissions()->modChangeStatus = true; }); @@ -109,7 +109,7 @@ public function updateDirectoryModAsAuthorizedUserWithChangeModStatusPermission( public function updateDirectoryModAsAuthorizedUserWhenModAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -125,7 +125,7 @@ public function updateDirectoryModAsAuthorizedUserWhenModAlreadyExists(Functiona public function updateDirectoryModAsAuthorizedUserWithInvalidDirectoryName(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -141,7 +141,7 @@ public function updateDirectoryModAsAuthorizedUserWithInvalidDirectoryName(Funct public function updateDirectoryModAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -158,7 +158,7 @@ public function updateDirectoryModAsAuthorizedUserWithoutRequiredData(Functional public function updateDirectoryModAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); diff --git a/tests/functional/Web/Mod/UpdateSteamWorkshopModCest.php b/tests/functional/Web/Mod/UpdateSteamWorkshopModCest.php index e192299c..63c7aac9 100644 --- a/tests/functional/Web/Mod/UpdateSteamWorkshopModCest.php +++ b/tests/functional/Web/Mod/UpdateSteamWorkshopModCest.php @@ -6,7 +6,7 @@ use App\DataFixtures\Mod\SteamWorkshop\Required\ArmaForcesMedicalModFixture; use App\DataFixtures\Mod\SteamWorkshop\Required\Deprecated\LegacyArmaForcesModsModFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Mod\Enum\ModStatusEnum; use App\Entity\Mod\Enum\ModTypeEnum; use App\Entity\Mod\SteamWorkshopMod; @@ -31,7 +31,7 @@ public function updateSteamWorkshopModAsUnauthenticatedUser(FunctionalTester $I) public function updateSteamWorkshopModAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage(sprintf('/mod/%s/update', ArmaForcesMedicalModFixture::ID)); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -39,7 +39,7 @@ public function updateSteamWorkshopModAsUnauthorizedUser(FunctionalTester $I): v public function updateSteamWorkshopModAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -77,7 +77,7 @@ public function updateSteamWorkshopModAsAuthorizedUser(FunctionalTester $I): voi public function updateSteamWorkshopModAsAuthorizedUserWithNameProvidedBySteamWorkshop(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -115,7 +115,7 @@ public function updateSteamWorkshopModAsAuthorizedUserWithNameProvidedBySteamWor public function updateSteamWorkshopModAsAuthorizedUserWithChangeModStatusPermission(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; $user->getPermissions()->modChangeStatus = true; }); @@ -155,7 +155,7 @@ public function updateSteamWorkshopModAsAuthorizedUserWithChangeModStatusPermiss public function updateSteamWorkshopModAsAuthorizedUserWhenModDoesNotExist(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -170,7 +170,7 @@ public function updateSteamWorkshopModAsAuthorizedUserWhenModDoesNotExist(Functi public function updateSteamWorkshopModAsAuthorizedUserWithInvalidModUrl(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -184,7 +184,7 @@ public function updateSteamWorkshopModAsAuthorizedUserWithInvalidModUrl(Function public function updateSteamWorkshopModAsAuthorizedUserWhenModAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -200,7 +200,7 @@ public function updateSteamWorkshopModAsAuthorizedUserWhenModAlreadyExists(Funct public function updateSteamWorkshopModAsAuthorizedUserWhenUrlIsNotAnArma3Mod(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -215,7 +215,7 @@ public function updateSteamWorkshopModAsAuthorizedUserWhenUrlIsNotAnArma3Mod(Fun public function updateSteamWorkshopModAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); @@ -229,7 +229,7 @@ public function updateSteamWorkshopModAsAuthorizedUserWithoutRequiredData(Functi public function updateSteamWorkshopModAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modUpdate = true; }); diff --git a/tests/functional/Web/ModGroup/CreateModGroupCest.php b/tests/functional/Web/ModGroup/CreateModGroupCest.php index 48168b9c..aca22957 100644 --- a/tests/functional/Web/ModGroup/CreateModGroupCest.php +++ b/tests/functional/Web/ModGroup/CreateModGroupCest.php @@ -6,7 +6,7 @@ use App\DataFixtures\Mod\SteamWorkshop\Required\CupTerrainsCoreModFixture; use App\DataFixtures\Mod\SteamWorkshop\Required\CupTerrainsMapsModFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Mod\AbstractMod; use App\Entity\ModGroup\ModGroup; use App\Entity\User\User; @@ -29,7 +29,7 @@ public function createModGroupAsUnauthenticatedUser(FunctionalTester $I): void public function createModGroupAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage('/mod-group/create'); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -37,7 +37,7 @@ public function createModGroupAsUnauthorizedUser(FunctionalTester $I): void public function createModGroupAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupCreate = true; }); @@ -74,7 +74,7 @@ public function createModGroupAsAuthorizedUser(FunctionalTester $I): void public function createModGroupAsAuthorizedUserWhenModGroupAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupCreate = true; }); @@ -88,7 +88,7 @@ public function createModGroupAsAuthorizedUserWhenModGroupAlreadyExists(Function public function createModGroupAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupCreate = true; }); @@ -102,7 +102,7 @@ public function createModGroupAsAuthorizedUserWithoutRequiredData(FunctionalTest public function createModGroupAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupCreate = true; }); diff --git a/tests/functional/Web/ModGroup/DeleteModGroupCest.php b/tests/functional/Web/ModGroup/DeleteModGroupCest.php index 8136266c..9c779087 100644 --- a/tests/functional/Web/ModGroup/DeleteModGroupCest.php +++ b/tests/functional/Web/ModGroup/DeleteModGroupCest.php @@ -5,7 +5,7 @@ namespace App\Tests\Functional\Web\ModGroup; use App\DataFixtures\ModGroup\CupModGroupFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\ModGroup\ModGroup; use App\Entity\User\User; use App\Tests\FunctionalTester; @@ -29,7 +29,7 @@ public function deleteModGroupAsUnauthenticatedUser(FunctionalTester $I): void public function deleteModGroupAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $name = CupModGroupFixture::NAME; $I->amOnPage(sprintf('/mod-group/%s/delete', $name)); @@ -40,7 +40,7 @@ public function deleteModGroupAsUnauthorizedUser(FunctionalTester $I): void public function deleteModGroupAsAuthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupDelete = true; }); diff --git a/tests/functional/Web/ModGroup/ListModGroupsCest.php b/tests/functional/Web/ModGroup/ListModGroupsCest.php index db4f9d71..c40eb8d9 100644 --- a/tests/functional/Web/ModGroup/ListModGroupsCest.php +++ b/tests/functional/Web/ModGroup/ListModGroupsCest.php @@ -4,7 +4,7 @@ namespace App\Tests\Functional\Web\ModGroup; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\User\User; use App\Tests\FunctionalTester; use Symfony\Component\HttpFoundation\Response; @@ -24,7 +24,7 @@ public function listModGroupsAsUnauthenticatedUser(FunctionalTester $I): void public function listModGroupsAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage('/mod-group/list'); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -32,7 +32,7 @@ public function listModGroupsAsUnauthorizedUser(FunctionalTester $I): void public function listModGroupsAsAuthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupList = true; }); @@ -46,7 +46,7 @@ public function listModGroupsAsAuthorizedUser(FunctionalTester $I): void public function listModGroupsAsAuthorizedUserWithCreateModPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupList = true; $user->getPermissions()->modGroupCreate = true; }); @@ -61,7 +61,7 @@ public function listModGroupsAsAuthorizedUserWithCreateModPermission(FunctionalT public function listModGroupsAsAuthorizedUserWithUpdateModPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupList = true; $user->getPermissions()->modGroupUpdate = true; }); @@ -76,7 +76,7 @@ public function listModGroupsAsAuthorizedUserWithUpdateModPermission(FunctionalT public function listModGroupsAsAuthorizedUserWithDeleteModPermission(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupList = true; $user->getPermissions()->modGroupDelete = true; }); diff --git a/tests/functional/Web/ModGroup/UpdateModGroupCest.php b/tests/functional/Web/ModGroup/UpdateModGroupCest.php index ed1c7b53..4bc714f4 100644 --- a/tests/functional/Web/ModGroup/UpdateModGroupCest.php +++ b/tests/functional/Web/ModGroup/UpdateModGroupCest.php @@ -10,7 +10,7 @@ use App\DataFixtures\Mod\SteamWorkshop\Required\RhsGrefModFixture; use App\DataFixtures\Mod\SteamWorkshop\Required\RhsUsafModFixture; use App\DataFixtures\ModGroup\RhsModGroupFixture; -use App\DataFixtures\User\RegularUserFixture; +use App\DataFixtures\User\User1Fixture; use App\Entity\Mod\AbstractMod; use App\Entity\ModGroup\ModGroup; use App\Entity\User\User; @@ -33,7 +33,7 @@ public function updateModGroupAsUnauthenticatedUser(FunctionalTester $I): void public function updateModGroupAsUnauthorizedUser(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID); + $I->amDiscordAuthenticatedAs(User1Fixture::ID); $I->amOnPage(sprintf('/mod-group/%s/update', RhsModGroupFixture::NAME)); $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); @@ -41,7 +41,7 @@ public function updateModGroupAsUnauthorizedUser(FunctionalTester $I): void public function updateModGroupAsAuthorizedUser(FunctionalTester $I): void { - $user = $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupUpdate = true; }); @@ -85,7 +85,7 @@ public function updateModGroupAsAuthorizedUser(FunctionalTester $I): void public function updateModGroupAsAuthorizedUserWhenModGroupAlreadyExists(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupUpdate = true; }); @@ -99,7 +99,7 @@ public function updateModGroupAsAuthorizedUserWhenModGroupAlreadyExists(Function public function updateModGroupAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupUpdate = true; }); @@ -113,7 +113,7 @@ public function updateModGroupAsAuthorizedUserWithoutRequiredData(FunctionalTest public function updateModGroupAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void { - $I->amDiscordAuthenticatedAs(RegularUserFixture::ID, function (User $user): void { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { $user->getPermissions()->modGroupUpdate = true; }); diff --git a/tests/functional/Web/ModList/CreateModListCest.php b/tests/functional/Web/ModList/CreateModListCest.php new file mode 100644 index 00000000..c799a3c2 --- /dev/null +++ b/tests/functional/Web/ModList/CreateModListCest.php @@ -0,0 +1,246 @@ +stopFollowingRedirects(); + $I->freezeTime('2020-01-01T00:00:00+00:00'); + } + + public function createModListAsUnauthenticatedUser(FunctionalTester $I): void + { + $I->amOnPage('/mod-list/create'); + $I->seeResponseRedirectsToDiscordAuth(); + } + + public function createModListAsUnauthorizedUser(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID); + + $I->amOnPage('/mod-list/create'); + $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); + } + + public function createModListAsAuthorizedUser(FunctionalTester $I): void + { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListCreate = true; + }); + + $I->amOnPage('/mod-list/create'); + + // Default form values + $I->seeInField('Mod list name', ''); + $I->seeInField('Mod list description', ''); + $I->dontSee('Mod list owner'); + $I->seeCheckboxIsChecked('Mod list active'); + $I->dontSee('Mod list approved'); + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_modGroups_'); // All mod group checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_dlcs_'); // All DLC checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_mods_'); // All mod checkboxes are unchecked + + // Fill form + $I->fillField('Mod list name', 'Custom'); + $I->fillField('Mod list description', 'Custom modlist'); + $I->uncheckOption('Mod list active'); + $I->checkTableRowCheckbox(CupModGroupFixture::ID); // Mod group + $I->checkTableRowCheckbox(CslaIronCurtainDlcFixture::ID); // DLC + $I->checkTableRowCheckbox(RhsAfrfModFixture::ID); // Mod + $I->click('Create mod list'); + + $I->seeResponseRedirectsTo('/mod-list/list'); + + /** @var ModList $modList */ + $modList = $I->grabEntityFromRepository(ModList::class, ['name' => 'Custom']); + $I->assertSame('Custom', $modList->getName()); + $I->assertSame('Custom modlist', $modList->getDescription()); + $I->assertSame(User1Fixture::ID, $modList->getOwner()->getId()->toString()); // Current user + $I->assertSame(false, $modList->isActive()); + $I->assertSame(false, $modList->isApproved()); + $I->assertSame([ + CupModGroupFixture::ID, + ], array_map(fn (ModGroup $modGroup) => $modGroup->getId()->toString(), $modList->getModGroups())); + $I->assertSame([ + CslaIronCurtainDlcFixture::ID, + ], array_map(fn (Dlc $dlc) => $dlc->getId()->toString(), $modList->getDlcs())); + $I->assertSame([ + RhsAfrfModFixture::ID, + ], array_map(fn (AbstractMod $mod) => $mod->getId()->toString(), $modList->getMods())); + + $I->assertSame('2020-01-01T00:00:00+00:00', $modList->getCreatedAt()->format(DATE_ATOM)); + // $I->assertSame($user, $modList->getCreatedBy()); // FIXME + $I->assertSame(null, $modList->getLastUpdatedAt()); + $I->assertSame(null, $modList->getLastUpdatedBy()); + } + + public function createModListAsAuthorizedUserWithModListUpdatePermission(FunctionalTester $I): void + { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListCreate = true; + $user->getPermissions()->modListUpdate = true; + }); + + $I->amOnPage('/mod-list/create'); + + // Default form values + $I->seeInField('Mod list name', ''); + $I->seeInField('Mod list description', ''); + $I->seeOptionIsSelected('Mod list owner', User1Fixture::USERNAME); + $I->seeCheckboxIsChecked('Mod list active'); + $I->dontSee('Mod list approved'); + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_modGroups_'); // All mod group checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_dlcs_'); // All DLC checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_mods_'); // All mod checkboxes are unchecked + + // Fill form + $I->fillField('Mod list name', 'Custom'); + $I->fillField('Mod list description', 'Custom modlist'); + $I->selectOption('Mod list owner', User2Fixture::USERNAME); + $I->uncheckOption('Mod list active'); + $I->checkTableRowCheckbox(CupModGroupFixture::ID); // Mod group + $I->checkTableRowCheckbox(CslaIronCurtainDlcFixture::ID); // DLC + $I->checkTableRowCheckbox(RhsAfrfModFixture::ID); // Mod + $I->click('Create mod list'); + + $I->seeResponseRedirectsTo('/mod-list/list'); + + /** @var ModList $modList */ + $modList = $I->grabEntityFromRepository(ModList::class, ['name' => 'Custom']); + $I->assertSame('Custom', $modList->getName()); + $I->assertSame('Custom modlist', $modList->getDescription()); + $I->assertSame(User2Fixture::ID, $modList->getOwner()->getId()->toString()); // Current user + $I->assertSame(false, $modList->isActive()); + $I->assertSame(false, $modList->isApproved()); + $I->assertSame([ + CupModGroupFixture::ID, + ], array_map(fn (ModGroup $modGroup) => $modGroup->getId()->toString(), $modList->getModGroups())); + $I->assertSame([ + CslaIronCurtainDlcFixture::ID, + ], array_map(fn (Dlc $dlc) => $dlc->getId()->toString(), $modList->getDlcs())); + $I->assertSame([ + RhsAfrfModFixture::ID, + ], array_map(fn (AbstractMod $mod) => $mod->getId()->toString(), $modList->getMods())); + + $I->assertSame('2020-01-01T00:00:00+00:00', $modList->getCreatedAt()->format(DATE_ATOM)); + // $I->assertSame($user, $modList->getCreatedBy()); // FIXME + $I->assertSame(null, $modList->getLastUpdatedAt()); + $I->assertSame(null, $modList->getLastUpdatedBy()); + } + + public function createModListAsAuthorizedUserWithModListApprovePermission(FunctionalTester $I): void + { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListCreate = true; + $user->getPermissions()->modListApprove = true; + }); + + $I->amOnPage('/mod-list/create'); + + // Default form values + $I->seeInField('Mod list name', ''); + $I->seeInField('Mod list description', ''); + $I->dontSee('Mod list owner'); + $I->seeCheckboxIsChecked('Mod list active'); + $I->dontSeeCheckboxIsChecked('Mod list approved'); + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_modGroups_'); // All mod group checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_dlcs_'); // All DLC checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_mods_'); // All mod checkboxes are unchecked + + // Fill form + $I->fillField('Mod list name', 'Custom'); + $I->fillField('Mod list description', 'Custom modlist'); + $I->uncheckOption('Mod list active'); + $I->checkOption('Mod list approved'); + $I->checkTableRowCheckbox(CupModGroupFixture::ID); // Mod group + $I->checkTableRowCheckbox(CslaIronCurtainDlcFixture::ID); // DLC + $I->checkTableRowCheckbox(RhsAfrfModFixture::ID); // Mod + $I->click('Create mod list'); + + $I->seeResponseRedirectsTo('/mod-list/list'); + + /** @var ModList $modList */ + $modList = $I->grabEntityFromRepository(ModList::class, ['name' => 'Custom']); + $I->assertSame('Custom', $modList->getName()); + $I->assertSame('Custom modlist', $modList->getDescription()); + $I->assertSame(User1Fixture::ID, $modList->getOwner()->getId()->toString()); // Current user + $I->assertSame(false, $modList->isActive()); + $I->assertSame(true, $modList->isApproved()); + $I->assertSame([ + CupModGroupFixture::ID, + ], array_map(fn (ModGroup $modGroup) => $modGroup->getId()->toString(), $modList->getModGroups())); + $I->assertSame([ + CslaIronCurtainDlcFixture::ID, + ], array_map(fn (Dlc $dlc) => $dlc->getId()->toString(), $modList->getDlcs())); + $I->assertSame([ + RhsAfrfModFixture::ID, + ], array_map(fn (AbstractMod $mod) => $mod->getId()->toString(), $modList->getMods())); + + $I->assertSame('2020-01-01T00:00:00+00:00', $modList->getCreatedAt()->format(DATE_ATOM)); + // $I->assertSame($user, $modList->getCreatedBy()); // FIXME + $I->assertSame(null, $modList->getLastUpdatedAt()); + $I->assertSame(null, $modList->getLastUpdatedBy()); + } + + public function createModListAsAuthorizedUserWhenModListAlreadyExists(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListCreate = true; + }); + + $I->amOnPage('/mod-list/create'); + + $I->fillField('Mod list name', DefaultModListFixture::NAME); + $I->click('Create mod list'); + + $I->canSeeFormErrorMessage('name', 'Mod list with the same name "Default" already exist.'); + } + + public function createModListAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListCreate = true; + }); + + $I->amOnPage('/mod-list/create'); + + $I->fillField('Mod list name', ''); + $I->click('Create mod list'); + + $I->canSeeFormErrorMessage('name', 'This value should not be blank.'); + } + + public function createModListAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListCreate = true; + }); + + $I->amOnPage('/mod-list/create'); + + $I->fillField('Mod list name', str_repeat('a', 256)); + $I->fillField('Mod list description', str_repeat('a', 256)); + $I->click('Create mod list'); + + $I->canSeeFormErrorMessage('name', 'This value is too long. It should have 255 characters or less.'); + $I->canSeeFormErrorMessage('description', 'This value is too long. It should have 255 characters or less.'); + } +} diff --git a/tests/functional/Web/ModList/DeleteModListCest.php b/tests/functional/Web/ModList/DeleteModListCest.php new file mode 100644 index 00000000..856776fa --- /dev/null +++ b/tests/functional/Web/ModList/DeleteModListCest.php @@ -0,0 +1,67 @@ +stopFollowingRedirects(); + } + + public function deleteModListAsUnauthenticatedUser(FunctionalTester $I): void + { + $name = DefaultModListFixture::NAME; + $I->amOnPage(sprintf('/mod-list/%s/delete', $name)); + $I->seeResponseRedirectsToDiscordAuth(); + + $I->seeInRepository(ModList::class, ['name' => $name]); + } + + public function deleteModListAsUnauthorizedUser(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID); + + $name = DefaultModListFixture::NAME; + $I->amOnPage(sprintf('/mod-list/%s/delete', $name)); + $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); + + $I->seeInRepository(ModList::class, ['name' => $name]); + } + + public function deleteModListAsAuthorizedUser(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListDelete = true; + }); + + $name = DefaultModListFixture::NAME; + $I->amOnPage(sprintf('/mod-list/%s/delete', $name)); + $I->seeResponseRedirectsTo('/mod-list/list'); + + $I->dontSeeInRepository(ModList::class, ['name' => $name]); + } + + public function deleteModListAsModListOwner(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(CupModListFixture::OWNER_ID, function (User $user): void { + $user->getPermissions()->modListDelete = false; + }); + + $name = CupModListFixture::NAME; + $I->amOnPage(sprintf('/mod-list/%s/delete', $name)); + $I->seeResponseRedirectsTo('/mod-list/list'); + + $I->dontSeeInRepository(ModList::class, ['name' => $name]); + } +} diff --git a/tests/functional/Web/ModList/ListModListsCest.php b/tests/functional/Web/ModList/ListModListsCest.php new file mode 100644 index 00000000..de3282d2 --- /dev/null +++ b/tests/functional/Web/ModList/ListModListsCest.php @@ -0,0 +1,133 @@ +stopFollowingRedirects(); + } + + public function listModListsAsUnauthenticatedUser(FunctionalTester $I): void + { + $I->amOnPage('/mod-list/list'); + $I->seeResponseRedirectsToDiscordAuth(); + } + + public function listModListsAsUnauthorizedUser(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User3Fixture::ID); + + $I->amOnPage('/mod-list/list'); + $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); + } + + public function listModListsAsAuthorizedUser(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User3Fixture::ID, function (User $user): void { + $user->getPermissions()->modListList = true; + }); + + $I->amOnPage('/mod-list/list'); + $I->seeResponseCodeIs(Response::HTTP_OK); + + $I->dontSeeLink('Create mod list'); + $I->seeActionButton('Download mod list'); + $I->dontSeeActionButton('Edit mod list'); + $I->dontSeeActionButton('Copy and edit mod list'); + $I->dontSeeActionButton('Delete mod list'); + } + + public function listModListsAsAuthorizedUserWithCreateModListPermission(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User3Fixture::ID, function (User $user): void { + $user->getPermissions()->modListList = true; + $user->getPermissions()->modListCreate = true; + }); + + $I->amOnPage('/mod-list/list'); + $I->seeResponseCodeIs(Response::HTTP_OK); + + $I->seeLink('Create mod list'); + $I->seeActionButton('Download mod list'); + $I->dontSeeActionButton('Edit mod list'); + $I->dontSeeActionButton('Copy and edit mod list'); + $I->dontSeeActionButton('Delete mod list'); + } + + public function listModListsAsAuthorizedUserWithUpdateModListPermission(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User3Fixture::ID, function (User $user): void { + $user->getPermissions()->modListList = true; + $user->getPermissions()->modListUpdate = true; + }); + + $I->amOnPage('/mod-list/list'); + $I->seeResponseCodeIs(Response::HTTP_OK); + + $I->dontSeeLink('Create mod list'); + $I->seeActionButton('Download mod list'); + $I->seeActionButton('Edit mod list'); + $I->dontSeeActionButton('Copy and edit mod list'); + $I->dontSeeActionButton('Delete mod list'); + } + + public function listModListsAsAuthorizedUserWithModListOwnership(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(CupModListFixture::OWNER_ID, function (User $user): void { + $user->getPermissions()->modListList = true; + }); + + $I->amOnPage('/mod-list/list'); + $I->seeResponseCodeIs(Response::HTTP_OK); + + $I->dontSeeLink('Create mod list'); + $I->seeActionButton('Download mod list'); + $I->seeActionButton('Edit mod list', '/mod-list/CUP/update'); + $I->dontSeeActionButton('Copy and edit mod list'); + $I->seeActionButton('Delete mod list', '/mod-list/CUP/delete'); + } + + public function listModListsAsAuthorizedUserWithCopyModListPermission(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User3Fixture::ID, function (User $user): void { + $user->getPermissions()->modListList = true; + $user->getPermissions()->modListCopy = true; + }); + + $I->amOnPage('/mod-list/list'); + $I->seeResponseCodeIs(Response::HTTP_OK); + + $I->dontSeeLink('Create mod list'); + $I->seeActionButton('Download mod list'); + $I->dontSeeActionButton('Edit mod list'); + $I->seeActionButton('Copy and edit mod list'); + $I->dontSeeActionButton('Delete mod list'); + } + + public function listModListsAsAuthorizedUserWithDeleteModListPermission(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User3Fixture::ID, function (User $user): void { + $user->getPermissions()->modListList = true; + $user->getPermissions()->modListDelete = true; + }); + + $I->amOnPage('/mod-list/list'); + $I->seeResponseCodeIs(Response::HTTP_OK); + + $I->dontSeeLink('Create mod list'); + $I->seeActionButton('Download mod list'); + $I->dontSeeActionButton('Edit mod list'); + $I->dontSeeActionButton('Copy and edit mod list'); + $I->seeActionButton('Delete mod list'); + } +} diff --git a/tests/functional/Web/ModList/UpdateModListCest.php b/tests/functional/Web/ModList/UpdateModListCest.php new file mode 100644 index 00000000..e951ed71 --- /dev/null +++ b/tests/functional/Web/ModList/UpdateModListCest.php @@ -0,0 +1,316 @@ +stopFollowingRedirects(); + $I->freezeTime('2020-01-01T00:00:00+00:00'); + } + + public function updateModListAsUnauthenticatedUser(FunctionalTester $I): void + { + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + $I->seeResponseRedirectsToDiscordAuth(); + } + + public function updateModListAsUnauthorizedUser(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID); + + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + $I->seeResponseCodeIs(Response::HTTP_FORBIDDEN); + } + + public function updateModListAsAuthorizedUser(FunctionalTester $I): void + { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListUpdate = true; + }); + + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + + // Default form values + $I->seeInField('Mod list name', 'RHS'); + $I->seeInField('Mod list description', ''); + $I->seeOptionIsSelected('Mod list owner', User2Fixture::USERNAME); + $I->dontSeeCheckboxIsChecked('Mod list active'); + $I->dontSee('Mod list approved'); + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_modGroups_', [ + RhsModGroupFixture::ID, + ]); // Some checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_dlcs_', [ + CslaIronCurtainDlcFixture::ID, + ]); // Some checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_mods_', [ + R3ModFixture::ID, + ArmaScriptProfilerModFixture::ID, + + AceInteractionMenuExpansionModFixture::ID, + ArmaForcesAceMedicalModFixture::ID, + LegacyArmaForcesModsModFixture::ID, + ArmaForcesJbadBuildingFixModFixture::ID, + ArmaForcesMedicalModFixture::ID, + ]); // Some checkboxes are unchecked + + // Fill form + $I->fillField('Mod list name', 'Custom'); + $I->fillField('Mod list description', 'Custom modlist'); + $I->selectOption('Mod list owner', User3Fixture::USERNAME); + $I->checkOption('Mod list active'); + $I->uncheckTableRowCheckbox(RhsModGroupFixture::ID); // Mod group + $I->checkTableRowCheckbox(CupModGroupFixture::ID); // Mod group + $I->uncheckTableRowCheckbox(CslaIronCurtainDlcFixture::ID); // DLC + $I->checkTableRowCheckbox(SogPrairieFireDlcFixture::ID); // DLC + $I->uncheckTableRowCheckbox(R3ModFixture::ID); // Mod + $I->uncheckTableRowCheckbox(ArmaScriptProfilerModFixture::ID); // Mod + $I->click('Apply'); + + $I->seeResponseRedirectsTo('/mod-list/list'); + + /** @var ModList $modList */ + $modList = $I->grabEntityFromRepository(ModList::class, ['name' => 'Custom']); + $I->assertSame('Custom', $modList->getName()); + $I->assertSame('Custom modlist', $modList->getDescription()); + $I->assertSame(User3Fixture::ID, $modList->getOwner()->getId()->toString()); + $I->assertSame(true, $modList->isActive()); + $I->assertSame(false, $modList->isApproved()); + $I->assertSame([ + CupModGroupFixture::ID, + ], array_map(fn (ModGroup $modGroup) => $modGroup->getId()->toString(), $modList->getModGroups())); + $I->assertSame([ + SogPrairieFireDlcFixture::ID, + ], array_map(fn (Dlc $dlc) => $dlc->getId()->toString(), $modList->getDlcs())); + $I->assertSame([ + AceInteractionMenuExpansionModFixture::ID, + ArmaForcesAceMedicalModFixture::ID, + LegacyArmaForcesModsModFixture::ID, + ArmaForcesJbadBuildingFixModFixture::ID, + ArmaForcesMedicalModFixture::ID, + ], array_map(fn (AbstractMod $mod) => $mod->getId()->toString(), $modList->getMods())); + + $I->assertSame('2020-01-01T00:00:00+00:00', $modList->getCreatedAt()->format(DATE_ATOM)); + $I->assertSame(null, $modList->getCreatedBy()); + // $I->assertSame('2021-01-01T00:00:00+00:00', $modList->getLastUpdatedAt()->format(DATE_ATOM)); // FIXME + // $I->assertSame($user, $modList->getLastUpdatedBy()); // FIXME + } + + public function updateModListAsAuthorizedUserWithModListApprovePermission(FunctionalTester $I): void + { + $user = $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListUpdate = true; + $user->getPermissions()->modListApprove = true; + }); + + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + + // Default form values + $I->seeInField('Mod list name', 'RHS'); + $I->seeInField('Mod list description', ''); + $I->seeOptionIsSelected('Mod list owner', User2Fixture::USERNAME); + $I->dontSeeCheckboxIsChecked('Mod list active'); + $I->dontSeeCheckboxIsChecked('Mod list approved'); + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_modGroups_', [ + RhsModGroupFixture::ID, + ]); // Some checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_dlcs_', [ + CslaIronCurtainDlcFixture::ID, + ]); // Some checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_mods_', [ + R3ModFixture::ID, + ArmaScriptProfilerModFixture::ID, + + AceInteractionMenuExpansionModFixture::ID, + ArmaForcesAceMedicalModFixture::ID, + LegacyArmaForcesModsModFixture::ID, + ArmaForcesJbadBuildingFixModFixture::ID, + ArmaForcesMedicalModFixture::ID, + ]); // Some checkboxes are unchecked + + // Fill form + $I->fillField('Mod list name', 'Custom'); + $I->fillField('Mod list description', 'Custom modlist'); + $I->selectOption('Mod list owner', User3Fixture::USERNAME); + $I->checkOption('Mod list active'); + $I->checkOption('Mod list approved'); + $I->uncheckTableRowCheckbox(RhsModGroupFixture::ID); // Mod group + $I->checkTableRowCheckbox(CupModGroupFixture::ID); // Mod group + $I->uncheckTableRowCheckbox(CslaIronCurtainDlcFixture::ID); // DLC + $I->checkTableRowCheckbox(SogPrairieFireDlcFixture::ID); // DLC + $I->uncheckTableRowCheckbox(R3ModFixture::ID); // Mod + $I->uncheckTableRowCheckbox(ArmaScriptProfilerModFixture::ID); // Mod + $I->click('Apply'); + + $I->seeResponseRedirectsTo('/mod-list/list'); + + /** @var ModList $modList */ + $modList = $I->grabEntityFromRepository(ModList::class, ['name' => 'Custom']); + $I->assertSame('Custom', $modList->getName()); + $I->assertSame('Custom modlist', $modList->getDescription()); + $I->assertSame(User3Fixture::ID, $modList->getOwner()->getId()->toString()); + $I->assertSame(true, $modList->isActive()); + $I->assertSame(true, $modList->isApproved()); + $I->assertSame([ + CupModGroupFixture::ID, + ], array_map(fn (ModGroup $modGroup) => $modGroup->getId()->toString(), $modList->getModGroups())); + $I->assertSame([ + SogPrairieFireDlcFixture::ID, + ], array_map(fn (Dlc $dlc) => $dlc->getId()->toString(), $modList->getDlcs())); + $I->assertSame([ + AceInteractionMenuExpansionModFixture::ID, + ArmaForcesAceMedicalModFixture::ID, + LegacyArmaForcesModsModFixture::ID, + ArmaForcesJbadBuildingFixModFixture::ID, + ArmaForcesMedicalModFixture::ID, + ], array_map(fn (AbstractMod $mod) => $mod->getId()->toString(), $modList->getMods())); + + $I->assertSame('2020-01-01T00:00:00+00:00', $modList->getCreatedAt()->format(DATE_ATOM)); + $I->assertSame(null, $modList->getCreatedBy()); + // $I->assertSame('2021-01-01T00:00:00+00:00', $modList->getLastUpdatedAt()->format(DATE_ATOM)); // FIXME + // $I->assertSame($user, $modList->getLastUpdatedBy()); // FIXME + } + + public function updateModListAsModListOwner(FunctionalTester $I): void + { + $user = $I->amDiscordAuthenticatedAs(RhsModListFixture::OWNER_ID, function (User $user): void { + $user->getPermissions()->modListUpdate = false; + }); + + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + + // Default form values + $I->seeInField('Mod list name', 'RHS'); + $I->seeInField('Mod list description', ''); + $I->dontSee('Mod list owner'); + $I->dontSeeCheckboxIsChecked('Mod list active'); + $I->dontSee('Mod list approved'); + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_modGroups_', [ + RhsModGroupFixture::ID, + ]); // Some checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_dlcs_', [ + CslaIronCurtainDlcFixture::ID, + ]); // Some checkboxes are unchecked + $I->seeTableRowCheckboxesAreUnchecked('mod_list_form_mods_', [ + R3ModFixture::ID, + ArmaScriptProfilerModFixture::ID, + + AceInteractionMenuExpansionModFixture::ID, + ArmaForcesAceMedicalModFixture::ID, + LegacyArmaForcesModsModFixture::ID, + ArmaForcesJbadBuildingFixModFixture::ID, + ArmaForcesMedicalModFixture::ID, + ]); // Some checkboxes are unchecked + + // Fill form + $I->fillField('Mod list name', 'Custom'); + $I->fillField('Mod list description', 'Custom modlist'); + $I->checkOption('Mod list active'); + $I->uncheckTableRowCheckbox(RhsModGroupFixture::ID); // Mod group + $I->checkTableRowCheckbox(CupModGroupFixture::ID); // Mod group + $I->uncheckTableRowCheckbox(CslaIronCurtainDlcFixture::ID); // DLC + $I->checkTableRowCheckbox(SogPrairieFireDlcFixture::ID); // DLC + $I->uncheckTableRowCheckbox(R3ModFixture::ID); // Mod + $I->uncheckTableRowCheckbox(ArmaScriptProfilerModFixture::ID); // Mod + $I->click('Apply'); + + $I->seeResponseRedirectsTo('/mod-list/list'); + + /** @var ModList $modList */ + $modList = $I->grabEntityFromRepository(ModList::class, ['name' => 'Custom']); + $I->assertSame('Custom', $modList->getName()); + $I->assertSame('Custom modlist', $modList->getDescription()); + $I->assertSame(RhsModListFixture::OWNER_ID, $modList->getOwner()->getId()->toString()); + $I->assertSame(true, $modList->isActive()); + $I->assertSame(false, $modList->isApproved()); + $I->assertSame([ + CupModGroupFixture::ID, + ], array_map(fn (ModGroup $modGroup) => $modGroup->getId()->toString(), $modList->getModGroups())); + $I->assertSame([ + SogPrairieFireDlcFixture::ID, + ], array_map(fn (Dlc $dlc) => $dlc->getId()->toString(), $modList->getDlcs())); + $I->assertSame([ + AceInteractionMenuExpansionModFixture::ID, + ArmaForcesAceMedicalModFixture::ID, + LegacyArmaForcesModsModFixture::ID, + ArmaForcesJbadBuildingFixModFixture::ID, + ArmaForcesMedicalModFixture::ID, + ], array_map(fn (AbstractMod $mod) => $mod->getId()->toString(), $modList->getMods())); + + $I->assertSame('2020-01-01T00:00:00+00:00', $modList->getCreatedAt()->format(DATE_ATOM)); + $I->assertSame(null, $modList->getCreatedBy()); + // $I->assertSame('2021-01-01T00:00:00+00:00', $modList->getLastUpdatedAt()->format(DATE_ATOM)); // FIXME + // $I->assertSame($user, $modList->getLastUpdatedBy()); // FIXME + } + + public function updateModListAsAuthorizedUserWhenModListAlreadyExists(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListUpdate = true; + }); + + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + + $I->fillField('Mod list name', DefaultModListFixture::NAME); + $I->click('Apply'); + + $I->canSeeFormErrorMessage('name', 'Mod list with the same name "Default" already exist.'); + } + + public function updateModListAsAuthorizedUserWithoutRequiredData(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListUpdate = true; + }); + + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + + $I->fillField('Mod list name', ''); + $I->click('Apply'); + + $I->canSeeFormErrorMessage('name', 'This value should not be blank.'); + } + + public function updateModListAsAuthorizedUserWithDataTooLong(FunctionalTester $I): void + { + $I->amDiscordAuthenticatedAs(User1Fixture::ID, function (User $user): void { + $user->getPermissions()->modListUpdate = true; + }); + + $I->amOnPage(sprintf('/mod-list/%s/update', RhsModListFixture::NAME)); + + $I->fillField('Mod list name', str_repeat('a', 256)); + $I->fillField('Mod list description', str_repeat('a', 256)); + $I->click('Apply'); + + $I->canSeeFormErrorMessage('name', 'This value is too long. It should have 255 characters or less.'); + $I->canSeeFormErrorMessage('description', 'This value is too long. It should have 255 characters or less.'); + } +}