jeudi 2 juin 2016

SF2 Functional tests : "Resetting the container is not allowed when a scope is active"

I try to execute simple functional tests on my SF2.8 app:

  • PHPUnit 5.3.4
  • Command line executed : phpunit -c app src/LCH/MultisiteBundle/Tests/Controller/SiteControllerTest

SiteControllerTest :

class SiteControllerTest extends WebTestCase
{

    /**
     * {@inheritDoc}
     */
    protected function setUp()
    {
        $this->superadmin = static::createClient();
    }

    /*
     * @group multisite
     */
    public function testList()
    {
        // Nothing here yet.
    }

    protected function tearDown() {
        parent::tearDown();
    }
}

PHPUnit return :

There was 1 error:

1) LCH\MultisiteBundle\Tests\Controller\SiteControllerTest::testList Symfony\Component\DependencyInjection\Exception\LogicException: Resetting the container is not allowed when a scope is active.

/var/www/html/sites/lch/loyalty/app/bootstrap.php.cache:2231 /var/www/html/sites/lch/loyalty/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:182 /var/www/html/sites/lch/loyalty/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:192 /var/www/html/sites/lch/loyalty/src/LCH/MultisiteBundle/Tests/Controller/SiteControllerTest.php:29

This is throwed by Container class itself during reset() method :

    /**
     * {@inheritdoc}
     */
    public function reset()
    {
        if (!empty($this->scopedServices)) {
            throw new LogicException('Resetting the container is not allowed when a scope is active.');
        }

        $this->services = array();
    }

But I can't find why. I didn't use scope so far in my services registration, so it should be the default self::SCOPE_CONTAINER one....

Any hints ?

Thanks a lot !

Aucun commentaire:

Enregistrer un commentaire