Skip to content

Commit

Permalink
Typo [SLE-192]
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgfeller committed Jan 5, 2024
1 parent af90d1f commit b55833f
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/testing/testing-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testClientReadPageAction_authenticated(): void
// Add needed database values to correctly display the page
$clientRow = $this->insertFixturesWithAttributes(['user_id' => $userId, 'client_status_id' => $clientStatusId],

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userId);

$request = $this->createRequest('GET', $this->urlFor('client-read-page', ['client_id' => '1']));
Expand Down Expand Up @@ -382,7 +382,7 @@ public function testNoteListAction(
['is_main' => 0, 'client_id' => $clientRow['id'], 'user_id' => $userLinkedToNoteRow['id']],
new NoteFixture()
);
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $authenticatedUserRow['id']);
// Make request
$request = $this->createJsonRequest('GET', $this->urlFor('note-list'))->withQueryParams(['client_id' => '1']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Authentication/LoginPageActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testLoginPageActionAlreadyLoggedIn(): void
{
// Insert authenticated user
$userId = $this->insertFixturesWithAttributes([], new UserFixture())['id'];
// Simulate logged-in user with logged-in user 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
$requestRouteAfterLogin = $this->urlFor('client-read-page', ['client_id' => '1']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Client/ClientListActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testClientListPageActionAuthorization(): void
);

$request = $this->createRequest('GET', $this->urlFor('client-list-page'));
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userRow['id']);

$response = $this->app->handle($request);
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Client/ClientReadPageActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testClientReadPageActionAuthenticated(): void
);

$request = $this->createRequest('GET', $this->urlFor('client-read-page', ['client_id' => $clientRow['id']]));
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $clientRow['user_id']);

$response = $this->app->handle($request);
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Client/ClientUpdateActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testClientSubmitUpdateActionAuthorization(
$this->insertFixturesWithAttributes(['id' => $requestData['client_status_id']], new ClientStatusFixture());
}

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $authenticatedUserRow['id']);

$request = $this->createJsonRequest(
Expand Down Expand Up @@ -186,8 +186,8 @@ public function testClientSubmitUpdateActionInvalid(array $requestBody, array $j
$requestBody
);

// Simulate logged-in user with logged-in user id
$this->container->get(SessionInterface::class)->set('user_id', $clientRow['user_id']);
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userId);

$response = $this->app->handle($request);
// Assert 200 OK
Expand Down Expand Up @@ -247,7 +247,7 @@ public function testClientSubmitUpdateActionUnchangedContent(): void
);

// Simulate logged-in user
$this->container->get(SessionInterface::class)->set('user_id', $clientRow['user_id']);
$this->container->get(SessionInterface::class)->set('user_id', $userId);

$request = $this->createJsonRequest(
'PUT',
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Dashboard/DashboardPageActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testDashboardPageActionAuthenticated(): void
// A dashboard panel is for the status "action pending" and its id is retrieved by the code
$this->insertFixturesWithAttributes(['name' => 'Action pending'], new ClientStatusFixture());

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $loggedInUserId);

$request = $this->createRequest('GET', $this->urlFor('home-page'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testDashboardTogglePanelActionAuthenticated(): void
// Insert linked and authenticated user
$userId = $this->insertFixturesWithAttributes([], new UserFixture())['id'];

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userId);

$request = $this->createJsonRequest(
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Note/NoteListActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testNoteListActionAuthorization(
new NoteFixture()
);

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $authenticatedUserRow['id']);
// Make request
$request = $this->createJsonRequest('GET', $this->urlFor('note-list'))->withQueryParams(['client_id' => '1']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Note/NoteReadPageActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testNoteReadPageActionAuthenticated(): void
new UserFixture()
)['id'];

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userId);

// *Test request on NOT existing note
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/User/PasswordChangeSubmitActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function testChangePasswordSubmitActionInvalid(array $requestBody, array
$this->urlFor('change-password-submit', ['user_id' => $userRow['id']]),
$requestBody
);
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userRow['id']);
$response = $this->app->handle($request);
// Assert 200 OK
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/User/UserCreateActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testUserSubmitCreateAuthorization(
$this->urlFor('user-create-submit'),
$requestData
);
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $authenticatedUserRow['id']);
$response = $this->app->handle($request);
// Assert status code
Expand Down Expand Up @@ -165,7 +165,7 @@ public function testUserSubmitCreateInvalid(array $requestBody, array $jsonRespo
$this->urlFor('user-create-submit'),
$requestBody
);
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userRow['id']);
$response = $this->app->handle($request);
// Assert 422 Unprocessable Entity, which means validation error if request body contains user_role_id
Expand All @@ -190,7 +190,7 @@ public function testUserSubmitCreateEmailAlreadyExists(): void
$this->addUserRoleId(['user_role_id' => UserRole::ADMIN]),
new UserFixture()
);
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $adminRow['id']);

$existingEmail = '[email protected]';
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/User/UserFetchActivityActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testUserListActivityFetchAction(): void
// Insert user activity to cover most possible code with this test
$this->insertFixturesWithAttributes(['user_id' => $userId], new UserActivityFixture());

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userId);

$request = $this->createJsonRequest('GET', $this->urlFor('user-get-activity'))
Expand Down Expand Up @@ -78,7 +78,7 @@ public function testUserListActivityFetchActionWithoutQueryParams(): void
$this->addUserRoleId(['user_role_id' => UserRole::NEWCOMER]),
new UserFixture()
)['id'];
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userId);

$request = $this->createJsonRequest('GET', $this->urlFor('user-get-activity'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/User/UserListActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testUserListAuthorization(
// Change user attributes to user data
$this->insertUserFixturesWithAttributes($userRow, $authenticatedUserRow);

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $authenticatedUserRow['id']);
// Make request
$request = $this->createJsonRequest('GET', $this->urlFor('user-list'));
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/User/UserListPageActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testUserListPageActionAuthenticatedUnauthorized(): void
new UserFixture()
);

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userRow['id']);

$request = $this->createRequest('GET', $this->urlFor('user-list-page'));
Expand All @@ -67,7 +67,7 @@ public function testUserListPageActionAuthenticatedAuthorized(): void
new UserFixture()
);

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userRow['id']);

$request = $this->createRequest('GET', $this->urlFor('user-list-page'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/User/UserReadPageActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testClientReadPageActionAuthorization(
// Insert tested and authenticated user
$this->insertUserFixturesWithAttributes($userData, $authenticatedUserData);

// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $authenticatedUserData['id']);

$request = $this->createRequest('GET', $this->urlFor('user-read-page', ['user_id' => $userData['id']]));
Expand Down
5 changes: 3 additions & 2 deletions tests/Integration/User/UserUpdateActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testUserSubmitUpdateAuthorization(
$this->urlFor('user-update-submit', ['user_id' => $userToChangeRow['id']]),
$requestData
);
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $authenticatedUserRow['id']);
$response = $this->app->handle($request);
// Assert status code
Expand Down Expand Up @@ -131,6 +131,7 @@ public function testUserSubmitUpdateInvalid(array $requestBody, array $jsonRespo
{
// Insert user that is allowed to change content (advisor owner)
$userRow = $this->insertFixturesWithAttributes(
// Replace user_role_id enum case with database id with AuthorizationTestTrait function addUserRoleId()
$this->addUserRoleId(['user_role_id' => UserRole::ADVISOR]),
new UserFixture()
);
Expand All @@ -140,7 +141,7 @@ public function testUserSubmitUpdateInvalid(array $requestBody, array $jsonRespo
$this->urlFor('user-update-submit', ['user_id' => $userRow['id']]),
$requestBody
);
// Simulate logged-in user with logged-in user id
// Simulate logged-in user by setting the user_id session variable
$this->container->get(SessionInterface::class)->set('user_id', $userRow['id']);
$response = $this->app->handle($request);
// Assert 200 OK
Expand Down
2 changes: 0 additions & 2 deletions tests/Provider/User/UserUpdateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
namespace App\Test\Provider\User;

use App\Domain\User\Enum\UserRole;
use App\Test\Traits\FixtureTestTrait;
use Fig\Http\Message\StatusCodeInterface;

class UserUpdateProvider
{
use FixtureTestTrait;

/**
* @return array[]
Expand Down

0 comments on commit b55833f

Please sign in to comment.