Download the PHP package draw/tester-bundle without Composer
On this page you can find all versions of the php package draw/tester-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tester-bundle
Draw Tester Bundle
This bundle integrate the Draw Tester Component.
It also provides test helpers to make it easier to test your Symfony application.
Kernel Testing
When configuring your kernel you may want to test that everything is hooked up correctly.
There is the list of service, event dispatcher, command etc.
There is some TestCase/Trait to help you do that (work in progress).
Event Dispatcher
Relying on the debug:event-dispatcher
command we can dump the list of event listeners and validated it against the expected list.
The first time you run this test it will fail and dump the current configuration in the event_dispatcher.xml
file.
Commit this file, next time your rune this test you will be able to validate that the configuration is still valid.
If you change the listener in your code or change your dependencies you can run the test again and see the diff.
This will allow you to see if some external listeners changed at the same time.
PHPUnit Extension
This bundle also provide a PHPUnit extension to make it easier to test your Symfony application.
KernelShutdown
Sometimes you need to use the kernel/container in a tearDownAfterClass method.
Since symfony shutdown the kernel in the tearDown method, this will boot a new kernel cause a kernel to be up.
Adding the KernelShutdownExtension will make sure the kernel is shutdown after the test.
SetUpAutowire addon
The draw/tester component provide a way to autowire property in your test.
This bundle provide some custom Autowire attribute that can use in the context of a Symfony test cases.
Make sure to register is in your phpunit configuration file. as explained in the draw/tester
documentation.
Here is an example of attribute you can use in your test case:
If you extend from a WebTestCase
you can also use the AutowireClient
attribute to get a client.
By using the AutowireClient
in conjunction with the AutowireService
you are use that the client is
created before the other service preventing the exception:
Booting the kernel before calling "Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient" is not supported, the kernel should only be booted once
This is the same client as the one you get from the WebTestCase
, you can use it the same way.
Note that the AutowireClient
attribute have an options
and server
parameters like you would do when calling the createClient
method.
DoctrineTransaction
Base on dama/doctrine-test-bundle
this extension will start a transaction before each test class and rollback it after the test.
By using test class instead of test method, like the original bundle does, it will ease dependencies managements.
Make sure to configure this extension first in your phpunit configuration file.
Also if one of your test should not have transaction you can use the NoTransaction
attribute on the test class.
All versions of tester-bundle with dependencies
draw/core Version ^0.14
draw/tester Version ^0.14
symfony/browser-kit Version ^6.4.0
symfony/deprecation-contracts Version ^3.5.0
symfony/framework-bundle Version ^6.4.0
symfony/http-foundation Version ^6.4.0
symfony/validator Version ^6.4.0