Functional testing

Our entire module has only two controller classes that we want to test for responses. We want to make sure that the process method of the FlatRateController and DynamicRateController classes are accessible and working.

We will first create an src/Foggyline/ShipmentBundle/Tests/Controller/FlatRateControllerTest.php file, with content as follows:

namespace Foggyline\ShipmentBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class FlatRateControllerTest extends WebTestCase { private $client; private $router; public function setUp() { $this->client = static::createClient(); $this->router = $this->client->getContainer()->get('router'); } public function testProcessAction() { $this->client->request('GET', ...

Get Modular Programming with PHP 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.