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

[FrameworkBundle][BC Break ?] Accessing static property $client in classes extending WebTestCase #31653

Closed
gnutix opened this issue May 28, 2019 · 11 comments

Comments

@gnutix
Copy link
Contributor

gnutix commented May 28, 2019

Symfony version(s) affected: 4.3.0-BETA2

Description
In symfony/framework-bundle@58e572e, protected static $client; was added to \Symfony\Bundle\FrameworkBundle\Test\WebTestCase.

I've upgraded my project to Symfony 4.3.0-BETA2 and had to fix my test suite and that of already multiple different libraries because it used $this->client to access the client (which is now triggering errors like Accessing static property Craue\FormFlowBundle\Tests\RevalidatePreviousStepsFlowTest::$client as non static, when it used to "work" before).

How to reproduce
Clone https://github.com/craue/CraueFormFlowBundle on branch "autoconfiguration" and run composer install && vendor/bin/phpunit.

Possible Solution
Either revert the addition, or write documentation as I think it's a BC break of sorts.

@gnutix gnutix changed the title [FrameworkBundle] Accessing static property $client in classes extending WebTestCase [FrameworkBundle][BC Break ?] Accessing static property $client in classes extending WebTestCase May 29, 2019
@raress96
Copy link

raress96 commented May 30, 2019

I also have this same problem with the full version 4.3.0.
What is more annoying is that I get this error from tests class from another custom bundle I made, but when running the tests from the main application.

@gmponos
Copy link
Contributor

gmponos commented May 30, 2019

I am not sure if the WebTestCase should be under the BC promise

https://symfony.com/doc/current/contributing/code/bc.html

Theoritically it is not.. never the less I believe that this specific class it is extended by a LOT a LOT people and it makes their update path a little bit difficult. For me I have to update a gazillion of Tests classes in order to update to 4.3

I can not see the reason why the client was added there...

@raress96
Copy link

Or if the client is really required there, the name can be changed to testClient or something else to not conflict with other clients. This seems like a really big BC break, since there are bundles which use that class, and if you use them then the hole app will crash and you can not fix it.

@gnutix
Copy link
Contributor Author

gnutix commented Jun 3, 2019

@fabpot This might require your attention as Symfony 4.3.0 has just been released with this?

@gmponos
Copy link
Contributor

gmponos commented Jun 3, 2019

Since the Tests are not under BC then it could be easily reverted I guess to ease the upgrade process.

@gnutix
Copy link
Contributor Author

gnutix commented Jun 3, 2019

@gmponos The doc states :

[...] classes located in the various *\Tests\ namespaces are an exception to this rule. They are meant for internal use only and should not be accessed by your own code.

But \Symfony\Bundle\FrameworkBundle\Test\WebTestCase is not under a *\Tests\* namespace (which would contain tests for Symfony code), but under a Test namespace (which contains utilities for testing). Therefore, I think it should be covered by the BC promise.

@xabbuh
Copy link
Member

xabbuh commented Jun 3, 2019

It is covered by the BC promise. But it also states that we may add new properties to a class. We rather need to discuss if we should use another name in this particular case to mitigate the impact.

@gmponos
Copy link
Contributor

gmponos commented Jun 3, 2019

Ah... a small s that I missed there...

@Simperfit
Copy link
Contributor

I already updated, but IMHO this should be treated as a BC Break and either be reverted or a new property with another name should be added to not break the existing. We can add new property but this is way to impacting to not be treated as a BC.

@nicolas-grekas
Copy link
Member

See #31880

fabpot added a commit that referenced this issue Jun 6, 2019
…tionsTrait (nicolas-grekas)

This PR was merged into the 4.3 branch.

Discussion
----------

[FrameworkBundle] fix BC-breaking property in WebTestAssertionsTrait

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31653
| License       | MIT
| Doc PR        | -

No properties should be exposed.

Commits
-------

6253926 [FrameworkBundle] fix BC-breaking property in WebTestAssertionsTrait
@fabpot fabpot closed this as completed Jun 6, 2019
@curry684
Copy link
Contributor

curry684 commented Jun 6, 2019

I had similar issues, rewrote half my test suite to accomodate for the 4.3.0 changes and rename $client in my own test cases, then upgraded to 4.3.1 just to see my CI phpStan section break again on invalid method calls on Response... #31904 should fix that last remnant.

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

No branches or pull requests

8 participants