Closed k20human closed 3 years ago
Thanks for the detailed issue.
Removing getContainer()
would break the bundle for Symfony < 5.3. Allowing only Symfony 5.3+ would be too restrictive IMHO.
Can we define the method only if it doesn't exist yet?
Or we can remove getContainer()
and the trait like in https://github.com/liip/LiipTestFixturesBundle/pull/26 and switch to services for the next major release.
Can we define the method only if it doesn't exist yet?
I think to something like this: https://www.php.net/manual/fr/function.function-exists.php#117916
if (!function_exists(__NAMESPACE__ . '\getContainer'))
{
function getContainer() {
// …
}
}
Ok perfect, will test this tomorrow and do the PR ;)
Le lun. 31 mai 2021 à 19:46, Alexis Lefebvre @.***> a écrit :
Can we define the method only if it doesn't exist yet?
I think to something like this: https://www.php.net/manual/fr/function.function-exists.php#117916
if (!function_exists(NAMESPACE . '\getContainer'))
{
function getContainer() { // … }
}
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liip/LiipFunctionalTestBundle/issues/583#issuecomment-851614880, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEEJPRR5PLKGJWBM4VUMOLTQPDQ7ANCNFSM453DH2SA .
Ok, finally we can't use function_exists
or method_exists
inside class definition. So i use __call
method to avoid BC break.
I keep usage of old method getContainer
because the new one of KernelTestCase
call bootKernel
which set static::$booted = true;
and it as some side effects
PR here : #584
Preconditions
Steps to reproduce
Liip\FunctionalTestBundle\Test\WebTestCase
Expected result
Actual result
An error occured:
It's due to this PR on SF 5.3 : https://github.com/symfony/symfony/pull/40366
I can propose a PR to fix that. Can we remove
getContainer
method from WebTestCase and use SF's one ? Or rename it ? Or other thing ?For now i copy / paste WebTestCase class in my code and remove the getContainer method. All tests run like before