Skip to content
This repository has been archived by the owner on Sep 25, 2022. It is now read-only.

Latest commit

 

History

History
99 lines (68 loc) · 3.49 KB

README.md

File metadata and controls

99 lines (68 loc) · 3.49 KB

AliceFixturesExtension

A Behat extension to load HautelookAliceBundle fixtures.

Package version Build Status SensioLabsInsight Scrutinizer Code Quality

Installation

You can use Composer to install the bundle to your project:

composer require theofidry/alice-fixtures-extension

Then, in your behat config file behat.yml, register the extension and declare the context:

# behat.yml
default:
    suites:
        default:
            contexts:
                - Fidry\AliceFixturesExtension\Context\Doctrine\AliceORMContext

                # or if you want to set the base path only for this context:
                - Fidry\AliceFixturesExtension\Context\Doctrine\AliceORMContext:
                    basePath: %paths.base%/tests/Features/fixtures/ORM (default value)
    # ...
    extensions:
        Fidry\AliceFixturesExtension\Extension:
            fixtures_base_path: ~ # default to %paths.base%/features/fixtures

You have three contexts available:

  • Fidry\AliceFixturesExtension\Context\Doctrine\AliceODMContext
  • Fidry\AliceFixturesExtension\Context\Doctrine\AliceORMContext
  • Fidry\AliceFixturesExtension\Context\Doctrine\AlicePHPCRContext

With the default fixtures basePath respectively at:

  • %paths.base%/tests/Features/fixtures/ODM
  • %paths.base%/tests/Features/fixtures/ORM
  • %paths.base%/tests/Features/fixtures/PHPCR

Basic usage

Assuming you have the same configuration as the Installation section, you can create the following fixture file:

# features/fixtures/ORM/dummy.yml

AppBundle\Entity\Dummy:
    dummy_{1..10}:
        name: <name()>

Then simply load your fixtures with the following step:

Given the fixtures file "dummy.yml" is loaded
Given the fixtures file "dummy.yml" is loaded with the persister "doctrine.orm.entity_manager"

Steps

For each context, you have the following steps available:

@Given the database is empty
@Then I empty the database

@Given the fixtures "fixturesFile" are loaded
@Given the fixtures file "fixturesFile" is loaded
@Given the fixtures "fixturesFile" are loaded with the persister "persister_service_id"
@Given the fixtures file "fixturesFile" is loaded with the persister "persister_service_id"

Loading a file can be done in three ways:

  • Relative path: "dummy.yml", will look for contextBasePath/dummy.yml
  • @Bundle path: "@AppBundle/DataFixtures/ORM/dummy.yml", will resolve the @AppBundle for example src/AppBundle/DataFixtures/ORM/dummy.yml
  • Absolute path: /dummy.yml

Credits

This library is developed by Théo FIDRY.

License

license