dbstudios / symfony-phpunit-helpers
1.0.1
2017-07-07 16:34 UTC
Requires
- php: >=5.6
- liip/functional-test-bundle: ~1.8
- phpunit/phpunit: ~5.7
Requires (Dev)
Suggests
- dbstudios/doctrine-entities: Required when using entity related assertions
- doctrine/doctrine-fixtures-bundle: Required when autoloading fixtures in setUp
This package is auto-updated.
Last update: 2024-12-19 11:01:59 UTC
README
Add the following to app/AppKernel.php
.
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { // ... if (in_array($this->getEnvironment(), array('dev', 'test'), true)) { // ... if ($this->getEnvironment() === 'test') { $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle(); } } return $bundles; } // ... }
Next, enable the Liip bundle. Additionally, you should also configure Doctrine to use a temporary SQLite database, in lieu of your normal database connection.
liip_functional_test: cache_sqlite_db: true # Optional, but recommended; tells Doctrine to use a temporary SQLite database for testing doctrine: dbal: driver: pdo_sqlite path: '%kernel.cache_dir%/test.db'
Please read the LiipFunctionalTestBundle documentation for more information on configuring the Liip bundle.
Usage
Simply have your test cases extend from DaybreakStudios\Utility\SymfonyPHPUnitHelpers\WebTestCase
.
<?php use DaybreakStudios\Utility\SymfonyPHPUntHelpers\WebTestCase; class MyTestCase extends WebTestCase { public function testItRespondsSuccessfully() { $this->client->request('GET', '/home'); $response = $this->client->getResponse(); $this->isSuccessful($response); } }