liip / liip/LiipFunctionalTestBundle
Double container instances is causing an overhead
- Dominant language
- PHP
- Stars
- 648
- Forks
- 179
- PR merge metrics
- No merged PRs in 30d
Description
Hello there,
According to [symfony official documentation](https://symfony.com/doc/current/testing.html#your-first-functional-test) in order to test a controller you have to initialize a client like this:
```
$client = static::createClient();
```
And this is what I've been doing.
after creating my client I used to do something like this:
```
$this->loadFixtures($this->getFixtureData());
```
Then today I reached my memory limit and dived little deeper into this bundle. I realized that the reason was that there is a container loaded in ` $client = static::createClient();` and also `loadFixtures` is loading a second container.
After making some copy-paste custom code I changed the signature of `loadFixtures` to accept a container and the memory for PHP 5 dropped from ~500 MB to ~200 MB.
In my belief it would've been better if you let the developer set his own container somehow.
You could say that I could use the `makeClient` instead but unfortunately make client is doing the same thing and it loading a second container too by calling internally this
```
$client = static::createClient(array('environment' => $this->environment), $params)
```
Is there any workaround about this?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Symfony functional-testing guidance and inspect createClient, loadFixtures, and makeClient in the bundle. Trace where each method initializes its container and compare the existing custom workaround described in the issue. Done means the fixture-loading path can reuse the client container without the reported duplicate-container memory overhead, with relevant functional tests covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100