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

Cannot use decorated EntityManager extended from Doctrine2 EntityManagerDecorator #3459

Closed
akbwm opened this Issue Aug 22, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@akbwm
Contributor

akbwm commented Aug 22, 2016

What are you trying to achieve?

Using custom EntityManager implementation via decorated Symfony2 service definition
services.yml

 my.em.decorator:
        public: false
        class: AppBundle\MyEntityManagerDecorator
        decorates: doctrine.orm.entity_manager
        arguments: 
            - "@my.em.decorator.inner"

MyEntityManagerDecorator.php

class MyEntityManagerDecorator extends Doctrine\ORM\Decorator\EntityManagerDecorator
{
...
}

What do you get instead?

Exception, because of Doctrine2 module checking against EntityManager instead of EntityManagerInterface
Doctrine2.php:151

        if (!($this->em instanceof \Doctrine\ORM\EntityManager)) {
            throw new ModuleConfigException(
                __CLASS__,
                "Connection object is not an instance of \\Doctrine\\ORM\\EntityManager.\n"
                . "Use `connection_callback` or dependent framework modules to specify one"
            );
        }

Provide console output if related. Use -vvv mode for more details.

  [Codeception\Exception\ModuleConfigException]                            
  Doctrine2 module is not configured!                                      

  Connection object is not an instance of \Doctrine\ORM\EntityManager.     
  Use `connection_callback` or dependent framework modules to specify one

Provide test source code if related

Any test suite using Doctrine2 module

Details

  • Codeception version: 2.1.7
  • PHP Version: 5.5.9
  • Operating System: ubuntu
  • Installation type: Composer
  • List of installed packages (composer show)
  • Suite configuration:
modules:
    config:
        Doctrine2:
            depends: Symfony2
        Symfony2:
            app_path: 'app'
            environment: 'test'
            debug: false

@Naktibalda Naktibalda added Symfony Doctrine and removed Symfony labels Aug 22, 2016

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Aug 22, 2016

Member

Please make a pull request.

Member

Naktibalda commented Aug 22, 2016

Please make a pull request.

akbwm added a commit to akbwm/Codeception that referenced this issue Aug 24, 2016

Codeception#3459
Use \Doctrine\ORM\EntityManagerInterface instead of
\Doctrine\ORM\EntityManager to check for valid entity manager in
Doctrine2 module.

DavertMik added a commit that referenced this issue Aug 24, 2016

#3459 (#3467)
Use \Doctrine\ORM\EntityManagerInterface instead of
\Doctrine\ORM\EntityManager to check for valid entity manager in
Doctrine2 module.

@Naktibalda Naktibalda closed this Aug 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment