September 2016
Intermediate to advanced
1091 pages
21h 41m
English
Similar to unit testing, we will only focus on a single functional test, as doing anything more robust would be out of the scope of this chapter. We will write a simple code that adds a product to the cart and accesses the checkout page. In order to add an item to the cart, here we also need to simulate the user login.
We write the src/Foggyline/SalesBundle/Tests/Controller/CartControllerTest.php test as follows:
namespace Foggyline\SalesBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; class CartControllerTest extends WebTestCase { private $client = null; public function setUp() ...Read now
Unlock full access