Skip to content

Conversation

ttskch
Copy link
Contributor

@ttskch ttskch commented Oct 7, 2025

Q A
Branch? 4.2
Tickets Related to #6976 and #7007
License MIT
Doc PR N/A

As of #6976 and #7007, calling createClient() no longer boots the kernel when $alwaysBootKernel = false is set, as recommended.

If we use Client::loginUser() when the kernel has not been booted, no error will occur and we will simply remain in a non-logged in state.

So, this PR ensure that the kernel is booted before using KernelBrowser::loginUser(), and that Client::loginUser() always succeeds.

@soyuka soyuka merged commit 70bdf29 into api-platform:4.2 Oct 8, 2025
113 of 114 checks passed
@soyuka
Copy link
Member

soyuka commented Oct 8, 2025

thanks!

@Crovitche-1623
Copy link
Contributor

Crovitche-1623 commented Oct 8, 2025

Are you sure the static::$booted variable from KernelTestCase variable will not be in sync anymore if the kernel is booted in these methods ? @ttskch
cc @soyuka

@Crovitche-1623
Copy link
Contributor

Crovitche-1623 commented Oct 8, 2025

Don't you think the database may be recreated twice if something like that is used :

// A test using `ApiTestCase`

$client = Client::loginUser();

$anotherClient = static::createClient();

@Crovitche-1623
Copy link
Contributor

NVM, a logged in user could be created without having to create the database. As far as I saw, the only the bootKernel is listened by Alice.

@Crovitche-1623
Copy link
Contributor

Even if the database is created only once, remember that the kernel may be shut down and recreated—for example, when calling static::createClient—so the $booted flag can get out of sync. I’m not sure whether that will cause issues down the line, but it’s worth keeping in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants