Skip to content

A base test case to speed up functional tests in Symfony -- this is a slimmed down fork of liip/LiipFunctionalTestBundle

License

Notifications You must be signed in to change notification settings

facile-it/symfony-functional-testcase

 
 

Repository files navigation

facile-it/symfony-functional-testcase

Build status Latest Stable Version Latest Unstable Version Codecov coverage status

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

About

A base test case to speed up functional tests in Symfony -- this is a slimmed down fork of liip/LiipFunctionalTestBundle

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 98.6%
  • Makefile 1.4%