Coder Social home page Coder Social logo

alicebundleextension's Introduction

AliceBundleExtension

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-bundle-extension

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

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

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

You have three contexts available:

  • Fidry\AliceBundleExtension\Context\Doctrine\AliceODMContext
  • Fidry\AliceBundleExtension\Context\Doctrine\AliceORMContext
  • Fidry\AliceBundleExtension\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"
Given the following fixtures files are loaded:
  | fixtures1.yml |
  | fixtures2.yml |

Loading fixture parameters

Fixture parameters can be loaded in the same way as loading fixtures. Any available step which loads fixtures, can also load parameters. You have to load your parameters before the dependend fixtures:

Given the fixtures file "parameters.yml" is loaded
And the fixtures file "dummy.yml" is loaded

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"
@Given the following fixtures files are loaded:
  | fixtures1.yml |
  | fixtures2.yml |
@Given the following fixtures files are loaded with the persister "persister_service_id":
  | fixtures1.yml |
  | fixtures2.yml |

Loading fixture files can be done as follows:

Type of path Fixtures file path Computed fixtures file path
Relative path `"dummy.yml"` `contextBasePath/dummy.yml`, ex: `%paths.base%/tests/Features/fixtures/ORM/dummy.yml`
@Bundle path `"@AppBundle/DataFixtures/ORM/dummy.yml"` `src/AppBundle/DataFixtures/ORM/dummy.yml` (example)
Absolute path `/dummy.yml` unchanged
Absolute directory path `/tests/Features/fixtures/ORM/` `/tests/Features/fixtures/ORM/*`
@Bundle `@AppBundle` `src/AppBundle/DataFixtures/ORM/*`

Paths can also be directories.

Credits

This library is developed by Théo FIDRY.

License

license

alicebundleextension's People

Contributors

akomm avatar caciobanu avatar gelolabs avatar theofidry avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.