Skip to content

Commit 556ff08

Browse files
authored
Merge pull request #8 from MacPaw/fix/orc-112-fix-configuration-doc
fix(bundle): fix install and configuration doc
2 parents bdc6377 + ad5a6ec commit 556ff08

File tree

1 file changed

+30
-44
lines changed

1 file changed

+30
-44
lines changed

docs/install.md

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,56 @@
11
# Installation
22

3-
## Step 1: Download the Bundle
3+
## Step 1: Install the Bundle
44

5-
Open a command console, enter your project directory and execute:
6-
7-
### Applications that use Symfony Flex
5+
Run the following command in your project directory to install the bundle as a development dependency:
86

97
```bash
108
composer require --dev macpaw/behat-orm-context
11-
```
12-
13-
### Applications that don't use Symfony Flex
9+
````
1410

15-
Open a command console, enter your project directory and execute the following command to download the latest stable
16-
version of this bundle:
17-
18-
```bash
19-
composer require --dev macpaw/behat-orm-context
20-
```
11+
> If you are using Symfony Flex, the bundle will be registered automatically.
12+
> Otherwise, follow Step 2 to register the bundle manually.
2113

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

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

2918
```php
3019
<?php
31-
// app/AppKernel.php
32-
33-
// ...
34-
class AppKernel extends Kernel
35-
{
36-
public function registerBundles()
37-
{
38-
$bundles = array(
39-
// ...
40-
BehatOrmContext\BehatOrmContextBundle::class => ['test' => true],
41-
);
42-
43-
// ...
44-
}
20+
// config/bundles.php
4521
22+
return [
4623
// ...
47-
}
24+
BehatOrmContext\BehatOrmContextBundle::class => ['test' => true],
25+
];
4826
```
4927

50-
## Step 2: Configure Behat
28+
> ℹ️ The bundle should only be enabled in the `test` environment.
29+
30+
## Step 3: Configure Behat
5131

52-
Go to `behat.yml`:
32+
Add the ORM context to your `behat.yml`:
5333

5434
```yaml
55-
# ...
56-
contexts:
57-
- BehatOrmContext\Context\OrmContext
58-
# ...
35+
default:
36+
suites:
37+
default:
38+
contexts:
39+
- BehatOrmContext\Context\ORMContext
5940
```
6041

61-
## Configuration
42+
## Step 4 (Optional): Inject a Custom ObjectManager
6243

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

6548
```yaml
66-
behat_orm_context:
67-
# Currently no specific configuration options are available
49+
when@test:
50+
services:
51+
BehatOrmContext\Context\ORMContext:
52+
arguments:
53+
$manager: '@doctrine.orm.other_entity_manager'
6854
```
6955

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

0 commit comments

Comments
 (0)