macpaw / behat-doctrine-fixtures
Bundle for creating Doctrine fixtures
Installs: 74 189
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 4
Forks: 2
Open Issues: 2
Type:symfony-bundle
Requires
- php: ^7.4 || ^8.0
- behat/behat: ^3.0
- doctrine/doctrine-bundle: ^2.0
- doctrine/doctrine-fixtures-bundle: ^3.0
- doctrine/doctrine-migrations-bundle: ^3.0
- doctrine/orm: ^2.0
- symfony/dependency-injection: ^4.4 || ^5.4 || ^6.0 || ^7.0
- symfony/http-kernel: ^4.4 || ^5.4 || ^6.0 || ^7.0
- theofidry/alice-data-fixtures: ^1.0
Requires (Dev)
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^9.5
- slevomat/coding-standard: ^7.0
- squizlabs/php_codesniffer: ^3.6
- symfony/console: ^4.4 || ^5.4 || ^6.0 || ^7.0
- symfony/property-access: ^4.4 || ^5.4 || ^6.0 || ^7.0
This package is auto-updated.
Last update: 2024-04-08 14:18:56 UTC
README
Version | Build Status | Code Coverage |
---|---|---|
master |
||
develop |
Migrate from 1.x to 2.0
To migrate from 1.x to 2.0, follow our guide.
Installation
Step 1: Install Bundle
Open a command console, enter your project directory and execute:
$ composer require --dev macpaw/behat-doctrine-fixtures
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
If you use PostgreSQL database, you also need to install postgresql-client:
$ apt-get install -y postgresql-client
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... BehatDoctrineFixtures\BehatDoctrineFixturesBundle::class => ['test' => true] ); // ... } // ... }
Step 3: Create Behat Doctrine Fixtures Config:
config/packages/test/behat_doctrine_fixtures.yaml
Configurating behat database context
behat_doctrine_fixtures: connections: default: database_fixtures_paths: - <path to directory with your fixtures>
You don't need to explicitly pass database url here, since this bundle uses doctrine connection under the hood. For now, we support PostgreSQL and Sqlite databases.
If you want to use multiple databases in your project, just add one more connection under behat_doctrine_fixtures.connections
with its own configuration:
behat_doctrine_fixtures: connections: default: database_fixtures_paths: - <path to directory with your fixtures> <secondConnectionName>: run_migrations_command: <customMigrationsCommand> database_fixtures_paths: - <path to directory with your fixtures>
Step 4: Configure Behat
Go to behat.yml
... contexts: - BehatDoctrineFixtures\Context\DatabaseContext ...