Add to composer.json:
"require-dev": {
"php-solution/sf-functional-test": "dev-master"
},
or if you run composer install without dev, but you must run phpunit to section "required"
Add to your phpunit.xml listener and configure arguments(relative file paths from your phpunit.xml configuration file):
<listener class="PhpSolution\FunctionalTest\PHPUnit\Listener\EnvLoader">
<arguments>
<array>
<element key="0">
<string>../.env</string>
</element>
<element key="1">
<string>.env</string>
</element>
</array>
</arguments>
</listener>
Add to your phpunit.xml Listener:
<listeners>
<listener class="PhpSolution\FunctionalTest\PHPUnit\Listener\FixtureLoader" />
<arguments>
<array>
<element key="--fixtures">
<string>%kernel.root_dir%/../tests/DataFixtures</string>
</element>
</array>
</arguments>
</listeners>
Add to your phpunit.xml Listener:
<listener class="PhpSolution\FunctionalTest\PHPUnit\Listener\MigrationLauncher">
</listener>
- Add to your config_test.yml:
security:
firewalls:
your_secured_category:
http_basic: ~
- Use on TestCase
$client = $this->getAuthorizedClient('user_login', 'password');
protected function getContainer()
protected function getRouter()
protected function generateUrl($route, $params = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
protected function getSecurityToken()
- Get doctrine service(return $this->container->get('doctrine')):
$this->getDoctrine()
- Find Entity helper method:
protected function findTestEntity($entityClass, $orderBy = 'id', $findBy = [])
- Refresh Entity:
protected function refreshEntity($entity)
See correct project structure and configs for functional tests on link