One of the clean code tips is to not defining flags as an argument for your functions. instead you should divide the login into multiple functions. By this way, you also won't violate SRP principle.
I suggest using factory states, like below.
UserFactory:
Hello Povilas, In the company im currently working luckymedia, in TestCase.php we create a separate public function as follows:
, then when we want to be logged as an admin we test as follows:
Is this the propper way to test, or can you suggest a better approach?
Thanks in advance
Yes, that's a perfectly fine approach, to avoid repeating the same thing in each test.
One of the clean code tips is to not defining flags as an argument for your functions. instead you should divide the login into multiple functions. By this way, you also won't violate SRP principle.
I suggest using factory states, like below. UserFactory:
then using it like this: