Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Behat support #80

Merged
merged 2 commits into from Apr 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 42 additions & 0 deletions README.md
Expand Up @@ -99,6 +99,48 @@ public function testMyTestCaseThatINeedToDebug()
}
```

### Behat

It is possible to use this bundle in a Behat test suite if scenarios are executed in the same process as Behat. This will not work if the Behat tests invoke the application via HTTP requests.

To use the bundle follow the installation instructions and add the following methods to your `FeatureContext` class:

```php
/**
* @BeforeSuite
*/
public static function beforeSuite()
{
StaticDriver::setKeepStaticConnections(true);
}

/**
* @BeforeScenario
*/
public function beforeScenario()
{
StaticDriver::beginTransaction();
}

/**
* @AfterScenario
*/
public function afterScenario()
{
StaticDriver::rollBack();
}

/**
* @AfterSuite
*/
public static function afterSuite()
{
StaticDriver::setKeepStaticConnections(false);
}
```

See [dmaicher/symfony-flex-behat-test](https://github.com/dmaicher/symfony-flex-behat-test) for a complete example.

### Troubleshooting

In case you are running (maybe without knowing it) queries during your tests that are implicitly committing any open transaction
Expand Down