Skip to content

fix: add doctrine reset manager #43

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

Merged
merged 1 commit into from
May 16, 2025
Merged
Show file tree
Hide file tree
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
23 changes: 5 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,18 @@ By default, the bundle has the following configuration:

```yaml
behat_api_context:
kernel_reset_managers: []
use_orm_context: true
kernel_reset_managers:
- BehatApiContext\Service\ResetManager\DoctrineResetManager
```

The `use_orm_context` parameter is no longer configurable manually. Its value is determined automatically based on whether the Doctrine ORM is installed:
> **Important:** This logic is applied internally and cannot be overridden via configuration.

| ORM Installed | Default `use_orm_context` |
|:-------------:|:-------------------------:|
| Yes | `true` |
| No | `false` |

You can override it manually in your `config/packages/test/behat_api_context.yaml`:

```yaml
behat_api_context:
use_orm_context: false
```

or

```yaml
behat_api_context:
use_orm_context: true
```

depending on your needs.

---

# Usage
Expand Down
1 change: 1 addition & 0 deletions src/Context/ORMContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function andISeeEntityInRepositoryWithProperties(string $entityClass, PyS
*/
private function seeInRepository(int $count, string $entityClass, ?array $params = null): void
{
/** @var class-string $entityClass */
$query = $this->manager->createQueryBuilder()
->from($entityClass, 'e')
->select('count(e)');
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/BehatApiContextExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace BehatApiContext\DependencyInjection;

use BehatApiContext\Context\ORMContext;
use BehatApiContext\Context\ApiContext;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
Expand Down Expand Up @@ -56,7 +56,7 @@ private function loadOrmContext(
$this->configureKernelResetManagers(
$config,
$container,
ORMContext::class
ApiContext::class
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/DependencyInjection/BehatApiContextExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testWithOrmContextEnabled(): void

self::assertTrue($container->hasDefinition(ORMContext::class));

$ormContextDefinition = $container->getDefinition(ORMContext::class);
$ormContextDefinition = $container->getDefinition(ApiContext::class);
$doctrineResetManagerDefinition = $container->getDefinition(DoctrineResetManager::class);

$methodCalls = $ormContextDefinition->getMethodCalls();
Expand Down
Loading