2

I'm using LiipFunctionalTestBundle with AliceBundle to test my Symfony 3.4 application with fixtures.

Everything is working fine but this specific case: Accessing application parameters from within a fixture loaded from a test in a Liip WebTestCase extension.

Let's consider this setup:

config.yml

parameters:
    img_url: 'http://images.url'

my-fixture.yml

AppBundle\Entity\Item:
    Item-0:
        name: 'First Item'
        image: '<{img_url}>/item0.png'

MyTest.php

use Liip\FunctionalTestBundle\Test\WebTestCase;

class MyTest extends WebTestCase
{
# ...

    public function testMy()
    {
        echo $this->getContainer()->getParameter('img_url');
        $this->loadFixtureFiles(['my-fixture.yml']);
        # ...
    }

Here is the result of the test:

$ phpunit --filter /MyTest::testMy$/
http://images.url
Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueDuringGenerationException:
  Could not resolve value during the generation process
[...]
Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException:
  Could not find the parameter "img_url"
[...]

However, my fixture can be loaded successfully from the command line:

$ console hautelook:fixtures:load -vv
13:37:42 INFO      [app] fixtures found ["files" => ["my-fixture.yml"]] []
13:37:42 INFO      [app] Purging database with purge mode "DELETE_MODE". [] []
13:37:42 INFO      [app] [...]
13:37:42 INFO      [app] fixtures loaded [] []

Why can't my fixture access the parameter from the test ?
How can I debug that ?

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
  • 1
    It works from command line but not from the bundle because fixtures are not instantiated in the same way, there is a discussion which is close to this issue: https://github.com/liip/LiipFunctionalTestBundle/issues/411 – A.L May 03 '18 at 11:48

0 Answers0