diff --git a/public/assets/user/create/user-create-modal.html.js b/public/assets/user/create/user-create-modal.html.js index 7e5b80fe..bd176b3a 100644 --- a/public/assets/user/create/user-create-modal.html.js +++ b/public/assets/user/create/user-create-modal.html.js @@ -42,7 +42,7 @@ export function displayUserCreateModal() {
-
diff --git a/public/assets/user/list/user-list-card.html.js b/public/assets/user/list/user-list-card.html.js index cdb9c7a8..0a069912 100644 --- a/public/assets/user/list/user-list-card.html.js +++ b/public/assets/user/list/user-list-card.html.js @@ -11,7 +11,7 @@ import {html} from "../../general/general-js/functions.js?v=0.4.1"; export function getUserCardHtml(user, statuses) { return `
-

${user.firstName !== null ? html(user.firstName) : ''} ${user.surname !== null ? html(user.surname) : ''}

+

${user.firstName !== null ? html(user.firstName) : ''} ${user.lastName !== null ? html(user.lastName) : ''}

email ${html(user.email)} diff --git a/public/assets/user/read/user-read-update-main.js b/public/assets/user/read/user-read-update-main.js index 27d212ff..e33ecdef 100644 --- a/public/assets/user/read/user-read-update-main.js +++ b/public/assets/user/read/user-read-update-main.js @@ -18,7 +18,7 @@ loadUserActivities(`user=${userId}`); document.querySelector('#edit-first-name-btn')?.addEventListener('click', makeUserFieldEditable); document.querySelector('h1[data-name="first_name"]')?.addEventListener('dblclick', makeUserFieldEditable); document.querySelector('#edit-last-name-btn')?.addEventListener('click', makeUserFieldEditable); -document.querySelector('h1[data-name="surname"]')?.addEventListener('dblclick', makeUserFieldEditable); +document.querySelector('h1[data-name="last_name"]')?.addEventListener('dblclick', makeUserFieldEditable); document.querySelector('#edit-email-btn')?.addEventListener('click', makeUserFieldEditable); document.querySelector('[data-name="email"]')?.addEventListener('dblclick', makeUserFieldEditable); diff --git a/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php b/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php index d26a0f3e..ff9c098f 100644 --- a/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php +++ b/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php @@ -422,7 +422,7 @@ public function change() 'encoding' => 'utf8mb4', 'after' => 'id', ]) - ->addColumn('surname', 'string', [ + ->addColumn('last_name', 'string', [ 'null' => true, 'default' => null, 'limit' => 100, @@ -434,7 +434,7 @@ public function change() 'null' => false, 'default' => '0', 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'surname', + 'after' => 'last_name', ]) ->addColumn('status', 'enum', [ 'null' => true, diff --git a/resources/schema/schema.php b/resources/schema/schema.php index 3510c66e..08d3d362 100644 --- a/resources/schema/schema.php +++ b/resources/schema/schema.php @@ -1751,11 +1751,11 @@ 'IS_GENERATED' => 'NEVER', 'GENERATION_EXPRESSION' => NULL, ), - 'surname' => + 'last_name' => array ( 'TABLE_CATALOG' => 'def', 'TABLE_NAME' => 'user', - 'COLUMN_NAME' => 'surname', + 'COLUMN_NAME' => 'last_name', 'ORDINAL_POSITION' => 3, 'COLUMN_DEFAULT' => 'NULL', 'IS_NULLABLE' => 'YES', diff --git a/resources/schema/schema.sql b/resources/schema/schema.sql index 1def218a..9fad66d6 100644 --- a/resources/schema/schema.sql +++ b/resources/schema/schema.sql @@ -7,7 +7,7 @@ CREATE TABLE `authentication_log` ( `created_at` datetime DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `authentication_log_user_id_fk` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `client` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -29,14 +29,14 @@ CREATE TABLE `client` ( PRIMARY KEY (`id`), KEY `FK_client_user` (`user_id`), KEY `FK_client_status` (`client_status_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Advisors help and consult clients'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Advisors help and consult clients'; CREATE TABLE `client_status` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL DEFAULT '0', `deleted_at` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Client status'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Client status'; CREATE TABLE `email_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -48,7 +48,7 @@ CREATE TABLE `email_log` ( `created_at` datetime DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `email_log_user_id_fk` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `note` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -63,7 +63,7 @@ CREATE TABLE `note` ( PRIMARY KEY (`id`), KEY `FK__user` (`user_id`), KEY `FK_note_client` (`client_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `phinx_migration_log` ( `version` bigint(20) NOT NULL, @@ -77,7 +77,7 @@ CREATE TABLE `phinx_migration_log` ( CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(100) DEFAULT NULL, - `surname` varchar(100) DEFAULT NULL, + `last_name` varchar(100) DEFAULT NULL, `user_role_id` int(11) NOT NULL DEFAULT 0, `status` enum('active','locked','unverified','suspended') DEFAULT 'unverified', `email` varchar(254) NOT NULL, @@ -89,7 +89,7 @@ CREATE TABLE `user` ( `deleted_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK_user_user_role` (`user_role_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `user_activity` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -103,7 +103,7 @@ CREATE TABLE `user_activity` ( `user_agent` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), KEY `user_activity_user_id_fk` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `user_filter_setting` ( `user_id` int(11) NOT NULL, @@ -117,7 +117,7 @@ CREATE TABLE `user_role` ( `name` varchar(30) NOT NULL, `hierarchy` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `user_verification` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -129,4 +129,4 @@ CREATE TABLE `user_verification` ( `deleted_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK__user_table` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; \ No newline at end of file diff --git a/resources/seeds/AdminUserSeeder.php b/resources/seeds/AdminUserSeeder.php index b6a140f9..63b011eb 100644 --- a/resources/seeds/AdminUserSeeder.php +++ b/resources/seeds/AdminUserSeeder.php @@ -32,7 +32,7 @@ public function run(): void $userRows = [ [ 'first_name' => 'Admin', - 'surname' => 'Admin', + 'last_name' => 'Admin', 'user_role_id' => 1, 'status' => 'active', 'email' => 'admin@user.com', diff --git a/resources/seeds/UserSeeder.php b/resources/seeds/UserSeeder.php index 0deaf1df..4a7242c6 100644 --- a/resources/seeds/UserSeeder.php +++ b/resources/seeds/UserSeeder.php @@ -34,7 +34,7 @@ public function run(): void [ 'id' => 2, 'first_name' => 'Managing-advisor', - 'surname' => 'Surname', + 'last_name' => 'Last name', 'user_role_id' => 2, 'status' => 'active', 'language' => 'en_US', @@ -44,7 +44,7 @@ public function run(): void [ 'id' => 3, 'first_name' => 'Advisor', - 'surname' => 'Surname', + 'last_name' => 'Surname', 'user_role_id' => 3, 'status' => 'active', 'language' => 'de_CH', @@ -54,7 +54,7 @@ public function run(): void [ 'id' => 4, 'first_name' => 'Newcomer', - 'surname' => 'Surname', + 'last_name' => 'Surname', 'user_role_id' => 4, 'status' => 'active', 'language' => 'fr_CH', diff --git a/src/Domain/Client/Repository/ClientFinderRepository.php b/src/Domain/Client/Repository/ClientFinderRepository.php index f9133c2e..f1c279b9 100644 --- a/src/Domain/Client/Repository/ClientFinderRepository.php +++ b/src/Domain/Client/Repository/ClientFinderRepository.php @@ -45,7 +45,7 @@ public function findClientsWithResultAggregate(array $whereArray = ['client.dele 'deleted_at' => 'client.deleted_at', // User data prefixed with user_ 'user_first_name' => 'user.first_name', - 'user_surname' => 'user.surname', + 'user_last_name' => 'user.last_name', // Client status data prefixed with client_status_ 'client_status_name' => 'client_status.name', ])// Multiple joins doc: https://book.cakephp.org/4/en/orm/query-builder.html#adding-joins @@ -116,7 +116,7 @@ public function findClientAggregateByIdIncludingDeleted(int $id): ClientReadResu 'deleted_at' => 'client.deleted_at', // User data prefixed with user_ 'user_first_name' => 'user.first_name', - 'user_surname' => 'user.surname', + 'user_last_name' => 'user.last_name', // Client status data prefixed with client_status_ 'client_status_name' => 'client_status.name', // Main note data loaded in page renderer prefixed with `note_` diff --git a/src/Domain/Note/Repository/NoteFinderRepository.php b/src/Domain/Note/Repository/NoteFinderRepository.php index 3d8dbd6e..6426554d 100644 --- a/src/Domain/Note/Repository/NoteFinderRepository.php +++ b/src/Domain/Note/Repository/NoteFinderRepository.php @@ -56,7 +56,7 @@ public function findAllNotesExceptMainByUserId(int $userId): array { $query = $this->queryFactory->selectQuery()->from('note'); - $concatName = $query->func()->concat(['user.first_name' => 'identifier', ' ', 'user.surname' => 'identifier']); + $concatName = $query->func()->concat(['user.first_name' => 'identifier', ' ', 'user.last_name' => 'identifier']); $query->select(array_merge($this->noteResultFields, ['user_full_name' => $concatName])) ->join(['table' => 'user', 'conditions' => 'note.user_id = user.id']) @@ -87,7 +87,7 @@ public function findAllNotesExceptMainWithUserByClientId(int $clientId): array $concatName = $query->func()->concat([ $query->func()->coalesce(['user.first_name' => 'identifier', '']), ' ', - $query->func()->coalesce(['user.surname' => 'identifier', '']), + $query->func()->coalesce(['user.last_name' => 'identifier', '']), ]); $query->select(array_merge($this->noteResultFields, ['user_full_name' => $concatName])) @@ -123,7 +123,7 @@ public function findMostRecentNotes(int $notesAmount): array $concatUserName = $query->func()->concat( // Not very sexy to put IFNULL function there but with "identifier", cake interprets the string literally - ['IFNULL(user.first_name, "")' => 'identifier', ' ', 'IFNULL(user.surname, "")' => 'identifier'] + ['IFNULL(user.first_name, "")' => 'identifier', ' ', 'IFNULL(user.last_name, "")' => 'identifier'] ); $concatClientName = $query->func()->concat( ['IFNULL(client.first_name, "")' => 'identifier', ' ', 'IFNULL(client.last_name, "")' => 'identifier'] diff --git a/src/Domain/Note/Service/NoteCreator.php b/src/Domain/Note/Service/NoteCreator.php index 4e3bf2c7..a1749ab6 100644 --- a/src/Domain/Note/Service/NoteCreator.php +++ b/src/Domain/Note/Service/NoteCreator.php @@ -59,7 +59,7 @@ public function createNote(array $noteValues): array return [ 'note_id' => $noteId, - 'user_full_name' => $user->firstName . ' ' . $user->surname, + 'user_full_name' => $user->firstName . ' ' . $user->lastName, 'formatted_creation_timestamp' => $dateFormatter->format($noteCreatedAtTimestamp), ]; } diff --git a/src/Domain/User/Data/UserData.php b/src/Domain/User/Data/UserData.php index fa7feaa8..1c132974 100644 --- a/src/Domain/User/Data/UserData.php +++ b/src/Domain/User/Data/UserData.php @@ -11,7 +11,7 @@ class UserData implements \JsonSerializable // Variable names matching database columns (camelCase instead of snake_case) public ?int $id; // Mysql always returns string from db https://stackoverflow.com/a/5323169/9013718 public ?string $firstName; - public ?string $surname; + public ?string $lastName; // Email has to be default null as it is an indicator that user obj is empty in AuthService register function public ?string $email; public ?string $password; @@ -30,7 +30,7 @@ public function __construct(array $userData = []) // Keys may be taken from view form or database, so they have to correspond to both; otherwise use mapper $this->id = $userData['id'] ?? null; $this->firstName = $userData['first_name'] ?? null; - $this->surname = $userData['surname'] ?? null; + $this->lastName = $userData['last_name'] ?? null; $this->email = $userData['email'] ?? null; $this->password = $userData['password'] ?? null; $this->password2 = $userData['password2'] ?? null; @@ -47,13 +47,13 @@ public function __construct(array $userData = []) } /** - * Returns the first and surname in one string separated by a whitespace. + * Returns the first and lastName in one string separated by a whitespace. * * @return string */ public function getFullName(): string { - return $this->firstName . ' ' . $this->surname; + return $this->firstName . ' ' . $this->lastName; } /** @@ -68,7 +68,7 @@ public function toArrayForDatabase(): array return [ 'id' => $this->id, 'first_name' => $this->firstName, - 'surname' => $this->surname, + 'last_name' => $this->lastName, 'email' => $this->email, 'password_hash' => $this->passwordHash, 'user_role_id' => $this->userRoleId, @@ -83,7 +83,7 @@ public function jsonSerialize(): array return [ 'id' => $this->id, 'firstName' => $this->firstName, - 'surname' => $this->surname, + 'lastName' => $this->lastName, 'email' => $this->email, 'status' => $this->status, 'userRoleId' => $this->userRoleId, diff --git a/src/Domain/User/Repository/UserFinderRepository.php b/src/Domain/User/Repository/UserFinderRepository.php index 82c2b7bc..06ffbd90 100644 --- a/src/Domain/User/Repository/UserFinderRepository.php +++ b/src/Domain/User/Repository/UserFinderRepository.php @@ -13,7 +13,7 @@ class UserFinderRepository private array $fields = [ 'id', 'first_name', - 'surname', + 'last_name', 'email', 'user_role_id', 'status', diff --git a/src/Domain/User/Service/Authorization/UserPermissionVerifier.php b/src/Domain/User/Service/Authorization/UserPermissionVerifier.php index 25815ca2..19342bf1 100644 --- a/src/Domain/User/Service/Authorization/UserPermissionVerifier.php +++ b/src/Domain/User/Service/Authorization/UserPermissionVerifier.php @@ -185,7 +185,7 @@ public function isGrantedToUpdate(array $userDataToUpdate, string|int $userIdToU // Personal info are values such as first name, last name and email $grantedUpdateKeys[] = 'personal_info'; $grantedUpdateKeys[] = 'first_name'; - $grantedUpdateKeys[] = 'surname'; + $grantedUpdateKeys[] = 'last_name'; $grantedUpdateKeys[] = 'email'; $grantedUpdateKeys[] = 'password_hash'; $grantedUpdateKeys[] = 'theme'; diff --git a/src/Domain/User/Service/UserNameAbbreviator.php b/src/Domain/User/Service/UserNameAbbreviator.php index 9d7c2166..f6210ffc 100644 --- a/src/Domain/User/Service/UserNameAbbreviator.php +++ b/src/Domain/User/Service/UserNameAbbreviator.php @@ -28,7 +28,7 @@ private function buildLastNameAbbreviation(string $lastName, array $usersToCheck ): string { // When $i (amount of letters) of last name to abbreviate is the same as the full name, // there is no short form and the function must end as it would cause infinite recursion. - // Checks if short form ($i letters from the beginning of surname) is contained in name to check + // Checks if short form ($i letters from the beginning of lastName) is contained in name to check if (strlen($lastName) > $i && str_contains($lastNameToCheck, substr($lastName, 0, $i))) { // Increase number of letters that should be used of the last name as it exists in the name to check $i++; @@ -41,7 +41,7 @@ private function buildLastNameAbbreviation(string $lastName, array $usersToCheck return $shortName; }; // Always privilege longest lastname abbreviation as it means that this length necessary - if (strlen($builtLastName = $buildLastName($lastName, (string)$userToCheck->surname)) > strlen( + if (strlen($builtLastName = $buildLastName($lastName, (string)$userToCheck->lastName)) > strlen( $abbreviatedLastName )) { $abbreviatedLastName = $builtLastName; @@ -94,7 +94,7 @@ public function abbreviateUserNames(array $users): array unset($usersToCheckAgainst[$userId]); // Call recursive function which compares last name of currently iterated user with other users with same // first name and returns the shortest version of non-duplicate lastname - $lastNameAbbr = $this->buildLastNameAbbreviation((string)$user->surname, $usersToCheckAgainst); + $lastNameAbbr = $this->buildLastNameAbbreviation((string)$user->lastName, $usersToCheckAgainst); $outputNames[(int)$userId] = $user->firstName . ' ' . $lastNameAbbr; } } diff --git a/src/Domain/User/Service/UserUpdater.php b/src/Domain/User/Service/UserUpdater.php index 3a5a9b9c..23126049 100644 --- a/src/Domain/User/Service/UserUpdater.php +++ b/src/Domain/User/Service/UserUpdater.php @@ -49,7 +49,7 @@ public function updateUser(int $userIdToChange, array $userValues): bool // Check that keys are one of the database columns that may be updated if (in_array($column, [ 'first_name', - 'surname', + 'last_name', 'email', 'status', 'user_role_id', diff --git a/src/Domain/User/Service/UserValidator.php b/src/Domain/User/Service/UserValidator.php index fb9b06fd..0350a4d6 100644 --- a/src/Domain/User/Service/UserValidator.php +++ b/src/Domain/User/Service/UserValidator.php @@ -33,16 +33,16 @@ public function validateUserValues(array $userValues, bool $isCreateMode = true) // For the user, there are no optional fields meaning that if any field is passed, it has to contain a value. $validator - // First name and surname are required to have values if they're given so no allowEmptyString + // First name and lastName are required to have values if they're given so no allowEmptyString ->requirePresence('first_name', $isCreateMode, __('Field is required')) ->minLength('first_name', 2, __('Minimum length is %d', 2)) ->maxLength('first_name', 100, __('Maximum length is %d', 100)) // Disallow empty strings as field is required ->notEmptyString('first_name', __('Required')) - ->requirePresence('surname', $isCreateMode, __('Field is required')) - ->minLength('surname', 2, __('Minimum length is %d', 2)) - ->maxLength('surname', 100, __('Maximum length is %d', 100)) - ->notEmptyString('surname', __('Required')) + ->requirePresence('last_name', $isCreateMode, __('Field is required')) + ->minLength('last_name', 2, __('Minimum length is %d', 2)) + ->maxLength('last_name', 100, __('Maximum length is %d', 100)) + ->notEmptyString('last_name', __('Required')) ->requirePresence('email', $isCreateMode, __('Field is required')) // email() automatically disallows empty strings ->email('email', false, __('Invalid email')) diff --git a/src/Domain/UserActivity/Service/UserActivityFinder.php b/src/Domain/UserActivity/Service/UserActivityFinder.php index 8a5dcbdb..9f6ce9be 100644 --- a/src/Domain/UserActivity/Service/UserActivityFinder.php +++ b/src/Domain/UserActivity/Service/UserActivityFinder.php @@ -86,7 +86,7 @@ private function findUserActivitiesGroupedByDate(int|string|array $userIds): arr if (count($userIds) > 1) { $userRow = $this->userFinderRepository->findUserById((int)$userActivity->userId); $userActivity->timeAndActionName = '' . $userRow['first_name'] . ' ' - . $userRow['surname'] . ' • ' . + . $userRow['last_name'] . ' • ' . $userActivity->timeAndActionName; } $formattedDate = ucfirst( diff --git a/templates/user/user-read.html.php b/templates/user/user-read.html.php index 63f053bf..a1224bca 100644 --- a/templates/user/user-read.html.php +++ b/templates/user/user-read.html.php @@ -60,8 +60,8 @@ class="contenteditable-edit-icon cursor-pointer" id="edit-last-name-btn"> -

surname) ? html($user->surname) : ' ' ?>

+

lastName) ? html($user->lastName) : ' ' ?>

diff --git a/tests/Fixture/UserFixture.php b/tests/Fixture/UserFixture.php index 1cceefff..c98037d1 100644 --- a/tests/Fixture/UserFixture.php +++ b/tests/Fixture/UserFixture.php @@ -17,7 +17,7 @@ class UserFixture [ 'id' => 1, 'first_name' => 'Example', - 'surname' => 'User', + 'last_name' => 'User', 'email' => 'user@example.com', // Cleartext password is 12345678 'password_hash' => '$2y$10$r8t5LRX7Hq1.22/h6dwe1uLrrhZnGTOnsue5p/rUgeD8BAhDwFhk2', diff --git a/tests/Integration/Authentication/LoginSubmitActionTest.php b/tests/Integration/Authentication/LoginSubmitActionTest.php index 6f4ab3da..416ba0a0 100644 --- a/tests/Integration/Authentication/LoginSubmitActionTest.php +++ b/tests/Integration/Authentication/LoginSubmitActionTest.php @@ -181,7 +181,7 @@ public function testLoginSubmitActionNotActiveAccount(UserStatus $status, string $email, 'To', $userRow['first_name'] . ' ' . - $userRow['surname'] . ' <' . $loginValues['email'] . '>' + $userRow['last_name'] . ' <' . $loginValues['email'] . '>' ); // Assert that there is a verification token in the database if unverified or locked diff --git a/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php b/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php index 3d645b0a..e4cdfcef 100644 --- a/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php +++ b/tests/Integration/Authentication/PasswordForgottenEmailSubmitActionTest.php @@ -69,7 +69,7 @@ public function testPasswordForgottenEmailSubmit(): void $this->assertEmailHeaderSame( $mailerMessage, 'To', - $userRow['first_name'] . ' ' . $userRow['surname'] . ' <' . $email . '>' + $userRow['first_name'] . ' ' . $userRow['last_name'] . ' <' . $email . '>' ); // Database assertions diff --git a/tests/Integration/Note/NoteCreateActionTest.php b/tests/Integration/Note/NoteCreateActionTest.php index 4056c045..0f902221 100644 --- a/tests/Integration/Note/NoteCreateActionTest.php +++ b/tests/Integration/Note/NoteCreateActionTest.php @@ -115,7 +115,7 @@ public function testNoteSubmitCreateActionAuthorization( $expectedResponseJson = [ 'status' => 'success', 'data' => [ - 'userFullName' => $authenticatedUserRow['first_name'] . ' ' . $authenticatedUserRow['surname'], + 'userFullName' => $authenticatedUserRow['first_name'] . ' ' . $authenticatedUserRow['last_name'], 'noteId' => $noteDbRow['id'], 'createdDateFormatted' => $dateFormatter->format(new \DateTime($noteDbRow['created_at'])), ], diff --git a/tests/Integration/Note/NoteListActionTest.php b/tests/Integration/Note/NoteListActionTest.php index e64ddbe9..d2612d11 100644 --- a/tests/Integration/Note/NoteListActionTest.php +++ b/tests/Integration/Note/NoteListActionTest.php @@ -123,7 +123,7 @@ public function testNoteListActionAuthorization( // Same format as in NoteFinder:findAllNotesFromClientExceptMain() 'createdAt' => $dateFormatter->format(new \DateTime($noteData['created_at'])), 'updatedAt' => $dateFormatter->format(new \DateTime($noteData['updated_at'])), - 'userFullName' => $userLinkedToNoteRow['first_name'] . ' ' . $userLinkedToNoteRow['surname'], + 'userFullName' => $userLinkedToNoteRow['first_name'] . ' ' . $userLinkedToNoteRow['last_name'], 'clientFullName' => null, // Has to match privilege from notePrivilegeDeterminer.php (rules are in notePermissionVerifier.php) 'privilege' => $expectedResult['privilege']->name, diff --git a/tests/Integration/User/UserCreateActionTest.php b/tests/Integration/User/UserCreateActionTest.php index 2cf9c49a..e4a91c20 100644 --- a/tests/Integration/User/UserCreateActionTest.php +++ b/tests/Integration/User/UserCreateActionTest.php @@ -59,7 +59,7 @@ public function testUserSubmitCreateAuthorization( $requestData = [ 'first_name' => 'Danny', - 'surname' => 'Ric', + 'last_name' => 'Ric', 'email' => 'daniel.riccardo@notmclaren.com', 'password' => '12345678', 'password2' => '12345678', @@ -125,7 +125,7 @@ public function testUserSubmitCreateAuthorization( $email, 'To', $requestData['first_name'] . ' ' . - $requestData['surname'] . ' <' . $requestData['email'] . '>' + $requestData['last_name'] . ' <' . $requestData['email'] . '>' ); } else { // Database must be unchanged // Only 1 row (authenticated user) expected in user table @@ -215,7 +215,7 @@ public function testUserSubmitCreateEmailAlreadyExists(): void $this->urlFor('user-create-submit'), [ 'first_name' => 'New User', - 'surname' => 'Same Email', + 'last_name' => 'Same Email', 'email' => $existingEmail, 'password' => '12345678', 'password2' => '12345678', diff --git a/tests/Integration/User/UserListActionTest.php b/tests/Integration/User/UserListActionTest.php index a95a8f0b..09516588 100644 --- a/tests/Integration/User/UserListActionTest.php +++ b/tests/Integration/User/UserListActionTest.php @@ -69,7 +69,7 @@ public function testUserListAuthorization( // camelCase according to Google recommendation https://stackoverflow.com/a/19287394/9013718 'id' => $authenticatedUserRow['id'], 'firstName' => $authenticatedUserRow['first_name'], - 'surname' => $authenticatedUserRow['surname'], + 'lastName' => $authenticatedUserRow['last_name'], 'email' => $authenticatedUserRow['email'], 'status' => $authenticatedUserRow['status'], 'userRoleId' => $authenticatedUserRow['user_role_id'], @@ -85,7 +85,7 @@ public function testUserListAuthorization( $expectedResponseArray['userResultDataArray'][] = [ 'id' => $userRow['id'], 'firstName' => $userRow['first_name'], - 'surname' => $userRow['surname'], + 'lastName' => $userRow['last_name'], 'email' => $userRow['email'], 'status' => $userRow['status'], 'userRoleId' => $userRow['user_role_id'], diff --git a/tests/Provider/Client/ClientListProvider.php b/tests/Provider/Client/ClientListProvider.php index 1d2198cf..6a0694dd 100644 --- a/tests/Provider/Client/ClientListProvider.php +++ b/tests/Provider/Client/ClientListProvider.php @@ -133,7 +133,7 @@ public static function clientListFilterCases(): array 'name' => [ // Test user filter "name" 'filterQueryParamsArr' => ['name' => 'th'], 'expectedClientsWhereString' => 'client.deleted_at IS NULL AND (CONCAT(client.first_name, " ", ' . - 'last_name) LIKE "%th%")', + 'client.last_name) LIKE "%th%")', 'authenticatedUserAttributes' => $newcomerAttributes, 'clientsToInsert' => $clientsToInsert, 'usersToInsert' => $usersToInsert, @@ -155,7 +155,7 @@ public static function clientListFilterCases(): array 'status and name' => [ // Test user filter "status 68 or 69" and "name contains 'enth'" 'filterQueryParamsArr' => ['status' => [68, 69], 'name' => 'enth'], 'expectedClientsWhereString' => 'client.deleted_at IS NULL AND (client_status_id IN (68, 69)) AND ' . - '(CONCAT(client.first_name, " ", last_name) LIKE "%enth%")', + '(CONCAT(client.first_name, " ", client.last_name) LIKE "%enth%")', 'authenticatedUserAttributes' => $newcomerAttributes, 'clientsToInsert' => $clientsToInsert, 'usersToInsert' => $usersToInsert, @@ -170,7 +170,7 @@ public static function clientListFilterCases(): array 'usersToInsert' => $usersToInsert, 'clientStatusesToInsert' => $clientStatusesToInsert, ], - // * Filter combination: linked to other user 43 or authenticated user 42, is deleted and the status is 68 + // * Filter combination: linked to other user 43 or authenticated user 42, is deleted, and the status is 68 'newcomer deleted' => [ // This test is as newcomer so no clients should be found 'filterQueryParamsArr' => ['status' => [68], 'user' => [42, 43], 'deleted' => 1], 'expectedClientsWhereString' => 'FALSE', // ? Newcomer may not see deleted clients diff --git a/tests/Provider/User/UserCreateProvider.php b/tests/Provider/User/UserCreateProvider.php index ae829985..81645a61 100644 --- a/tests/Provider/User/UserCreateProvider.php +++ b/tests/Provider/User/UserCreateProvider.php @@ -76,7 +76,7 @@ public static function invalidUserCreateCases(): array 'requestBody' => [ // Values too short 'first_name' => 'n', - 'surname' => 'n', + 'last_name' => 'n', 'email' => 'new.email@tes$t.ch', 'status' => 'non-existing', 'user_role_id' => 99, @@ -89,7 +89,7 @@ public static function invalidUserCreateCases(): array 'data' => [ 'errors' => [ 'first_name' => [0 => 'Minimum length is 2'], - 'surname' => [0 => 'Minimum length is 2'], + 'last_name' => [0 => 'Minimum length is 2'], 'email' => [0 => 'Invalid email'], 'status' => [0 => 'Invalid option'], 'user_role_id' => [0 => 'Invalid option'], @@ -103,7 +103,7 @@ public static function invalidUserCreateCases(): array // Values too long 'requestBody' => [ 'first_name' => str_repeat('i', 101), - 'surname' => str_repeat('i', 101), + 'last_name' => str_repeat('i', 101), 'email' => 'new.email.@test.ch', // Valid required values to test the above 'status' => UserStatus::Active->value, @@ -117,7 +117,7 @@ public static function invalidUserCreateCases(): array 'data' => [ 'errors' => [ 'first_name' => [0 => 'Maximum length is 100'], - 'surname' => [0 => 'Maximum length is 100'], + 'last_name' => [0 => 'Maximum length is 100'], 'email' => [0 => 'Invalid email'], ], ], @@ -127,7 +127,7 @@ public static function invalidUserCreateCases(): array // Required values not given 'requestBody' => [ 'first_name' => '', - 'surname' => '', + 'last_name' => '', 'email' => '', // Valid required values to test the above 'status' => '', @@ -141,7 +141,7 @@ public static function invalidUserCreateCases(): array 'data' => [ 'errors' => [ 'first_name' => [0 => 'Required'], - 'surname' => [0 => 'Required'], + 'last_name' => [0 => 'Required'], 'email' => [0 => 'Invalid email'], 'status' => [0 => 'Invalid option'], // Same error message twice because not numeric and not existing. @@ -161,7 +161,7 @@ public static function invalidUserCreateCases(): array 'data' => [ 'errors' => [ 'first_name' => [0 => 'Field is required'], - 'surname' => [0 => 'Field is required'], + 'last_name' => [0 => 'Field is required'], 'email' => [0 => 'Field is required'], 'status' => [0 => 'Field is required'], 'user_role_id' => [0 => 'Field is required'], diff --git a/tests/Provider/User/UserUpdateProvider.php b/tests/Provider/User/UserUpdateProvider.php index 78ea66e3..da95729a 100644 --- a/tests/Provider/User/UserUpdateProvider.php +++ b/tests/Provider/User/UserUpdateProvider.php @@ -36,7 +36,7 @@ public static function userUpdateAuthorizationCases(): array ]; $basicDataChanges = [ 'first_name' => 'NewFirstName', - 'surname' => 'NewLastName', + 'last_name' => 'NewLastName', 'email' => 'new.email@test.ch', 'theme' => 'dark', 'language' => 'de_CH', @@ -127,7 +127,7 @@ public static function invalidUserUpdateCases(): array 'requestBody' => [ // Values too short 'first_name' => 'n', - 'surname' => 'n', + 'last_name' => 'n', 'email' => 'new.email@tes$t.ch', 'status' => 'non-existing', 'user_role_id' => 99, @@ -139,7 +139,7 @@ public static function invalidUserUpdateCases(): array 'data' => [ 'errors' => [ 'first_name' => [0 => 'Minimum length is 2'], - 'surname' => [0 => 'Minimum length is 2'], + 'last_name' => [0 => 'Minimum length is 2'], 'email' => [0 => 'Invalid email'], 'status' => [0 => 'Invalid option'], 'user_role_id' => [0 => 'Invalid option'], @@ -152,7 +152,7 @@ public static function invalidUserUpdateCases(): array // Values too long 'requestBody' => [ 'first_name' => str_repeat('i', 101), - 'surname' => str_repeat('i', 101), + 'last_name' => str_repeat('i', 101), 'email' => 'new.email.@test.ch', ], 'jsonResponse' => [ @@ -161,7 +161,7 @@ public static function invalidUserUpdateCases(): array 'data' => [ 'errors' => [ 'first_name' => [0 => 'Maximum length is 100'], - 'surname' => [0 => 'Maximum length is 100'], + 'last_name' => [0 => 'Maximum length is 100'], 'email' => [0 => 'Invalid email'], ], ],