Download the PHP package kununu/testing-bundle without Composer
On this page you can find all versions of the php package kununu/testing-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package testing-bundle
kununu testing-bundle
This bundle integrates with kununu/data-fixtures package allowing you to load fixtures in your tests.
It also provides some utilities that makes testing easier, like a RequestBuilder
that turns testing controllers more expressive. If you want to see an example of what this bundle can do for you click here.
Install
1. Add kununu/testing-bundle to your project
Please be aware that this bundle should not be used in production mode!
2. Enable Bundle
Enable the bundle at config/bundles.php
for any environment.
Configuration
Create the file kununu_testing.yaml
inside config/packages/test/
.
The configuration options of the bundle heavily depend on the fixture type. Check out the Load Fixtures section where you can find more options.
Tip
If you are using the bundle on more than one environment, for example dev and test, and the configuration options are exactly the same you can import the kununu_testing.yaml
like bellow in order to not duplicate the configurations.
Load Fixtures
This bundle integrates with kununu/data-fixtures allowing you to load fixtures in your tests. Currently, this bundle supports the following types of fixtures:
- Doctrine DBAL Connection Fixtures
- Cache Pool Fixtures
- Elasticsearch Fixtures
- Symfony Http Client Fixtures
Schema Copier
This bundle also has a way of copying a database schema from one database to another.
See more:
- Schema Copier
Making a Request
Request Builder
This bundle provides a Request Builder which makes calling an endpoint more expressive.
WebTestCase
This bundle exposes the WebTestCase that you can extend which exposes a method that helps you testing your controllers without having to care about create the kernel. This class also allows you load fixtures in your tests.
Internally this method calls the Symfony client with:
Example
Let's imagine that you have a route named company_create which is protected (A valid access token needs to be provided) and expects a json to be provided in the body of the request with the data required to create a new company.
Using concepts provided by this bundle, like Loading Fixtures, the RequestBuilder and the WebTestCase our test could like:
Contribute
If you are interested in contributing read our contributing guidelines.
Tests
This repository takes advantages of GitHub actions to run tests when a commit is performed to a branch.
If you want to run the integration tests on your local machine you will need:
- pdo_mysql extension
- MySQL server
- Elasticsearch cluster
In your local environment to get everything ready for you, run ./tests/setupLocalTests.sh
and follow the instructions.
Then you can run the tests: vendor/bin/phpunit
.
All versions of testing-bundle with dependencies
symfony/framework-bundle Version ^5.4|^6.4
kununu/data-fixtures Version ^12.0
symfony/config Version ^5.4|^6.4
symfony/dependency-injection Version ^5.4|^6.4
symfony/http-kernel Version ^5.4|^6.4