Comments (5)
A dirty fix:
$this->connection = $this->om instanceof EntityManagerInterface ? $this->om->getConnection() : $this->registry->getConnection($omName);
The problem is, that the $this->registry->getManager($omName)
does not return the EntityManagerInterface
but the ObjectManager
.
from liiptestfixturesbundle.
Thanks for the report!
Could you please open a PR with a fix? First we need to add a new Kernel with a new config that use more than entity manager, we only have one at the moment: https://github.com/liip/LiipTestFixturesBundle/blob/2.x/tests/AppConfigMysql/config.yml Then add tests that call the different entity managers.
Shoud we update the setObjectManagerName
method like this?
-public function setObjectManagerName(string $omName = null): void
+public function setObjectManagerName(string $omName = null, ?string $connectionName = null): void
{
$this->omName = $omName;
$this->om = $this->registry->getManager($omName);
- $this->connection = $this->registry->getConnection($omName);
+ $this->connection = $this->registry->getConnection($connectionName ?? $omName);
}
Then
static::getContainer()
->get(DatabaseToolCollection::class)
->get('a_name_not_matching_connection_name', 'default')
->loadFixtures([YourFixtures::class]);
may works.
from liiptestfixturesbundle.
@alexislefebvre It looks like, it is not that easy.
Loading fixtures like this:
static::getContainer()
->get(DatabaseToolCollection::class)
->get('client')
->loadFixtures([RunActionFixtures::class]);
the DatabaseToolCollection
should handle the list of database tools. The index of this list depends on registry name and driver name. No dependency on connection or entity manager (no sure, if both is necessary). Each time, you pull out the database tool from the collection, the object manager (and connection) is set. This overwrites previous settings. This means, the last call of the get method will win.
See:
I have no quick fix for this. So I found a workaround. I changed the doctrine configuration for the test environment, so that the number of connections is equal to the number of entity managers and the entity managers names do now match the connection name. E. g. like this:
doctrine.yaml:
when@test:
doctrine:
dbal:
connections:
a_name_not_matching_connection_name:
url: '%env(resolve:DATABASE_TEST_URL)%'
orm:
entity_managers:
a_name_not_matching_connection_name:
connection: a_name_not_matching_connection_name
If there is no one else out there having the same problem, it is ok, to handle this as an edge case without fixing it.
from liiptestfixturesbundle.
I tried to add a test with 2 connections and 2 entity managers and it added way more complexity than I expected: it means 2 different configurations for the entities, their schema and fixtures. I ended up with that classes that can't be found and I gave up.
I'm sorry but I can't help with this topic.
from liiptestfixturesbundle.
I also had a closer look, and - yes - it is more complex than it looked in the beginning. I do not have a really good idea right now, but I think, it is possible.
I think most projects do not have to deal with more than one connection or entity manager. If I found a good solution, I'll let you know. Thanks for your support.
from liiptestfixturesbundle.
Related Issues (20)
- Drop support of PHP 7.2 and 7.3? HOT 1
- [Bug]: keep_database_and_schema config is ignored it is always false with SQL Server HOT 2
- facing issue in new pimcore version 10.6 HOT 5
- [Feature Request]: Add LoadFixtureGroup method HOT 2
- Deprecated DBAL APIs still in use HOT 1
- Question: cached database with GitLab CI pipeline HOT 2
- Load fixture without a file path HOT 7
- [Feature Request]: Support Symfony 7 HOT 1
- [Bug]: $referenceRepository->getReferences() is broken HOT 1
- [Bug]: mysqldump: unknown variable 'column-statistics=0' error HOT 7
- Performance with LiipTestFixturesBundle v2.6.0 HOT 7
- SqlitePlatform::getName() is deprecated HOT 4
- [Bug]: Impossible to set "keep_database_and_schema" HOT 4
- [Bug]: 2.7.2 - Doctrine MongoDB Manager can not be used anymore HOT 2
- [Feature Request]: Upgrading doctrine/dbal Connection handling HOT 5
- [Feature Request]: Support "doctrine/dbal" 4 HOT 1
- [Feature Request]: Prepare release 3.x HOT 1
- [Bug]: Undeclared dependency on doctrine/dbal ^3.1.0 | ^4.0.1 HOT 3
- [Feature Request]: Support doctrine/dbal 4
- contributing: MongoDb extension on Mac M1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liiptestfixturesbundle.