# dmaicher/doctrine-test-bundle architecture

> Architecture diagram of the GitHub repository dmaicher/doctrine-test-bundle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dmaicher/doctrine-test-bundle
- Repository: https://github.com/dmaicher/doctrine-test-bundle

## Overview

DAMA DoctrineTestBundle isolates Symfony/Doctrine tests by reusing database connections within a PHP process and wrapping test work in rollbackable transactions. PHPUnit and Behat provide separate lifecycle integrations; Symfony configuration and compiler passes wire enabled connections and static caches. The README documents these capabilities, while source excerpts show the driver, connection wrappers, and compiler-pass wiring. Some relationships for unsampled configuration and integrations are documented rather than inspected in source.

Main entry points: [`src/Doctrine/DBAL/StaticDriver.php`](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/StaticDriver.php) (Static driver), [`src/DAMADoctrineTestBundle.php`](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DAMADoctrineTestBundle.php) (Bundle registration), [`src/DependencyInjection/AddMiddlewaresCompilerPass.php`](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/AddMiddlewaresCompilerPass.php) (Middleware setup), [`src/DependencyInjection/ModifyDoctrineConfigCompilerPass.php`](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/ModifyDoctrineConfigCompilerPass.php) (Doctrine config setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Bundle configuration"]
  node_bundle["Bundle registration"]
  node_config_extension["Config extension"]
  node_config["Bundle configuration<br/>[Configuration.php]"]
  node_middleware_pass["Middleware setup"]
  node_doctrine_pass["Doctrine config setup"]
end

subgraph group_connection["Static connections"]
  node_middleware["DBAL middleware<br/>[Middleware.php]"]
  node_static_driver["Static driver<br/>[StaticDriver.php]"]
  node_static_connection["Savepoint connection"]
  node_connection_trait["Savepoint operations"]
end

subgraph group_cache["Static caches"]
  node_static_cache["PSR-6 static cache"]
end

subgraph group_integrations["Test integrations"]
  node_phpunit_extension["PHPUnit lifecycle"]
  node_skip_rollback["Rollback opt-out"]
  node_behat_extension["Behat extension"]
  node_behat_listener["Behat lifecycle<br/>[BehatListener.php]"]
end

node_symfony(("Symfony container"))
node_db_driver["Doctrine DBAL driver"]
node_database[("Database")]
node_entity_managers["Doctrine EntityManagers"]
node_phpunit(("PHPUnit runner"))
node_behat(("Behat runner"))

node_symfony -->|"loads bundle"| node_bundle
node_bundle -->|"registers pass"| node_middleware_pass
node_bundle -->|"registers pass"| node_doctrine_pass
node_config_extension -->|"loads schema"| node_config
node_middleware_pass -->|"reads settings"| node_config
node_middleware_pass -->|"registers middleware"| node_middleware
node_doctrine_pass -->|"reads settings"| node_config
node_doctrine_pass -->|"sets cache service"| node_static_cache
node_middleware -->|"wraps driver"| node_static_driver
node_static_driver -->|"delegates connection"| node_db_driver
node_static_driver -->|"wraps shared connection"| node_static_connection
node_static_connection -->|"uses operations"| node_connection_trait
node_connection_trait -->|"executes savepoints"| node_database
node_static_cache -->|"serves cache"| node_entity_managers
node_phpunit -->|"runs extension"| node_phpunit_extension
node_phpunit_extension -->|"controls transactions"| node_static_driver
node_phpunit_extension -->|"checks opt-out"| node_skip_rollback
node_behat -->|"loads extension"| node_behat_extension
node_behat_extension -->|"registers listener"| node_behat_listener
node_behat_listener -->|"controls transactions"| node_static_driver

click node_bundle "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DAMADoctrineTestBundle.php"
click node_config_extension "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/DAMADoctrineTestExtension.php"
click node_config "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/Configuration.php"
click node_middleware_pass "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/AddMiddlewaresCompilerPass.php"
click node_doctrine_pass "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/ModifyDoctrineConfigCompilerPass.php"
click node_middleware "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/Middleware.php"
click node_static_driver "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/StaticDriver.php"
click node_static_connection "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/StaticConnection.php"
click node_connection_trait "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/StaticConnectionTrait.php"
click node_static_cache "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/Cache/Psr6StaticArrayCache.php"
click node_phpunit_extension "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/PHPUnit/PHPUnitExtension.php"
click node_skip_rollback "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/PHPUnit/SkipDatabaseRollback.php"
click node_behat_extension "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Behat/ServiceContainer/DoctrineExtension.php"
click node_behat_listener "https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Behat/BehatListener.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bundle,node_config_extension,node_config,node_middleware_pass,node_doctrine_pass toneBlue
class node_middleware,node_static_driver,node_static_connection,node_connection_trait,node_database toneAmber
class node_static_cache toneMint
class node_phpunit_extension,node_skip_rollback,node_behat_extension,node_behat_listener toneRose
class node_symfony,node_db_driver,node_entity_managers,node_phpunit,node_behat toneIndigo
```

## Components

### Bundle configuration

- [Bundle registration](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DAMADoctrineTestBundle.php): `src/DAMADoctrineTestBundle.php`
- [Config extension](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/DAMADoctrineTestExtension.php): `src/DependencyInjection/DAMADoctrineTestExtension.php`
- [Bundle configuration](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/Configuration.php): `src/DependencyInjection/Configuration.php`
- [Middleware setup](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/AddMiddlewaresCompilerPass.php): `src/DependencyInjection/AddMiddlewaresCompilerPass.php`
- [Doctrine config setup](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/DependencyInjection/ModifyDoctrineConfigCompilerPass.php): `src/DependencyInjection/ModifyDoctrineConfigCompilerPass.php`

### Static connections

- [DBAL middleware](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/Middleware.php): `src/Doctrine/DBAL/Middleware.php`
- [Static driver](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/StaticDriver.php): `src/Doctrine/DBAL/StaticDriver.php`
- [Savepoint connection](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/StaticConnection.php): `src/Doctrine/DBAL/StaticConnection.php`
- [Savepoint operations](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/DBAL/StaticConnectionTrait.php): `src/Doctrine/DBAL/StaticConnectionTrait.php`

### Static caches

- [PSR-6 static cache](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Doctrine/Cache/Psr6StaticArrayCache.php): `src/Doctrine/Cache/Psr6StaticArrayCache.php`

### Test integrations

- [PHPUnit lifecycle](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/PHPUnit/PHPUnitExtension.php): `src/PHPUnit/PHPUnitExtension.php`
- [Rollback opt-out](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/PHPUnit/SkipDatabaseRollback.php): `src/PHPUnit/SkipDatabaseRollback.php`
- [Behat extension](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Behat/ServiceContainer/DoctrineExtension.php): `src/Behat/ServiceContainer/DoctrineExtension.php`
- [Behat lifecycle](https://github.com/dmaicher/doctrine-test-bundle/blob/master/src/Behat/BehatListener.php): `src/Behat/BehatListener.php`

### Other components

- **Symfony container**
- **Doctrine DBAL driver**
- **Database**
- **Doctrine EntityManagers**
- **PHPUnit runner**
- **Behat runner**

## Connections

- Symfony container → Bundle registration: loads bundle (evidence: `src/DAMADoctrineTestBundle.php`)
- Bundle registration → Middleware setup: registers pass (evidence: `src/DAMADoctrineTestBundle.php`)
- Bundle registration → Doctrine config setup: registers pass (evidence: `src/DAMADoctrineTestBundle.php`)
- Config extension → Bundle configuration: loads schema (evidence: `src/DependencyInjection/DAMADoctrineTestExtension.php`)
- Middleware setup → Bundle configuration: reads settings (evidence: `src/DependencyInjection/AddMiddlewaresCompilerPass.php`)
- Middleware setup → DBAL middleware: registers middleware (evidence: `src/DependencyInjection/AddMiddlewaresCompilerPass.php`)
- Doctrine config setup → Bundle configuration: reads settings (evidence: `src/DependencyInjection/ModifyDoctrineConfigCompilerPass.php`)
- Doctrine config setup → PSR-6 static cache: sets cache service (evidence: `src/DependencyInjection/ModifyDoctrineConfigCompilerPass.php`)
- DBAL middleware → Static driver: wraps driver (evidence: `src/Doctrine/DBAL/Middleware.php`)
- Static driver → Doctrine DBAL driver: delegates connection (evidence: `src/Doctrine/DBAL/StaticDriver.php`)
- Static driver → Savepoint connection: wraps shared connection (evidence: `src/Doctrine/DBAL/StaticDriver.php`)
- Savepoint connection → Savepoint operations: uses operations (evidence: `src/Doctrine/DBAL/StaticConnection.php`)
- Savepoint operations → Database: executes savepoints (evidence: `src/Doctrine/DBAL/StaticConnectionTrait.php`)
- PSR-6 static cache → Doctrine EntityManagers: serves cache (evidence: `README.md`)
- PHPUnit runner → PHPUnit lifecycle: runs extension (evidence: `README.md`)
- PHPUnit lifecycle → Static driver: controls transactions (evidence: `src/PHPUnit/PHPUnitExtension.php`)
- PHPUnit lifecycle → Rollback opt-out: checks opt-out (evidence: `src/PHPUnit/PHPUnitExtension.php`)
- Behat runner → Behat extension: loads extension (evidence: `README.md`)
- Behat extension → Behat lifecycle: registers listener (evidence: `src/Behat/ServiceContainer/DoctrineExtension.php`)
- Behat lifecycle → Static driver: controls transactions (evidence: `src/Behat/BehatListener.php`)
