Skip to content

Conversation

@jpjoao
Copy link
Contributor

@jpjoao jpjoao commented Mar 15, 2020

fixes #12961

Make documentation reflect changes made on 4.4 that allows only one client and require the usage of Symfony\Bundle\FrameworkBundle\Test\WebTestCase::ensureKernelShutdown() before creating new clients.

// ...
public function testWithMultipleClients()
{
self::ensureKernelShutdown();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This first shutdown is not really needed, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the documentation is for multiple clients, I thought it would be better to have some kind of patter and add the call prior to all client creations (which is not present on the examples of a single client) to show the main difference and easy the understanding of the mechanism.

But I am happy with it if you want me to remove it and/or add a comment about the need to add it only if there are new clients being create.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I opened #34507 a long time ago and proposed this solution on the docs. To be honest, feels weird to ask people to shut down the kernel before actually creating any client. And when you call createClient() it is already shutting down any previous kernel on the bootKernel() method.

I'll leave it up to the maintainers!

// ...
public function testWithMultipleInsulatedClients()
{
self::ensureKernelShutdown();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as my previous answer.

$harry->request('POST', '/say/sally/Hello');
$sally->request('GET', '/messages');
self::ensureKernelShutdown();
$sally = static::createClient();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of the second client? It's using the same parameters, same kernel etc as the one before. So you could just use the same client for both the following requests or not?

$harry = static::createClient();
self::ensureKernelShutdown();
$sally = static::createClient();

This also seems pretty strange. How does $harry client still work when the kernel is shutdown?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this "works" because https://github.com/symfony/symfony/blob/829566cdea90a0be0231a15a229df2166868fce0/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php#L155
boots the kernel again. So harry starts a client and boots the kernel, then shutdown the kernel, then boot it again...

@OskarStark
Copy link
Contributor

@jpjoao do still think, this is needed?

@jpjoao
Copy link
Contributor Author

jpjoao commented Jun 20, 2025

@OskarStark It has been a while since I last had a look at it. I don't have the context of it any more. If this was not merged after 5 years, I don't think it is relevant.

@jpjoao jpjoao closed this Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Issues and PRs which are looking for volunteers to complete them. Status: Needs Review Waiting feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants