-
Notifications
You must be signed in to change notification settings - Fork 26
feat: Make AppKernel with KernelTestCase compatible #44
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
feat: Make AppKernel with KernelTestCase compatible #44
Conversation
7739be9
to
f8f4f6f
Compare
@Nyholm I don't know how to deal with the failing tests:
Just found the following: symfony/symfony#30071 |
@Nyholm I found a solution, hope we can use it like that. |
bc6c33e
to
0919131
Compare
Awesome. Thank you. Could you update this PR after bumping composer.json. See #45 (comment) |
@Nyholm Yes, I have done some other changes too, I would like do this at the end because of the renamed tests. :) |
…patible - Add deprecation layer for AppKernel constructor - Add tests for usage with KernelTestCase - Deprecate BaseBundleTestCase - Update example in Readme
960a11f
to
2826783
Compare
@Nyholm Also ready now, without the breaking change layer. Ready for a major. |
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.
Thank you for working on this
src/AppKernel.php
Outdated
@@ -208,4 +214,35 @@ public function setRoutingFile($routingFile) | |||
{ | |||
$this->routingFile = $routingFile; | |||
} | |||
|
|||
public function handleOptions(array $options) |
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 is a new feature you snuck in. Why is it better to have an array of values rather than calling the underlying methods?
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.
😄 Yeah.
I liked the idea of the options in the KernelTestCase
, you are right, the methods are better.
The reason why I introduced this is: You only have the possibility to change the config by override the createKernel
this limits it to a configuration per file and not per test. (If you don't want to boot it yourself and just want to use static:bootKernel
.)
By just call the handleOptions
in the createKernel
you can actually passthrough everything before the kernel is booted and the container is compiled.
Another Idea, that just came in my mind, we could just create a option like config
which must be a callable:
static::bootKernel(['config' => static function(AppKernel $kernel){
$kernel->setRoutingFile(__DIR__.'/Fixtures/routes.yml');
}]);
Then we can benefit from the methods and save some lines, cause the KernelTestCase
makes the booting process.
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.
Thank you
/** | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
*/ | ||
abstract class BaseBundleTestCase extends TestCase |
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 is great. Im happy to remove this class.
fixes: #39