-
Notifications
You must be signed in to change notification settings - Fork 182
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
Use SymfonyFixturesLoader to load fixtures #432
Conversation
…quire injected service
As |
I think some test are failing because of my limited knowledge of functional tests. I'll take a look tomorrow but if you feel like taking a look I can use some help ! I'm quite confident that the feature is working as I use it in a dev project I have. |
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
Liip\FunctionalTestBundle\Tests\App\DataFixtures\ORM\: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think tests are failing because the service on this resource import should be tagged as fixture.
Liip\FunctionalTestBundle\Tests\App\DataFixtures\ORM\:
resource: 'DataFixtures/ORM/*'
tags: ['doctrine.fixture.orm']
see http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html#loading-fixtures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created magnetik#1 for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
humm, I was thinking that the "autoconfigure" should have taken care of this automagically (as test are implementing the right interface)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if DoctrineFixturesBundle did add __instanceof
, but you might be right. Checking now if they did..
https://symfony.com/blog/new-in-symfony-3-3-service-autoconfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, implementing ORMFixtureInterface
should be enough to autoconfigure the doctrine.fixture.orm
tag, whereafter FixturesCompilerPass
will add the fixture to the definition of doctrine.fixtures.loader
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the tag definition in the config.yml
and the test are passing. Is that something that can be related to order in which the services are loaded ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I guess the DoctrineFixturesBundle
is not loaded / included with the test
environment's AppKernel
?
That would also explain why it's working in your dev environment, as you probably did include the bundle in your kernel over there.
4763025
to
030d4d8
Compare
Okay so now it's green except for lowest dependencies. And I've no idea why :D |
97dddd2
to
cbd2ba6
Compare
Okay so it requires I've adapted the composer.json :) |
🎉 @alexislefebvre would be great if |
Or maybe @maximgubar could help us in getting this merged and releasing |
|
||
public function __construct(TokenStorageInterface $tokenStorage) | ||
{ | ||
$this->tokenStorage = $tokenStorage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to use $this->tokenStorage
in this test? I would like to ensure that this service is callable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a call in the load
method.
LGTM, I'm surprised that it doesn't break anything even though the fixture loader has been changed. Thanks! |
I'm expecting quite a few bugs to pop in, regarding DX with the declaration of the service and so on. Let's see how it goes when an alpha is released :) |
Where the previous fixture loader did simply rely on plain old class instantiation or a service definition, the loader now basically is enhanced by one that supports autowiring and autoconfiguration. In other words, as long as userland's service definitions are valid everything should be fine. Before vs After 🎉 Really looking forward to this! |
Could you please add a small documentation about these changes in https://github.com/liip/LiipFunctionalTestBundle/blob/2.x/CHANGELOG.md, and https://github.com/liip/LiipFunctionalTestBundle/blob/2.x/UPGRADE-2.0.md if this is a breaking change? |
Done |
Thanks @magnetik and @rvanlaak for your work on this PR, I released the 2.0.0-alpha5 version: https://github.com/liip/LiipFunctionalTestBundle/releases/tag/2.0.0-alpha5 |
@@ -25,9 +25,9 @@ | |||
"symfony/phpunit-bridge": "^3.4 || ^4.0", | |||
"doctrine/orm": "^2.6", | |||
"symfony/monolog-bundle": "^3.1", | |||
"doctrine/doctrine-fixtures-bundle": "^3.0", | |||
"doctrine/doctrine-fixtures-bundle": "^3.0 >=3.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line shouldn't be in require
section instead of require-dev
?
Since we use it in Services\FixturesLoaderFactory
, it's became a dependency, WDYT ?
Got this error when updating to 2.0.0-alpha5
The service "liip_functional_test.services.fixtures_loader_factory" has a dependency on a non-existent service "doctrine.fixtures.loader".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum so we should load the service only if the DoctrineFixturesBundle is available, because you should be able to use the bundle without using the fixtures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #437
It's another try to fix #411.
The downside of the
SymfonyFixturesLoader
is that it always load all fixtures and cannot load a subset of it.So I wrapped around some code to load only needed dependencies.
The test are not passing, but I'm not sure why as I can use it in my project.