facile-it / symfony-functional-testcase
A small functional base test case for Symfony
Installs: 17 708
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 181
Open Issues: 0
Requires
- php: ^7.4|^8.0
- symfony/framework-bundle: ^4.4|^5.0|^6.0|^7.0
Requires (Dev)
- facile-it/facile-coding-standard: ^1.2
- jangregor/phpstan-prophecy: ^1.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.10
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5.2
- symfony/browser-kit: ^4.4|^5.0|^6.0|^7.0
- symfony/console: ^4.4|^5.0|^6.0|^7.0
- symfony/monolog-bridge: >=3
- symfony/monolog-bundle: ^3.1.2
- symfony/phpunit-bridge: ^5.1.8
- symfony/security-bundle: ^4.4|^5.0|^6.0|^7.0
- symfony/security-core: ^4.4|^5.0|^6.0|^7.0
- symfony/yaml: ^4.4|^5.0|^6.0|^7.0
Suggests
- facile-it/paraunit: A PHPUnit wrapper to execute tests in parallel
This package is auto-updated.
Last update: 2024-11-19 22:04:47 UTC
README
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.
Installation
$ 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:
<?php namespace Tests; -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Facile\SymfonyFunctionalTestCase\WebTestCase; class SomeTest extends WebTestCase {
Functionalities
Check HTTP status codes
isSuccessful()
Check that the request succedded:
$client = $this->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:
$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:
$client = $this->makeClient(); $client->request('GET', '/contact'); // Standard response for successful HTTP request $this->assertStatusCode(302, $client);
Command Tests
TODO document runCommand