From 648f2678174f61cf9bc8c9b74ef002c1f03bb1f0 Mon Sep 17 00:00:00 2001 From: samuelgfeller Date: Fri, 12 Apr 2024 19:58:09 +0200 Subject: [PATCH] Updated samuelgfeller/test-traits to v6 [SLE-192] --- .github/workflows/build.yml | 2 +- .github/workflows/deploy.yml | 4 +-- README.md | 29 ++++++++++--------- composer.json | 12 ++++---- src/Application/Responder/RedirectHandler.php | 2 +- tests/Fixture/ClientFixture.php | 4 +-- tests/Fixture/ClientStatusFixture.php | 6 ++-- tests/Fixture/NoteFixture.php | 6 ++-- tests/Fixture/UserActivityFixture.php | 4 +-- tests/Fixture/UserFilterSettingFixture.php | 4 +-- tests/Fixture/UserFixture.php | 4 +-- tests/Fixture/UserRoleFixture.php | 4 +-- .../AccountUnlockActionTest.php | 6 ++-- .../Authentication/LoginPageActionTest.php | 2 +- .../Authentication/LoginSecurityTest.php | 2 +- .../Authentication/LoginSubmitActionTest.php | 8 ++--- ...PasswordForgottenEmailSubmitActionTest.php | 4 +-- .../PasswordResetSubmitActionTest.php | 6 ++-- .../RegisterVerifyActionTest.php | 6 ++-- .../Client/ApiClientCreateActionTest.php | 4 +-- .../Client/ClientCreateActionTest.php | 10 +++---- .../Client/ClientDeleteActionTest.php | 4 +-- .../Client/ClientListActionTest.php | 12 ++++---- .../Client/ClientReadPageActionTest.php | 6 ++-- .../Client/ClientUpdateActionTest.php | 20 ++++++------- .../Dashboard/DashboardPageActionTest.php | 10 +++---- .../DashboardTogglePanelActionTest.php | 2 +- .../Integration/Note/NoteCreateActionTest.php | 12 ++++---- .../Integration/Note/NoteDeleteActionTest.php | 8 ++--- tests/Integration/Note/NoteListActionTest.php | 20 ++++++------- .../Note/NoteReadPageActionTest.php | 8 ++--- .../Integration/Note/NoteUpdateActionTest.php | 16 +++++----- .../User/PasswordChangeSubmitActionTest.php | 2 +- .../Integration/User/UserCreateActionTest.php | 8 ++--- .../User/UserFetchActivityActionTest.php | 6 ++-- .../User/UserListPageActionTest.php | 4 +-- .../Integration/User/UserUpdateActionTest.php | 2 +- tests/Trait/AppTestTrait.php | 4 +-- tests/Trait/AuthorizationTestTrait.php | 4 +-- 39 files changed, 132 insertions(+), 145 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1be8a0f..b762b9af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -75,7 +75,7 @@ jobs: run: composer update --no-ansi --no-interaction --no-progress - name: Execute database migrations - run: composer migrate-prod + run: composer migrate:prod - name: Show test db tables run: mysql -uroot -proot -D ${{ matrix.test-database }} -e "SHOW TABLES;" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4a282fa2..656386d4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -63,7 +63,7 @@ jobs: script: | cd ${{ secrets.DEMO_PROJECT_ROOT }} chmod +x vendor/bin/phinx - composer migrate-prod + composer migrate:prod - name: ♥️ Sync files with care-point uses: SamKirkland/FTP-Deploy-Action@4.3.3 @@ -90,4 +90,4 @@ jobs: script: | cd ${{ secrets.CARE_POINT_PROJECT_ROOT }} chmod +x vendor/bin/phinx - composer migrate-prod \ No newline at end of file + composer migrate:prod \ No newline at end of file diff --git a/README.md b/README.md index eca63d50..079e2b66 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ It showcases the implementation of a simple yet robust with a variety of backend and frontend features built using the Slim 4 micro-framework. The base for this project was the official -[Slim-Skeleton](https://github.com/slimphp/Slim-Skeleton). +[Slim-Skeleton](https://github.com/slimphp/Slim-Skeleton) and the [slim4-skeleton](https://github.com/odan/slim4-skeleton). This repository can serve as a learning example or be adapted for developing new -applications. +applications. External library dependencies are [kept to a minimum](https://github.com/samuelgfeller/slim-example-project/wiki/Libraries-and-Framework) to facilitate maintenance and ensure long-term viability. @@ -32,17 +32,18 @@ A detailed [**documentation**](https://github.com/samuelgfeller/slim-example-pro Please read the [**installation guide**](https://github.com/samuelgfeller/slim-example-project/wiki/Installation-Guide) to get started. -Stripped down versions of this repository are available as skeleton templates: -[**slim-api-starter**](https://github.com/samuelgfeller/slim-api-starter) (only API) and -[**slim-starter**](https://github.com/samuelgfeller/slim-starter) (with frontend and API endpoint). +Stripped down versions of this repository are available as skeleton +templates. +With frontend [`slim-starter`](https://github.com/samuelgfeller/slim-starter) or just for an API: +[`slim-api-starter`](https://github.com/samuelgfeller/slim-api-starter). ## Features All the features were developed with an effort to ensure maximum user-friendliness. -The frontend should be intuitive, aesthetically pleasing, minimalistic, and functional. -The backend should be efficient and secure. +The frontend, intuitive, aesthetically pleasing, minimalistic, and functional. +The backend, efficient and secure. This project is currently designed for non-profit organizations or foundations that require a platform -to manage and maintain a record of communication through notes of people they assist. +to manage and maintain a record of communication through notes of people they help. **Project components:** @@ -56,8 +57,7 @@ to manage and maintain a record of communication through notes of people they as protection against rapid fire and distributed brute force attacks (time throttling and captcha) * [Localization](https://github.com/samuelgfeller/slim-example-project/wiki/Translations) - English, German and French * [Validation](https://github.com/samuelgfeller/slim-example-project/wiki/Validation) -* [Template rendering](https://github.com/samuelgfeller/slim-example-project/wiki/Template-rendering) with native PHP syntax -* [Editing values using `contenteditable`](https://github.com/samuelgfeller/slim-example-project/wiki/JavaScript-Frontend#contenteditable-fields) +* [Template rendering](https://github.com/samuelgfeller/slim-example-project/wiki/Template-rendering) with native PHP syntax (easily interchangeable with twig) * [Dark theme](https://github.com/samuelgfeller/slim-example-project/wiki/Dark-Theme) * [Advanced error handling](https://github.com/samuelgfeller/slim-example-project/wiki/Error-Handling) * [Integration & unit testing](https://github.com/samuelgfeller/slim-example-project/wiki/Writing-Tests) @@ -66,7 +66,8 @@ to manage and maintain a record of communication through notes of people they as * [Query Builder](https://github.com/samuelgfeller/slim-example-project/wiki/Repository-and-Query-Builder) * [Logging](https://github.com/samuelgfeller/slim-example-project/wiki/Logging) * [Mailing](https://github.com/samuelgfeller/slim-example-project/wiki/Mailing) -* Simple [console commands](https://github.com/samuelgfeller/slim-example-project/wiki/Console-Commands) +* [Simple console commands](https://github.com/samuelgfeller/slim-example-project/wiki/Console-Commands) +* [Scrutinizer](https://github.com/samuelgfeller/slim-example-project/wiki/How-to-set-up-Scrutinizer) * [GitHub Actions](https://github.com/samuelgfeller/slim-example-project/wiki/GitHub-Actions) **Functionalities demonstrating real-world features:** @@ -86,9 +87,9 @@ to manage and maintain a record of communication through notes of people they as Click to see demo Link: [Login](https://demo.slim-example-project.samuel-gfeller.ch) -Usernames: `admin@user.com` | `managing-advisor@user.com` | `advisor@user.com` | `newcomer@user.com` +Username: `admin@user.com` Password: `12345678` -The database is reset every hour. +The database is reset regularly. @@ -121,7 +122,7 @@ Of course, there are big frameworks that have their own well-established set of implementations of features. However, I find them often -too complex, where the code makes too much "behind the scenes" and lots of dependencies, +too complex, where the code makes too much "behind the scenes" and with lots of dependencies, which can lead to time-consuming refactoring on version changes. I also dislike having to follow the propitiatory rules of a framework and much prefer the freedom of a micro-framework and carefully diff --git a/composer.json b/composer.json index 81ca6ed8..0054dd0a 100644 --- a/composer.json +++ b/composer.json @@ -13,9 +13,9 @@ "selective/basepath": "^2.0", "symfony/mailer": "^7", "odan/session": "^6", - "nyholm/psr7": "^1.5", - "nyholm/psr7-server": "^1.1", - "fig/http-message-util": "^1.1", + "nyholm/psr7": "^1", + "nyholm/psr7-server": "^1", + "fig/http-message-util": "^1", "php": "^8.2", "ext-pdo": "*", "ext-json": "*", @@ -29,7 +29,7 @@ "jetbrains/phpstorm-attributes": "^1.0", "friendsofphp/php-cs-fixer": "^3", "odan/phinx-migrations-generator": "^6", - "samuelgfeller/test-traits": "^5" + "samuelgfeller/test-traits": "^6" }, "autoload": { "psr-4": { @@ -54,9 +54,9 @@ "phinx-migrations generate --overwrite -c config/env/env.phinx.php --ansi", "@schema:generate" ], - "migrate-prod": "vendor/bin/phinx migrate -c config/env/env.phinx.php --ansi -vvv", + "migrate:prod": "vendor/bin/phinx migrate -c config/env/env.phinx.php --ansi -vvv", "migrate": [ - "@migrate-prod", + "@migrate:prod", "@schema:generate" ], "schema:generate": [ diff --git a/src/Application/Responder/RedirectHandler.php b/src/Application/Responder/RedirectHandler.php index 0c298ef1..80d13d29 100644 --- a/src/Application/Responder/RedirectHandler.php +++ b/src/Application/Responder/RedirectHandler.php @@ -44,7 +44,7 @@ public function redirectToUrl( * @param ResponseInterface $response The response * @param string $routeName The redirect route name * @param array $data Named argument replacement data - * @param array $queryParams Optional query string parameters + * @param array $queryParams Optional query string parameters * * @return ResponseInterface The response */ diff --git a/tests/Fixture/ClientFixture.php b/tests/Fixture/ClientFixture.php index df39868e..935be849 100644 --- a/tests/Fixture/ClientFixture.php +++ b/tests/Fixture/ClientFixture.php @@ -2,12 +2,10 @@ namespace App\Test\Fixture; -use TestTraits\Interface\FixtureInterface; - /** * Client values that can be inserted into the database. */ -class ClientFixture implements FixtureInterface +class ClientFixture { // Table name public string $table = 'client'; diff --git a/tests/Fixture/ClientStatusFixture.php b/tests/Fixture/ClientStatusFixture.php index a34cb284..95c5ee91 100644 --- a/tests/Fixture/ClientStatusFixture.php +++ b/tests/Fixture/ClientStatusFixture.php @@ -2,23 +2,21 @@ namespace App\Test\Fixture; -use TestTraits\Interface\FixtureInterface; - /** * Client status values that can be inserted into the database * No fixture has to be inserted first. */ -class ClientStatusFixture implements FixtureInterface +class ClientStatusFixture { // Table name public string $table = 'client_status'; // Database records in 2d array public array $records = [ - // First record must have deleted_at => null [ 'id' => 1, 'name' => 'Action pending', + // The first record must have deleted_at => null 'deleted_at' => null, ], [ diff --git a/tests/Fixture/NoteFixture.php b/tests/Fixture/NoteFixture.php index 9acd07e5..c440100c 100644 --- a/tests/Fixture/NoteFixture.php +++ b/tests/Fixture/NoteFixture.php @@ -2,19 +2,16 @@ namespace App\Test\Fixture; -use TestTraits\Interface\FixtureInterface; - /** * Note values that can be inserted into the database. */ -class NoteFixture implements FixtureInterface +class NoteFixture { // Table name public string $table = 'note'; // Database records in 2d array public array $records = [ - // First record must have deleted_at => null [ 'id' => 1, 'user_id' => 10, @@ -24,6 +21,7 @@ class NoteFixture implements FixtureInterface 'hidden' => null, 'updated_at' => '2024-01-01 00:00:01', 'created_at' => '2024-01-01 00:00:01', + // The first record must have deleted_at => null 'deleted_at' => null, ], // Note id 2: is not main note and linked to user 10 and client 1 diff --git a/tests/Fixture/UserActivityFixture.php b/tests/Fixture/UserActivityFixture.php index 63d750a8..38f8c372 100644 --- a/tests/Fixture/UserActivityFixture.php +++ b/tests/Fixture/UserActivityFixture.php @@ -2,9 +2,7 @@ namespace App\Test\Fixture; -use TestTraits\Interface\FixtureInterface; - -class UserActivityFixture implements FixtureInterface +class UserActivityFixture { // Table name public string $table = 'user_activity'; diff --git a/tests/Fixture/UserFilterSettingFixture.php b/tests/Fixture/UserFilterSettingFixture.php index d46555a9..4703685a 100644 --- a/tests/Fixture/UserFilterSettingFixture.php +++ b/tests/Fixture/UserFilterSettingFixture.php @@ -2,9 +2,7 @@ namespace App\Test\Fixture; -use TestTraits\Interface\FixtureInterface; - -class UserFilterSettingFixture implements FixtureInterface +class UserFilterSettingFixture { // Table name public string $table = 'user_filter_setting'; diff --git a/tests/Fixture/UserFixture.php b/tests/Fixture/UserFixture.php index e5415e01..e54b6941 100644 --- a/tests/Fixture/UserFixture.php +++ b/tests/Fixture/UserFixture.php @@ -2,13 +2,11 @@ namespace App\Test\Fixture; -use TestTraits\Interface\FixtureInterface; - /** * User values that can be inserted into the database. * ! All user roles are inserted automatically for each test (in AppTestTrait). */ -class UserFixture implements FixtureInterface +class UserFixture { // Table name public string $table = 'user'; diff --git a/tests/Fixture/UserRoleFixture.php b/tests/Fixture/UserRoleFixture.php index dde0cbdb..f70e7aa0 100644 --- a/tests/Fixture/UserRoleFixture.php +++ b/tests/Fixture/UserRoleFixture.php @@ -2,9 +2,7 @@ namespace App\Test\Fixture; -use TestTraits\Interface\FixtureInterface; - -class UserRoleFixture implements FixtureInterface +class UserRoleFixture { // Table name public string $table = 'user_role'; diff --git a/tests/Integration/Authentication/AccountUnlockActionTest.php b/tests/Integration/Authentication/AccountUnlockActionTest.php index f95c555b..0d971c6a 100644 --- a/tests/Integration/Authentication/AccountUnlockActionTest.php +++ b/tests/Integration/Authentication/AccountUnlockActionTest.php @@ -42,7 +42,7 @@ public function testAccountUnlockAction(UserVerificationData $verification, stri { // Insert locked user $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, ['status' => UserStatus::Locked->value, 'id' => $verification->userId], ); @@ -87,7 +87,7 @@ public function testAccountUnlockActionInvalidExpiredToken( ): void { // Insert locked user $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, ['status' => UserStatus::Locked->value, 'id' => $verification->userId], ); @@ -133,7 +133,7 @@ public function testAccountUnlockActionAlreadyUnlocked( ): void { // Insert locked user $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, ['status' => UserStatus::Active->value, 'id' => $verification->userId], ); diff --git a/tests/Integration/Authentication/LoginPageActionTest.php b/tests/Integration/Authentication/LoginPageActionTest.php index d387ce4d..75664356 100644 --- a/tests/Integration/Authentication/LoginPageActionTest.php +++ b/tests/Integration/Authentication/LoginPageActionTest.php @@ -39,7 +39,7 @@ public function testLoginPageAction(): void public function testLoginPageActionAlreadyLoggedIn(): void { // Insert authenticated user - $userId = $this->insertFixture(new UserFixture())['id']; + $userId = $this->insertFixture(UserFixture::class)['id']; // Simulate logged-in user by setting the user_id session variable $this->container->get(SessionInterface::class)->set('user_id', $userId); // Prepare route to test the case when the user clicks on a login link with a redirect route diff --git a/tests/Integration/Authentication/LoginSecurityTest.php b/tests/Integration/Authentication/LoginSecurityTest.php index bcda6dd3..f39964e3 100644 --- a/tests/Integration/Authentication/LoginSecurityTest.php +++ b/tests/Integration/Authentication/LoginSecurityTest.php @@ -43,7 +43,7 @@ public function testLoginThrottlingWrongCredentials(): void $correctLoginRequestBody = ['email' => $email, 'password' => $password]; // Insert user fixture - $user = $this->insertFixture(new UserFixture(), [ + $user = $this->insertFixture(UserFixture::class, [ 'email' => $email, 'password_hash' => password_hash($password, PASSWORD_DEFAULT), ], ); diff --git a/tests/Integration/Authentication/LoginSubmitActionTest.php b/tests/Integration/Authentication/LoginSubmitActionTest.php index 0b0da135..055911b8 100644 --- a/tests/Integration/Authentication/LoginSubmitActionTest.php +++ b/tests/Integration/Authentication/LoginSubmitActionTest.php @@ -43,7 +43,7 @@ public function testLoginSubmitAction(): void { $loginValues = ['password' => '12345678', 'email' => 'user@example.com']; $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, [ 'password_hash' => password_hash($loginValues['password'], PASSWORD_DEFAULT), 'email' => $loginValues['email'], @@ -79,7 +79,7 @@ public function testLoginSubmitAction(): void */ public function testLoginSubmitActionWrongPassword(): void { - $this->insertFixture(new UserFixture()); + $this->insertFixture(UserFixture::class); $invalidCredentials = [ 'email' => 'admin@test.com', @@ -114,7 +114,7 @@ public function testLoginSubmitActionWrongPassword(): void #[DataProviderExternal(\App\Test\Provider\Authentication\AuthenticationProvider::class, 'invalidLoginCredentialsProvider')] public function testLoginSubmitActionInvalidValues(array $invalidLoginValues, string $errorMessage): void { - $this->insertFixture(new UserFixture()); + $this->insertFixture(UserFixture::class); // Create request $request = $this->createFormRequest('POST', $this->urlFor('login-submit'), $invalidLoginValues); @@ -148,7 +148,7 @@ public function testLoginSubmitActionNotActiveAccount(UserStatus $status, string { $loginValues = ['password' => '12345678', 'email' => 'user@example.com']; $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, [ 'password_hash' => password_hash($loginValues['password'], PASSWORD_DEFAULT), 'email' => $loginValues['email'], diff --git a/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php b/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php index 3b55998d..36a38baa 100644 --- a/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php +++ b/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php @@ -35,7 +35,7 @@ class PasswordForgottenEmailSubmitActionTest extends TestCase public function testPasswordForgottenEmailSubmit(): void { // Insert user - $userRow = $this->insertFixture(new UserFixture()); + $userRow = $this->insertFixture(UserFixture::class); $userId = $userRow['id']; $email = $userRow['email']; @@ -134,7 +134,7 @@ public function testPasswordForgottenEmailSubmitUserNotExisting(): void public function testPasswordForgottenEmailSubmitInvalidData(): void { // Insert user - $userRow = $this->insertFixture(new UserFixture()); + $userRow = $this->insertFixture(UserFixture::class); // Simulate logged-in user with id 2 $this->container->get(SessionInterface::class)->set('user_id', $userRow['id']); diff --git a/tests/Integration/Authentication/PasswordResetSubmitActionTest.php b/tests/Integration/Authentication/PasswordResetSubmitActionTest.php index 39620615..3c1657bf 100644 --- a/tests/Integration/Authentication/PasswordResetSubmitActionTest.php +++ b/tests/Integration/Authentication/PasswordResetSubmitActionTest.php @@ -44,7 +44,7 @@ public function testResetPasswordSubmit(UserVerificationData $verification, stri { $newPassword = 'new password'; // Insert user - $userRow = $this->insertFixture(new UserFixture(), ['id' => $verification->userId]); + $userRow = $this->insertFixture(UserFixture::class, ['id' => $verification->userId]); $this->insertFixtureRow('user_verification', $verification->toArrayForDatabase()); @@ -85,7 +85,7 @@ public function testResetPasswordSubmitInvalidToken( ): void { // User needed to insert verification $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, ['id' => $verification->userId, 'status' => UserStatus::Unverified->value], ); @@ -140,7 +140,7 @@ public function testResetPasswordSubmitInvalidData( // Invalid new password $newPassword = '1'; // Insert user id 2 role: user - $userRow = $this->insertFixture(new UserFixture(), ['id' => $verification->userId]); + $userRow = $this->insertFixture(UserFixture::class, ['id' => $verification->userId]); $this->insertFixtureRow('user_verification', $verification->toArrayForDatabase()); diff --git a/tests/Integration/Authentication/RegisterVerifyActionTest.php b/tests/Integration/Authentication/RegisterVerifyActionTest.php index 26ce397f..499f7c81 100644 --- a/tests/Integration/Authentication/RegisterVerifyActionTest.php +++ b/tests/Integration/Authentication/RegisterVerifyActionTest.php @@ -43,7 +43,7 @@ public function testRegisterVerification(UserVerificationData $verification, str { // User needed to insert verification (taking first record from userFixture) $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, ['id' => $verification->userId, 'status' => UserStatus::Unverified->value], ); @@ -90,7 +90,7 @@ public function testRegisterVerificationAlreadyVerified( ): void { // User needed to insert verification $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, ['id' => $verification->userId, 'status' => UserStatus::Active->value], ); @@ -139,7 +139,7 @@ public function testRegisterVerificationInvalidUsedExpiredToken( ): void { // User needed to insert verification $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, ['id' => $verification->userId, 'status' => UserStatus::Unverified->value], ); diff --git a/tests/Integration/Client/ApiClientCreateActionTest.php b/tests/Integration/Client/ApiClientCreateActionTest.php index 26dbb0c4..de0c056b 100644 --- a/tests/Integration/Client/ApiClientCreateActionTest.php +++ b/tests/Integration/Client/ApiClientCreateActionTest.php @@ -43,7 +43,7 @@ public function testApiClientSubmitCreateAction(): void { // Insert required client status $clientStatusId = $this->insertFixture( - new ClientStatusFixture(), + ClientStatusFixture::class, ['name' => ClientStatus::ACTION_PENDING->value], )['id']; @@ -114,7 +114,7 @@ public function testApiClientSubmitCreateActionInvalid( ): void { // Insert action pending client status because it's needed by the service function $this->insertFixture( - new ClientStatusFixture(), + ClientStatusFixture::class, ['name' => ClientStatus::ACTION_PENDING->value], ); diff --git a/tests/Integration/Client/ClientCreateActionTest.php b/tests/Integration/Client/ClientCreateActionTest.php index 62a5a685..9cf7a9e4 100644 --- a/tests/Integration/Client/ClientCreateActionTest.php +++ b/tests/Integration/Client/ClientCreateActionTest.php @@ -56,7 +56,7 @@ public function testClientSubmitCreateActionAuthorization( $this->insertUserFixturesWithAttributes($authenticatedUserRow, $userLinkedToClientRow); // Client status is not authorization relevant for client creation - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; $clientCreationValues = [ 'first_name' => 'New', @@ -161,10 +161,10 @@ public function testClientSubmitCreateActionInvalid(array $requestBody, array $j { // Insert managing advisor user which is allowed to create clients $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::MANAGING_ADVISOR]), )['id']; - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // To test note message validation when submitted in client creation form the client values have to be valid if (isset($requestBody['user_id']) && $requestBody['user_id'] === 'valid' && $requestBody['client_status_id'] === 'valid') { @@ -214,11 +214,11 @@ public function testClientSubmitCreateActionValid(array $requestBody): void { // Insert managing advisor user which is allowed to create clients $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::MANAGING_ADVISOR]), )['id']; // Insert mandatory field client status id - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Add valid client status id to request body $requestBody['client_status_id'] = $clientStatusId; diff --git a/tests/Integration/Client/ClientDeleteActionTest.php b/tests/Integration/Client/ClientDeleteActionTest.php index 17525532..310e1d97 100644 --- a/tests/Integration/Client/ClientDeleteActionTest.php +++ b/tests/Integration/Client/ClientDeleteActionTest.php @@ -51,10 +51,10 @@ public function testClientSubmitDeleteActionAuthorization( $this->insertUserFixturesWithAttributes($authenticatedUserRow, $userLinkedToClientRow); // Insert client status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client linked to given user $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['client_status_id' => $clientStatusId, 'user_id' => $userLinkedToClientRow['id']], ); diff --git a/tests/Integration/Client/ClientListActionTest.php b/tests/Integration/Client/ClientListActionTest.php index 600be4b3..89dc5a51 100644 --- a/tests/Integration/Client/ClientListActionTest.php +++ b/tests/Integration/Client/ClientListActionTest.php @@ -58,7 +58,7 @@ public function testClientListPageActionAuthorization(): void { // Insert logged-in user with the lowest privilege $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::NEWCOMER]), ); @@ -114,15 +114,15 @@ public function testClientListWithFilterAction( array $usersToInsert, array $clientStatusesToInsert, ): void { - $users = $this->insertFixture(new UserFixture(), $usersToInsert); - $statuses = $this->insertFixture(new ClientStatusFixture(), $clientStatusesToInsert); + $users = $this->insertFixture(UserFixture::class, $usersToInsert); + $statuses = $this->insertFixture(ClientStatusFixture::class, $clientStatusesToInsert); // Insert authenticated user before client $loggedInUserId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId($authenticatedUserAttributes), )['id']; // Insert clients - $clients = $this->insertFixture(new ClientFixture(), $clientsToInsert); + $clients = $this->insertFixture(ClientFixture::class, $clientsToInsert); // Add session $this->container->get(SessionInterface::class)->set('user_id', $loggedInUserId); @@ -203,7 +203,7 @@ public function testClientListWithFilterAction( #[DataProviderExternal(\App\Test\Provider\Client\ClientListProvider::class, 'clientListInvalidFilterCases')] public function testClientListActionInvalidFilters(array $filterQueryParamsArr, array $expectedBody): void { - $loggedInUserId = $this->insertFixture(new UserFixture())['id']; + $loggedInUserId = $this->insertFixture(UserFixture::class)['id']; $this->container->get(SessionInterface::class)->set('user_id', $loggedInUserId); $request = $this->createJsonRequest( diff --git a/tests/Integration/Client/ClientReadPageActionTest.php b/tests/Integration/Client/ClientReadPageActionTest.php index 4bdddf67..ee87e44a 100644 --- a/tests/Integration/Client/ClientReadPageActionTest.php +++ b/tests/Integration/Client/ClientReadPageActionTest.php @@ -36,12 +36,12 @@ public function testClientReadPageActionAuthenticated(): void { // Add needed database values to correctly display the page // Insert authenticated user permitted to see client read page - $userId = $this->insertFixture(new UserFixture())['id']; + $userId = $this->insertFixture(UserFixture::class)['id']; // Insert linked client status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client linked to user to be sure that the user is permitted to see the client read page $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['user_id' => $userId, 'client_status_id' => $clientStatusId], ); diff --git a/tests/Integration/Client/ClientUpdateActionTest.php b/tests/Integration/Client/ClientUpdateActionTest.php index d934775a..7ad4104c 100644 --- a/tests/Integration/Client/ClientUpdateActionTest.php +++ b/tests/Integration/Client/ClientUpdateActionTest.php @@ -63,7 +63,7 @@ public function testClientSubmitUpdateActionAuthorization( $this->insertUserFixturesWithAttributes($authenticatedUserRow, $userLinkedToClientRow); // Insert client status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client that will be used for this test $clientAttributes = ['client_status_id' => $clientStatusId, 'user_id' => $userLinkedToClientRow['id']]; // If deleted at is provided in the request data, it means that client should be undeleted @@ -71,19 +71,19 @@ public function testClientSubmitUpdateActionAuthorization( // Add deleted at to client attributes $clientAttributes = array_merge($clientAttributes, ['deleted_at' => date('Y-m-d H:i:s')]); } - $clientRow = $this->insertFixture(new ClientFixture(), $clientAttributes); + $clientRow = $this->insertFixture(ClientFixture::class, $clientAttributes); // Insert other user and client status used for the modification request if needed. if (isset($requestData['user_id'])) { // Replace the value "new" from the data to be changed array with a new, // different user id (user linked previously + 1) $requestData['user_id'] = $clientRow['user_id'] + 1; - $this->insertFixture(new UserFixture(), ['id' => $requestData['user_id']]); + $this->insertFixture(UserFixture::class, ['id' => $requestData['user_id']]); } if (isset($requestData['client_status_id'])) { // Add previously not existing client status to request data (previous client status + 1) $requestData['client_status_id'] = $clientRow['client_status_id'] + 1; - $this->insertFixture(new ClientStatusFixture(), ['id' => $requestData['client_status_id']]); + $this->insertFixture(ClientStatusFixture::class, ['id' => $requestData['client_status_id']]); } // Simulate logged-in user by setting the user_id session variable @@ -167,13 +167,13 @@ public function testClientSubmitUpdateActionInvalid(array $requestBody, array $j { // Insert user that is allowed to change content $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::MANAGING_ADVISOR]), )['id']; - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client that will be used for this test $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['client_status_id' => $clientStatusId, 'user_id' => $userId], ); @@ -231,13 +231,13 @@ public function testClientSubmitUpdateActionUnchangedContent(): void { // Insert user that is allowed to change content $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::MANAGING_ADVISOR]), )['id']; - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client that will be used for this test $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['client_status_id' => $clientStatusId, 'user_id' => $userId], ); diff --git a/tests/Integration/Dashboard/DashboardPageActionTest.php b/tests/Integration/Dashboard/DashboardPageActionTest.php index 2d938e47..fa552750 100644 --- a/tests/Integration/Dashboard/DashboardPageActionTest.php +++ b/tests/Integration/Dashboard/DashboardPageActionTest.php @@ -25,19 +25,19 @@ class DashboardPageActionTest extends TestCase public function testDashboardPageActionAuthenticated(): void { // Insert authenticated user - $loggedInUserId = $this->insertFixture(new UserFixture())['id']; + $loggedInUserId = $this->insertFixture(UserFixture::class)['id']; // Insert other users to have different user filter chips (to test logic for user activity panel) - $userId = $this->insertFixture(new UserFixture(), ['first_name' => 'Andrew'])['id']; + $userId = $this->insertFixture(UserFixture::class, ['first_name' => 'Andrew'])['id']; // Set user Andrew to active filter $this->insertFixture( - new UserFilterSettingFixture(), + UserFilterSettingFixture::class, ['module' => 'dashboard-user-activity', 'filter_id' => "user_$userId", 'user_id' => $loggedInUserId], ); // Insert another inactive user - $this->insertFixture(new UserFixture(), ['first_name' => 'Mike']); + $this->insertFixture(UserFixture::class, ['first_name' => 'Mike']); // A dashboard panel is for the status "action pending" and its id is retrieved by the code - $this->insertFixture(new ClientStatusFixture(), ['name' => 'Action pending']); + $this->insertFixture(ClientStatusFixture::class, ['name' => 'Action pending']); // Simulate logged-in user by setting the user_id session variable $this->container->get(SessionInterface::class)->set('user_id', $loggedInUserId); diff --git a/tests/Integration/Dashboard/DashboardTogglePanelActionTest.php b/tests/Integration/Dashboard/DashboardTogglePanelActionTest.php index 567e5e66..6cad0400 100644 --- a/tests/Integration/Dashboard/DashboardTogglePanelActionTest.php +++ b/tests/Integration/Dashboard/DashboardTogglePanelActionTest.php @@ -31,7 +31,7 @@ class DashboardTogglePanelActionTest extends TestCase public function testDashboardTogglePanelActionAuthenticated(): void { // Insert linked and authenticated user - $userId = $this->insertFixture(new UserFixture())['id']; + $userId = $this->insertFixture(UserFixture::class)['id']; // Simulate logged-in user by setting the user_id session variable $this->container->get(SessionInterface::class)->set('user_id', $userId); diff --git a/tests/Integration/Note/NoteCreateActionTest.php b/tests/Integration/Note/NoteCreateActionTest.php index 34feb74c..57a87035 100644 --- a/tests/Integration/Note/NoteCreateActionTest.php +++ b/tests/Integration/Note/NoteCreateActionTest.php @@ -57,10 +57,10 @@ public function testNoteSubmitCreateActionAuthorization( $this->insertUserFixturesWithAttributes($authenticatedUserRow, $linkedUserRow); // Insert needed client status fixture - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert one client linked to this user $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['user_id' => $linkedUserRow['id'], 'client_status_id' => $clientStatusId], ); @@ -156,21 +156,21 @@ public function testNoteCreateSubmitActionInvalid( ): void { // Insert user authorized to create $clientOwnerId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::ADVISOR]), )['id']; // Insert linked status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client row $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['user_id' => $clientOwnerId, 'client_status_id' => $clientStatusId], ); // Insert main note linked to client and user if data provider $existingMainNote is true if ($existingMainNote === true) { // Creating main note row with correct values - $mainNoteRow = (new NoteFixture())->getRecords()[0]; + $mainNoteRow = (new NoteFixture())->records[0]; $mainNoteRow['is_main'] = 1; $mainNoteRow['client_id'] = $clientRow['id']; $mainNoteRow['user_id'] = $clientOwnerId; diff --git a/tests/Integration/Note/NoteDeleteActionTest.php b/tests/Integration/Note/NoteDeleteActionTest.php index adcae178..c2c575cf 100644 --- a/tests/Integration/Note/NoteDeleteActionTest.php +++ b/tests/Integration/Note/NoteDeleteActionTest.php @@ -53,16 +53,16 @@ public function testNoteSubmitDeleteActionAuthorization( $this->insertUserFixturesWithAttributes($authenticatedUserRow, $linkedUserRow); // Insert linked status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert one client linked to this user $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['user_id' => $linkedUserRow['id'], 'client_status_id' => $clientStatusId], ); // Insert main note attached to client and given "owner" user $mainNoteData = $this->insertFixture( - new NoteFixture(), + NoteFixture::class, [ 'is_main' => 1, 'user_id' => $linkedUserRow['id'], @@ -72,7 +72,7 @@ public function testNoteSubmitDeleteActionAuthorization( // Insert normal note attached to client and given "owner" user $normalNoteData = $this->insertFixture( - new NoteFixture(), + NoteFixture::class, [ 'is_main' => 0, 'user_id' => $linkedUserRow['id'], diff --git a/tests/Integration/Note/NoteListActionTest.php b/tests/Integration/Note/NoteListActionTest.php index 6e1c7718..b2b0a954 100644 --- a/tests/Integration/Note/NoteListActionTest.php +++ b/tests/Integration/Note/NoteListActionTest.php @@ -64,21 +64,21 @@ public function testNoteListActionAuthorization( // because note read rights change (e.g. that newcomers may not see the notes from everyone), the // client owner id has to be added to the provider $clientOwnerId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::ADVISOR]), )['id']; // Insert linked status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client row $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['user_id' => $clientOwnerId, 'client_status_id' => $clientStatusId], ); // Insert linked note. Only one per test to simplify assertions with different privileges $noteData = $this->insertFixture( - new NoteFixture(), + NoteFixture::class, [ 'is_main' => 0, 'client_id' => $clientRow['id'], @@ -154,17 +154,17 @@ public function testNoteListFilter( ): void { // Authenticated user role not relevant here, and it should not cause issues (authorization tested above) $loggedInUserId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::MANAGING_ADVISOR]), )['id']; // Insert users without specific user role - $users = $this->insertFixture(new UserFixture(), $usersAttrToInsert); + $users = $this->insertFixture(UserFixture::class, $usersAttrToInsert); // Insert client status and client - $statusId = $this->insertFixture(new ClientStatusFixture())['id']; + $statusId = $this->insertFixture(ClientStatusFixture::class)['id']; $clientAttrToInsert['client_status_id'] = $statusId; - $clientId = $this->insertFixture(new ClientFixture(), $clientAttrToInsert)['id']; - $notes = $this->insertFixture(new NoteFixture(), $notesAttrToInsert); + $clientId = $this->insertFixture(ClientFixture::class, $clientAttrToInsert)['id']; + $notes = $this->insertFixture(NoteFixture::class, $notesAttrToInsert); // Add session $this->container->get(SessionInterface::class)->set('user_id', $loggedInUserId); @@ -223,7 +223,7 @@ public function testNoteListFilterInvalid( array $filterQueryParams, string $exceptionMessage, ): void { - $loggedInUserId = $this->insertFixture(new UserFixture())['id']; + $loggedInUserId = $this->insertFixture(UserFixture::class)['id']; $this->container->get(SessionInterface::class)->set('user_id', $loggedInUserId); $request = $this->createJsonRequest( diff --git a/tests/Integration/Note/NoteReadPageActionTest.php b/tests/Integration/Note/NoteReadPageActionTest.php index f08830f9..3a9823b1 100644 --- a/tests/Integration/Note/NoteReadPageActionTest.php +++ b/tests/Integration/Note/NoteReadPageActionTest.php @@ -42,7 +42,7 @@ public function testNoteReadPageActionAuthenticated(): void { // Insert authenticated user newcomer which is allowed to read the page (only his user will load however) $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::NEWCOMER]), )['id']; @@ -61,13 +61,13 @@ public function testNoteReadPageActionAuthenticated(): void self::assertSame($expectedClientReadUrl, $response->getHeaderLine('Location')); // *Test request on existing note - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; $clientId = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['client_status_id' => $clientStatusId], )['id']; $noteId = $this->insertFixture( - new NoteFixture(), + NoteFixture::class, ['client_id' => $clientId, 'user_id' => $userId], )['id']; diff --git a/tests/Integration/Note/NoteUpdateActionTest.php b/tests/Integration/Note/NoteUpdateActionTest.php index 31f70a50..93eb1e93 100644 --- a/tests/Integration/Note/NoteUpdateActionTest.php +++ b/tests/Integration/Note/NoteUpdateActionTest.php @@ -56,22 +56,22 @@ public function testNoteSubmitUpdateActionAuthorization( $this->insertUserFixturesWithAttributes($authenticatedUserRow, $linkedUserRow); // Insert linked status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert one client linked to this user $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['user_id' => $linkedUserRow['id'], 'client_status_id' => $clientStatusId], ); // Insert main note attached to client and given "owner" user $mainNoteRow = $this->insertFixture( - new NoteFixture(), + NoteFixture::class, ['is_main' => 1, 'user_id' => $linkedUserRow['id'], 'client_id' => $clientRow['id']], ); // Insert normal non-hidden note attached to client and given "owner" user $normalNoteRow = $this->insertFixture( - new NoteFixture(), + NoteFixture::class, ['is_main' => 0, 'user_id' => $linkedUserRow['id'], 'client_id' => $clientRow['id'], 'hidden' => 0], ); @@ -181,20 +181,20 @@ public function testNoteSubmitUpdateActionInvalid(array $invalidRequestBody, arr { // Insert authorized user $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::ADVISOR]), )['id']; // Insert linked status - $clientStatusId = $this->insertFixture(new ClientStatusFixture())['id']; + $clientStatusId = $this->insertFixture(ClientStatusFixture::class)['id']; // Insert client row $clientRow = $this->insertFixture( - new ClientFixture(), + ClientFixture::class, ['user_id' => $userId, 'client_status_id' => $clientStatusId], ); // Insert note linked to client and user $noteData = $this->insertFixture( - new NoteFixture(), + NoteFixture::class, ['client_id' => $clientRow['id'], 'user_id' => $userId, 'is_main' => 0], ); diff --git a/tests/Integration/User/PasswordChangeSubmitActionTest.php b/tests/Integration/User/PasswordChangeSubmitActionTest.php index 2e266225..61c908f2 100644 --- a/tests/Integration/User/PasswordChangeSubmitActionTest.php +++ b/tests/Integration/User/PasswordChangeSubmitActionTest.php @@ -136,7 +136,7 @@ public function testChangePasswordSubmitActionInvalid(array $requestBody, array { // Insert user that is allowed to change content $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::ADVISOR]), ); diff --git a/tests/Integration/User/UserCreateActionTest.php b/tests/Integration/User/UserCreateActionTest.php index 21ee2ee0..004ffd11 100644 --- a/tests/Integration/User/UserCreateActionTest.php +++ b/tests/Integration/User/UserCreateActionTest.php @@ -51,7 +51,7 @@ public function testUserSubmitCreateAuthorization( $userRoleFinderRepository = $this->container->get(UserRoleFinderRepository::class); // Insert authenticated user and user linked to resource with given attributes containing the user role $authenticatedUserRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId($authenticatedUserAttr), ); @@ -149,7 +149,7 @@ public function testUserSubmitCreateInvalid(array $requestBody, array $jsonRespo // Insert user that is allowed to create user without any authorization limitation (admin) // Even if user_role_id is empty string or null $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::ADMIN]), ); @@ -179,7 +179,7 @@ public function testUserSubmitCreateEmailAlreadyExists(): void { // Insert authenticated admin $adminRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::ADMIN]), ); // Simulate logged-in user by setting the user_id session variable @@ -187,7 +187,7 @@ public function testUserSubmitCreateEmailAlreadyExists(): void $existingEmail = 'email@address.com'; // Insert user with email that will be used in request to create a new one - $this->insertFixture(new UserFixture(), ['email' => $existingEmail]); + $this->insertFixture(UserFixture::class, ['email' => $existingEmail]); $request = $this->createJsonRequest( 'POST', diff --git a/tests/Integration/User/UserFetchActivityActionTest.php b/tests/Integration/User/UserFetchActivityActionTest.php index 9b380322..c9ae5553 100644 --- a/tests/Integration/User/UserFetchActivityActionTest.php +++ b/tests/Integration/User/UserFetchActivityActionTest.php @@ -40,11 +40,11 @@ public function testUserListActivityFetchAction(): void { // Insert authenticated but unauthorized user newcomer $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::NEWCOMER]), )['id']; // Insert user activity to cover most possible code with this test - $this->insertFixture(new UserActivityFixture(), ['user_id' => $userId]); + $this->insertFixture(UserActivityFixture::class, ['user_id' => $userId]); // Simulate logged-in user by setting the user_id session variable $this->container->get(SessionInterface::class)->set('user_id', $userId); @@ -75,7 +75,7 @@ public function testUserListActivityFetchActionWithoutQueryParams(): void { // Insert authenticated but unauthorized user newcomer $userId = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::NEWCOMER]), )['id']; // Simulate logged-in user by setting the user_id session variable diff --git a/tests/Integration/User/UserListPageActionTest.php b/tests/Integration/User/UserListPageActionTest.php index a14fbad7..75d6c94f 100644 --- a/tests/Integration/User/UserListPageActionTest.php +++ b/tests/Integration/User/UserListPageActionTest.php @@ -38,7 +38,7 @@ public function testUserListPageActionAuthenticatedUnauthorized(): void { // Insert authenticated but unauthorized user newcomer $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::NEWCOMER]), ); @@ -63,7 +63,7 @@ public function testUserListPageActionAuthenticatedAuthorized(): void { // Insert authenticated user newcomer which is allowed to read the page (only his user will load however) $userRow = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::MANAGING_ADVISOR]), ); diff --git a/tests/Integration/User/UserUpdateActionTest.php b/tests/Integration/User/UserUpdateActionTest.php index bc5b3335..b18accb8 100644 --- a/tests/Integration/User/UserUpdateActionTest.php +++ b/tests/Integration/User/UserUpdateActionTest.php @@ -126,7 +126,7 @@ public function testUserSubmitUpdateInvalid(array $requestBody, array $jsonRespo // Insert user that is allowed to change content (advisor owner) $userRow = $this->insertFixture( // Replace user_role_id enum case with database id with AuthorizationTestTrait function addUserRoleId() - new UserFixture(), + UserFixture::class, $this->addUserRoleId(['user_role_id' => UserRole::ADVISOR]), ); diff --git a/tests/Trait/AppTestTrait.php b/tests/Trait/AppTestTrait.php index e92ad0cb..b018d8ce 100644 --- a/tests/Trait/AppTestTrait.php +++ b/tests/Trait/AppTestTrait.php @@ -47,9 +47,9 @@ protected function setUp(): void $this->setUpDatabase($this->container->get('settings')['root_dir'] . '/resources/schema/schema.sql'); // If fixtureTestTrait is included in the test class, insert default user roles - if (method_exists($this, 'insertFixture')) { + if (method_exists($this, 'insertDefaultFixtureRecords')) { // Automatically insert user roles - $this->insertDefaultFixtures([UserRoleFixture::class]); + $this->insertDefaultFixtureRecords([UserRoleFixture::class]); } } } diff --git a/tests/Trait/AuthorizationTestTrait.php b/tests/Trait/AuthorizationTestTrait.php index 11d4e253..17ca079b 100644 --- a/tests/Trait/AuthorizationTestTrait.php +++ b/tests/Trait/AuthorizationTestTrait.php @@ -60,7 +60,7 @@ protected function insertUserFixturesWithAttributes(array &$authenticatedUserAtt $authenticatedUserAttrOriginal = $authenticatedUserAttr; // Insert authenticated user and user linked to resource with given attributes containing the user role $authenticatedUserAttr = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId($authenticatedUserAttr), ); if ($authenticatedUserAttrOriginal === $userAttr) { @@ -71,7 +71,7 @@ protected function insertUserFixturesWithAttributes(array &$authenticatedUserAtt } else { // If authenticated user and owner user is not the same, insert owner $userAttr = $this->insertFixture( - new UserFixture(), + UserFixture::class, $this->addUserRoleId($userAttr), ); }