Functional testing
Our module has two controller classes that we want to test for responses. We want to make sure that the authorize
, capture
, and cancel
methods of the CardController
and CheckMoneyController
classes are working.
We first create asrc/Foggyline/PaymentBundle/Tests/Controller/CardControllerTest.php
file, with content as follows:
namespace Foggyline\PaymentBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class CardControllerTest extends WebTestCase { private $client; private $router; public function setUp() { $this->client = static::createClient(); $this->router = $this->client->getContainer()->get('router'); } public function testAuthorizeAction() { $this->client->request('GET', $this->router->generate('foggyline_payment_card_authorize')); ...
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.