I have a test, where i've persists entity inside a test case. But when i'm inside a controller, which i'm testing, is called by api request, there is no entity changes.
class UserProductionTest extends WebTestCase
{
public function testProduction(): void
{
$client = self::getAuthenticatedClient();
$user = $this->getCurrentUser(); //#1: existing user with lastLoginAt = null
$client->jsonRequest(
"GET",
"/api/user/online_heartbeat"
);
$user = $this->getCurrentUser(); //#2: existing user, with lastLoginAt = 'now'. Changes caused by api call atop.
$user->setLastLoginAt($user->getLastLoginAt()->modify('-5 minutes'));
/** @var UserRepository $userRepository */
$userRepository = $this->getContainer()->get(UserRepository::class);
$userRepository->save($user, true); //#3: saves changes by repository
$client->jsonRequest(
"GET",
"/api/production/offline_income/en" //There i call controller, which inside i get current user again, but there is #2 value, not #3
);
$user = $this->getCurrentUser();
$this->assertResponseIsSuccessful();
}
}
StaticDriver::commit() line after #3 successfully writes changes into DB.
I guess there are maybe kind of config issue, or maybe cause is User entity, used in authorization hooks.
I have a test, where i've persists entity inside a test case. But when i'm inside a controller, which i'm testing, is called by api request, there is no entity changes.
StaticDriver::commit()
line after #3 successfully writes changes into DB. I guess there are maybe kind of config issue, or maybe cause is User entity, used in authorization hooks.