Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 30 additions & 44 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,56 @@
# Installation

## Step 1: Download the Bundle
## Step 1: Install the Bundle

Open a command console, enter your project directory and execute:

### Applications that use Symfony Flex
Run the following command in your project directory to install the bundle as a development dependency:

```bash
composer require --dev macpaw/behat-orm-context
```

### Applications that don't use Symfony Flex
````

Open a command console, enter your project directory and execute the following command to download the latest stable
version of this bundle:

```bash
composer require --dev macpaw/behat-orm-context
```
> If you are using Symfony Flex, the bundle will be registered automatically.
> Otherwise, follow Step 2 to register the bundle manually.

This command requires you to have Composer installed globally, as explained
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.
## Step 2: Register the Bundle

Then, enable the bundle by adding it to the list of registered bundles
in the `app/AppKernel.php` file of your project:
If your project does **not** use Symfony Flex or the bundle does not provide a recipe, manually register it in `config/bundles.php`:

```php
<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
BehatOrmContext\BehatOrmContextBundle::class => ['test' => true],
);

// ...
}
// config/bundles.php

return [
// ...
}
BehatOrmContext\BehatOrmContextBundle::class => ['test' => true],
];
```

## Step 2: Configure Behat
> ℹ️ The bundle should only be enabled in the `test` environment.

## Step 3: Configure Behat

Go to `behat.yml`:
Add the ORM context to your `behat.yml`:

```yaml
# ...
contexts:
- BehatOrmContext\Context\OrmContext
# ...
default:
suites:
default:
contexts:
- BehatOrmContext\Context\ORMContext
```

## Configuration
## Step 4 (Optional): Inject a Custom ObjectManager

By default, the bundle has the following configuration:
By default, `ORMContext` uses the `doctrine.orm.entity_manager` service.
To override this and inject a custom Doctrine ObjectManager (which implements `Doctrine\ORM\EntityManagerInterface`),
update your service configuration in `config/services.yaml` under the `test` environment:

```yaml
behat_orm_context:
# Currently no specific configuration options are available
when@test:
services:
BehatOrmContext\Context\ORMContext:
arguments:
$manager: '@doctrine.orm.other_entity_manager'
```

You can override it manually in your `config/packages/test/behat_orm_context.yaml`.
This allows you to swap the ObjectManager used by the context without modifying the class itself.