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', $this->router->generate('foggyline_shipment_flat_rate_process')); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame('application/json...