The FoggylineShipmentBundle
module is quite simple. By providing only two simple services and two simple controllers, it's easy to test.
We will start off by adding the following line under the testsuites
element of our phpunit.xml.dist
file:
<directory>src/Foggyline/ShipmentBundle/Tests</directory>
With that in place, running the phpunit
command from root of our shop should pick up any test we have defined under the src/Foggyline/ShipmentBundle/Tests/
directory.
Now, let's go ahead and create a test for our FlatRateShipment
service. We will do so by creating a src/Foggyline/ShipmentBundle/Tests/Service/FlatRateShipmentTest.php
file, with content as follows:
namespace Foggyline\ShipmentBundle\Tests\Service; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; class FlatRateShipmentTest extends KernelTestCase { private $container; private $router; private $street = 'Masonic Hill Road'; private $city = 'Little Rock'; private $country = 'US'; private $postcode...