liip / liip/LiipTestFixturesBundle

Specifying an entity manager when using the loadFixtures method

Open
#85 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
178
Forks
48
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Hi team, I have two different bundles in my app and each one has their own entity manager. I am writing an integration test for a service in one of the bundles, but I need to load a fixture class from the second bundle. Is this currently possible?

**Describe alternatives you've considered**
I tried passing in the name of the entity manager for the fixture I'd like to load, in the `$omName` parameter of the `loadFixtures` method unsuccessfully. This was the main exception I kept getting:

`InvalidArgumentException: Doctrine ORM Manager named "shared" does not exist.`

I also tried different variations of the entity manager name but same outcome, eg:
"shared", "doctrine.orm.shared_entity_manager" and "shared_entity_manager":

**Additional context**
Here is part of my doctrine orm config with the two entity managers for more context:

```
orm:
default_entity_manager: default
auto_generate_proxy_classes: '%kernel.debug%'
entity_managers:
default:
connection: client_database
auto_mapping: true
shared:
connection: shared_database
mappings:
AdminBundle:
type: annotation
dir: '%kernel.project_dir%/src/AdminBundle/Entity'
prefix: AdminBundle\Entity
```

Thanks,
-Aleks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the loadFixtures method and the two-entity-manager Doctrine ORM configuration shown in the issue. Trace how the $omName value is resolved and identify the fixture-loading entry point and relevant tests. Done means a fixture from the second bundle can be loaded through its entity manager without the reported manager-not-found exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.