symfony: In test mode Symfony can't find doctrine filters

Symfony version(s) affected: 4.2.1

Description
I wrote a simple test to check whether user authorization is working. After entering “php bin / phpunit” gets the error: Filter ‘softdeleteable’ does not exist. My custom doctrine filters working in dev/prod mode. image image

Exception:

 Symfony\Component\Security\Core\Exception\AuthenticationServiceException {#521
  -token: Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken {#309
    -credentials: "123456789"
    -providerKey: "login"
    -user: "user.1@project.test"
    -roles: []
    -authenticated: false
    -attributes: []
  }
  #message: "Filter 'softdeleteable' does not exist."
  #code: 0
  #file: "./vendor/symfony/security-core/Authentication/Provider/DaoAuthenticationProvider.php"
  #line: 85
  -previous: InvalidArgumentException {#490
    #message: "Filter 'softdeleteable' does not exist."
    #code: 0
    #file: "./vendor/doctrine/orm/lib/Doctrine/ORM/Query/FilterCollection.php"
    #line: 107
    trace: {
      ./vendor/doctrine/orm/lib/Doctrine/ORM/Query/FilterCollection.php:107 { …}
      ./vendor/doctrine/doctrine-bundle/ManagerConfigurator.php:48 { …}
      ./vendor/doctrine/doctrine-bundle/ManagerConfigurator.php:34 { …}
      ./var/cache/test/ContainerSdbfk4U/srcApp_KernelTestDebugContainer.php:677 {
        ›
        › ($this->privates['doctrine.orm.default_manager_configurator'] ?? ($this->privates['doctrine.orm.default_manager_configurator'] = new \Doctrine\Bundle\DoctrineBundle\ManagerConfigurator(array(0 => 'softdeleteable', 1 => 'creditexpiration'), array())))-
>configure($instance);
        ›
        arguments: {
          $entityManager: Doctrine\ORM\EntityManager {#577 …}
        }
      }
      ./var/cache/test/ContainerSdbfk4U/srcApp_KernelTestDebugContainer.php:3059 { …}
      ./var/cache/test/ContainerSdbfk4U/srcApp_KernelTestDebugContainer.php:654 { …}
      ./var/cache/test/ContainerSdbfk4U/srcApp_KernelTestDebugContainer.php:1947 { …}
      ./var/cache/test/ContainerSdbfk4U/srcApp_KernelTestDebugContainer.php:669 { …}
      ./vendor/symfony/dependency-injection/Container.php:245 { …}
      ./vendor/symfony/dependency-injection/Container.php:225 { …}
      ./vendor/symfony/doctrine-bridge/ManagerRegistry.php:35 { …}
      ./vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php:152 { …}
      ./vendor/symfony/doctrine-bridge/Security/User/EntityUserProvider.php:112 { …}
      ./vendor/symfony/doctrine-bridge/Security/User/EntityUserProvider.php:117 { …}
      ./vendor/symfony/doctrine-bridge/Security/User/EntityUserProvider.php:49 { …}
      ./vendor/symfony/security-core/Authentication/Provider/DaoAuthenticationProvider.php:74 { …}
      ./vendor/symfony/security-core/Authentication/Provider/UserAuthenticationProvider.php:64 { …}
      ./vendor/symfony/security-core/Authentication/AuthenticationProviderManager.php:76 { …}
      ./vendor/symfony/security-http/Firewall/UsernamePasswordJsonAuthenticationListener.php:121 { …}
      ./vendor/symfony/security-bundle/Debug/WrappedListener.php:46 { …}
      ./vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php:35 { …}
      ./vendor/symfony/security-http/Firewall.php:90 { …}
      ./vendor/symfony/security-bundle/EventListener/FirewallListener.php:48 { …}
      ./vendor/symfony/event-dispatcher/Debug/WrappedListener.php:111 { …}
      ./vendor/symfony/event-dispatcher/EventDispatcher.php:212 { …}
      ./vendor/symfony/event-dispatcher/EventDispatcher.php:44 { …}
      ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:142 { …}
      ./vendor/symfony/http-kernel/HttpKernel.php:126 { …}
      ./vendor/symfony/http-kernel/HttpKernel.php:67 { …}
      ./vendor/symfony/http-kernel/Kernel.php:198 { …}
      ./vendor/symfony/http-kernel/Client.php:68 { …}
      ./vendor/symfony/framework-bundle/Client.php:131 { …}
      ./vendor/symfony/browser-kit/Client.php:405 { …}
      ./tests/Controller/ApiControllerTest.php:167 { …}
      ./tests/Controller/ApiControllerTest.php:72 { …}
      ./tests/Controller/User/MyselfControllerTest.php:12 { …}
      App\Tests\Controller\User\MyselfControllerTest->testShow() {}
      ./bin/.phpunit/phpunit-6.5/src/Framework/TestCase.php:1071 { …}
      ./bin/.phpunit/phpunit-6.5/src/Framework/TestCase.php:939 { …}
      ./bin/.phpunit/phpunit-6.5/src/Framework/TestResult.php:698 { …}
      ./bin/.phpunit/phpunit-6.5/src/Framework/TestCase.php:894 { …}
      ./bin/.phpunit/phpunit-6.5/src/Framework/TestSuite.php:755 { …}
      ./bin/.phpunit/phpunit-6.5/src/Framework/TestSuite.php:755 { …}
      ./bin/.phpunit/phpunit-6.5/src/TextUI/TestRunner.php:545 { …}
      ./bin/.phpunit/phpunit-6.5/src/TextUI/Command.php:195 { …}
      ./bin/.phpunit/phpunit-6.5/src/TextUI/Command.php:148 { …}
      ./bin/.phpunit/phpunit-6.5/phpunit:17 { …}
      ./vendor/symfony/phpunit-bridge/bin/simple-phpunit:242 { …}
      ./bin/phpunit:18 { …}
    }
  }
  trace: {
    ./vendor/symfony/security-core/Authentication/Provider/DaoAuthenticationProvider.php:85 { …}
    ./vendor/symfony/security-core/Authentication/Provider/UserAuthenticationProvider.php:64 { …}
    ./vendor/symfony/security-core/Authentication/AuthenticationProviderManager.php:76 { …}
    ./vendor/symfony/security-http/Firewall/UsernamePasswordJsonAuthenticationListener.php:121 { …}
    ./vendor/symfony/security-bundle/Debug/WrappedListener.php:46 { …}
    ./vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php:35 { …}
    ./vendor/symfony/security-http/Firewall.php:90 { …}
    ./vendor/symfony/security-bundle/EventListener/FirewallListener.php:48 { …}
    ./vendor/symfony/event-dispatcher/Debug/WrappedListener.php:111 { …}
    ./vendor/symfony/event-dispatcher/EventDispatcher.php:212 { …}
    ./vendor/symfony/event-dispatcher/EventDispatcher.php:44 { …}
    ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:142 { …}
    ./vendor/symfony/http-kernel/HttpKernel.php:126 { …}
    ./vendor/symfony/http-kernel/HttpKernel.php:67 { …}
    ./vendor/symfony/http-kernel/Kernel.php:198 { …}
    ./vendor/symfony/http-kernel/Client.php:68 { …}
    ./vendor/symfony/framework-bundle/Client.php:131 { …}
    ./vendor/symfony/browser-kit/Client.php:405 { …}
    ./tests/Controller/ApiControllerTest.php:167 {
      ›     ],\r
      ›     json_encode($body)\r
      › );\r
      arguments: {
        $method: "POST"
        $uri: "http://localhost/auth/login"
        $parameters: []
        $files: []
        $server: array:4 [ …4]
        $content: "{"email":"user.1@project.test","password":"123456789"}"
      }
    }
    ./tests/Controller/ApiControllerTest.php:72 { …}
    ./tests/Controller/User/MyselfControllerTest.php:12 { …}
    App\Tests\Controller\User\MyselfControllerTest->testShow() {}
    ./bin/.phpunit/phpunit-6.5/src/Framework/TestCase.php:1071 { …}
    ./bin/.phpunit/phpunit-6.5/src/Framework/TestCase.php:939 { …}
    ./bin/.phpunit/phpunit-6.5/src/Framework/TestResult.php:698 { …}
    ./bin/.phpunit/phpunit-6.5/src/Framework/TestCase.php:894 { …}
    ./bin/.phpunit/phpunit-6.5/src/Framework/TestSuite.php:755 { …}
    ./bin/.phpunit/phpunit-6.5/src/Framework/TestSuite.php:755 { …}
    ./bin/.phpunit/phpunit-6.5/src/TextUI/TestRunner.php:545 { …}
    ./bin/.phpunit/phpunit-6.5/src/TextUI/Command.php:195 { …}
    ./bin/.phpunit/phpunit-6.5/src/TextUI/Command.php:148 { …}
    ./bin/.phpunit/phpunit-6.5/phpunit:17 { …}
    ./vendor/symfony/phpunit-bridge/bin/simple-phpunit:242 { …}
    ./bin/phpunit:18 { …}
  }

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (4 by maintainers)

Most upvoted comments

Hi !

I fixed my problem removing the enabled: true and everything works just fine.

Thank you for creating this example. I am able to reproduce it. The failure is related to the addFilter() call in the DI container happening after the configuration is retrieved. But I have no idea why that is different from the dev or prod environment.