Closed Spomky closed 6 years ago
Looks like ContainerAwareFixture
stopped being injected with container after this patch
Looks like behavior of autoload: true
without directories
and fixtures
differs from app/console doctrine:fixtures:load
Given the following configs:
# app/config/test_fixtures.yml
services:
_defaults:
autowire: true
autoconfigure: true
_instanceof:
Doctrine\Common\DataFixtures\FixtureInterface:
tags:
- { name: doctrine.fixture.orm }
BestApps\Stories\Tests\Fixtures\:
resource: ../../tests/Fixtures/
# behat.yml
# ....
BehatExtension\DoctrineDataFixturesExtension\Extension:
lifetime: scenario
# ...
doctrine:fixtures:load
loads all my fixtures
behat does not load them (I see errors like username not found and other fixture-related ones)
behat with directories
configured to tests/Fixtures
loads them well
It looks like the error comes from the backup feature. This feature only works with sqlite and mysql. Are you using another DB engine (e.g. pgsql)?
no, I'm using mysql for dev and prod ans sqlite for test env
I fixed it, but it is required to create an alias of the doctrine.fixtures.loader
to load fixtures that use the doctrine.fixture.orm
tag.
This alias must be named doctrine.fixtures.loader.alias
and declared as public. It has to be set in a test bundle.
PHP Config:
$container
->alias('doctrine.fixtures.loader.alias', 'doctrine.fixtures.loader')
->public();
YAML Config:
services:
doctrine.fixtures.loader.alias:
alias: 'doctrine.fixtures.loader.alias'
public: true
At the moment I do not see any way to do it dynamically. Working on it.
I also disabled the backup service as I am not really happy with the current design of that feature. Also working on it.
I created a dedicated bundle to handle that.
It has to be set in your test AppKernel
class: new BehatExtension\DoctrineDataFixturesExtension\Bundle\BehatDoctrineDataFixturesExtensionBundle(),
Does anyone use the configuration options fixtures
or directories
?
I am not sure it makes sense to keep those features when fixtures can be found using tags.
WDYT?
I've used directories before, but not sure I'll continue to use it if service loading would work
For now I can confirm that my fixtures are successfully loaded as services, container-aware fixtures work, autoloading work. No config changes needed (only bundle registration, which I can consider as a new feature, not a bc-break). I'll do more testing and general PR review a bit later. Thank you for you work, @Spomky!
Good news!
I still consider that new version as a major one as it now requires PHP7.1 instead of PHP5.3.
The migration
feature -i.e. the load of the DB using the Doctrine Migration component- have also been removed (no documentation by the way).
I will restore that feature soon.
Still need to write additional tests (e.g. using mysql/pgsql and the backup feature).
Thank you for your comments. I updated the PR accordingly. Should be fine now. I will merge not later that friday and tag as @beta.
Merged and tagged as beta.
Proposal for #3