Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt documentation for multiple clients on WebTestCases #13351

Open
wants to merge 1 commit into
base: 4.4
Choose a base branch
from

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
Member

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
Member

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...

@javiereguiluz javiereguiluz added the help wanted Issues and PRs which are looking for volunteers to complete them. label May 20, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants