$ composer require php-solution/sf-functional-test
Add to your phpunit.xml extension and configure paths (comma separated relative file paths from your phpunit.xml configuration file):
<bootstrap class="PhpSolution\FunctionalTest\PhpUnit\Extension\PreRunEnvLoaderExtension">
<parameter name="paths" value="../.env,.env"/>
</bootstrap>
Add to your phpunit.xml extension:
<bootstrap class="PhpSolution\FunctionalTest\PhpUnit\Extension\PreRunCommandLauncherExtension">
<parameter name="command" value="functional-test:fixtures:load"/>
<!--Default is false. If true, if command's exit code > 0 then tests will fail immediately-->
<parameter name="exitOnError" value="true" />
</bootstrap>
Add to your phpunit.xml extension:
<bootstrap class="\PhpSolution\FunctionalTest\PhpUnit\Extension\DoctrineMigrationExtension" />
Or simply:
<bootstrap class="PhpSolution\FunctionalTest\PhpUnit\Extension\PreRunCommandLauncherExtension">
<parameter name="command" value="doctrine:migration:migrate --no-interaction"/>
<parameter name="exitOnError" value="true" />
</bootstrap>
Add to your phpunit.xml extension:
<bootstrap class="PhpSolution\FunctionalTest\PhpUnit\Extension\PreRunCommandLauncherExtension">
<parameter name="command" value="doctrine:mongodb:schema:drop --collection"/>
</bootstrap>
Add to your phpunit.xml extension:
<bootstrap class="PhpSolution\FunctionalTest\PhpUnit\Extension\PreRunNativeCommandLauncherExtension">
<parameter name="command" value="bin/console doctrine:mongodb:schema:drop --collection"/>
</bootstrap>
- Add to your config_test.yml:
security:
firewalls:
your_secured_category:
http_basic: ~
- Use on TestCase
$client = $this->getAuthorizedClient('user_login', 'password');
- Add EntityTrait or DocumentTrait to your TestCase
$this->getDoctrine()
- Find Entity helper method:
protected function findEntity(string $entityClass, string $orderBy = 'id', array $findBy = [])
protected function findDocument(string $documentClass, array $criteria = [])
protected function findDocuments(string $documentClass, array $criteria = [], array $orderBy = [])
- Refresh Entity:
protected function refreshEntity($entity)
protected function refreshDocument($document)
- Add config
swiftmailer:
disable_delivery: true
spool:
type: file
path: '%kernel.project_dir%/var/spool'
delivery_addresses: ~
- Add SpoolTrait and find methods
public function purgeSpool()
public function getSpooledEmails()
public function getEmailContent($file)
protected function getSpoolDir()
See correct project structure and configs for functional tests on link