-
Notifications
You must be signed in to change notification settings - Fork 62
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
Not working with PHPUnit process isolation #66
Comments
Hmm that is interesting 😕 How exactly are you running your tests? Are you doing some parallel execution in multiple php processes? If you could somehow give me a minimal reproducer I could also have a look myself. |
Hello, thanks for the quick response! I actually just found out what's happening: my test was running with Removing the thanks. |
I had to create ulgy class which override base test client. <?php
namespace App\Test;
use Symfony\Bundle\FrameworkBundle\Client;
class TestClient extends Client
{
public function getHandleScript()
{
// due to: https://github.com/dmaicher/doctrine-test-bundle/issues/66
// we have to set keep static connections for scripts which are called in separated process
return
'\DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver::setKeepStaticConnections(true);' .
parent::getHandleScript();
}
} Now everything works fine. |
Issue still exists
P.S. I saw "feature" label, I think this I faced this long ago and mentioned already. |
@BonBonSlick I'm not personally using process isolation in any of my projects. If you are interested in supporting it then feel free to dig into it and create a PR. Also feel free to suggest any Readme update for this issue with a PR 😉 |
@dmaicher Hello, I'm having a similar problem. I already have a solution (in my code) for my use case but I wonder if you would consider the following idea. Since it is sometimes painful to set My solution involves using a custom index.php to perform |
I've just added your bundle to an older Symfony 4.4 project to add some first tests. I went strictly by the official Symfony documentation and it simply does not work because of this issue :( I already had overwritten Why is that boolean in there at all? Are there connections to be expected outside of the tests? |
Hello,
I configured the bundle as per the documentation (add the bundle AppKernel, add the listener in phpunit.xml.dist...) but it doesn't work.
From my own debugging of the bundle, the issue is that when
StaticDriver::connect()
is called,self::$keepStaticConnections
is false, which makes this bundle do absolutely nothing.I did find the place where the
keepStaticConnections
is supposed to be set to true inPHPUnitListener
, but for some reason the change doesn't stay.I dumped all the relevant places, the variables goes to true in the
Listener
but it's back to false whenconnect()
is called.Changing line 23 of
StaticDriver
fromprivate static $keepStaticConnections = false;
toprivate static $keepStaticConnections = true;
works.I'm using PHPUnit 6.5 and PHP 7.2. Symfony is 3.4.
What am I missing ? Why is the static value change not sticking ?
Thanks.
The text was updated successfully, but these errors were encountered: