https://github.com/facile-it/symfony-functional-testcase
A base test case to speed up functional tests in Symfony -- this is a slimmed down fork of liip/LiipFunctionalTestBundle
https://github.com/facile-it/symfony-functional-testcase
phpunit symfony testing
Last synced: 4 months ago
JSON representation
A base test case to speed up functional tests in Symfony -- this is a slimmed down fork of liip/LiipFunctionalTestBundle
- Host: GitHub
- URL: https://github.com/facile-it/symfony-functional-testcase
- Owner: facile-it
- License: mit
- Fork: true (liip/LiipFunctionalTestBundle)
- Created: 2019-03-06T13:52:55.000Z (about 6 years ago)
- Default Branch: 1.x
- Last Pushed: 2024-03-15T08:18:41.000Z (about 1 year ago)
- Last Synced: 2024-03-26T00:03:42.766Z (about 1 year ago)
- Topics: phpunit, symfony, testing
- Language: PHP
- Homepage:
- Size: 1000 KB
- Stars: 0
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# facile-it/symfony-functional-testcase

[](https://packagist.org/packages/facile-it/symfony-functional-testcase)
[](https://packagist.org/packages/facile-it/symfony-functional-testcase)
[](https://codecov.io/gh/facile-it/symfony-functional-testcase)This is a small base TestCase for PHPUnit functional tests in Symfony that provides a simple `getContainer()` helper,
alongside with some small caching to speed up the tests.Forked (and slimmed down) from [liip/LiipFunctionalTestBundle](https://github.com/liip/LiipFunctionalTestBundle).
# Installation
```bash
$ composer require --dev facile-it/symfony-functional-testcase
```# Usage
To use this in one of your functional tests, you just have to edit it like this:```diff
makeClient();
$client->request('GET', '/contact');// Successful HTTP request
$this->isSuccessful($client->getResponse());
```Add `false` as the second argument in order to check that the request failed:
```php
$client = $this->makeClient();
$client->request('GET', '/error');// Request returned an error
$this->isSuccessful($client->getResponse(), false);
```In order to test more specific status codes, use `assertStatusCode()`:
##### assertStatusCode()
Check the HTTP status code from the request:
```php
$client = $this->makeClient();
$client->request('GET', '/contact');// Standard response for successful HTTP request
$this->assertStatusCode(302, $client);
```## Command Tests
TODO document `runCommand`