Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 (almost 6 years ago)
- Default Branch: 1.x
- Last Pushed: 2024-03-15T08:18:41.000Z (10 months ago)
- Last Synced: 2024-03-26T00:03:42.766Z (10 months 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
![Build status](https://github.com/facile-it/symfony-functional-testcase/workflows/CI/badge.svg)
[![Latest Stable Version](https://poser.pugx.org/facile-it/symfony-functional-testcase/v/stable)](https://packagist.org/packages/facile-it/symfony-functional-testcase)
[![Latest Unstable Version](https://poser.pugx.org/facile-it/symfony-functional-testcase/v/unstable)](https://packagist.org/packages/facile-it/symfony-functional-testcase)
[![Codecov coverage status](https://codecov.io/gh/facile-it/symfony-functional-testcase/branch/master/graph/badge.svg)](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`