项目作者: theofidry

项目描述 :
Behat extension for HautelookAliceBundle.
高级语言: PHP
项目地址: git://github.com/theofidry/AliceBundleExtension.git
创建时间: 2015-08-23T11:02:15Z
项目社区:https://github.com/theofidry/AliceBundleExtension

开源协议:MIT License

下载


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:

  1. composer require --dev theofidry/alice-bundle-extension

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

  1. # behat.yml
  2. default:
  3. suites:
  4. default:
  5. contexts:
  6. - Fidry\AliceBundleExtension\Context\Doctrine\AliceORMContext
  7. # or if you want to set the base path only for this context:
  8. - Fidry\AliceBundleExtension\Context\Doctrine\AliceORMContext:
  9. basePath: %paths.base%/tests/Features/fixtures/ORM (default value)
  10. # ...
  11. extensions:
  12. Fidry\AliceBundleExtension\Extension:
  13. 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:

  1. # features/fixtures/ORM/dummy.yml
  2. AppBundle\Entity\Dummy:
  3. dummy_{1..10}:
  4. name: <name()>

Then simply load your fixtures with the following step:

  1. Given the fixtures file "dummy.yml" is loaded
  2. Given the fixtures file "dummy.yml" is loaded with the persister "doctrine.orm.entity_manager"
  3. Given the following fixtures files are loaded:
  4. | fixtures1.yml |
  5. | 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:

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

Steps

For each context, you have the following steps available:

  1. @Given the database is empty
  2. @Then I empty the database
  3. @Given the fixtures "fixturesFile" are loaded
  4. @Given the fixtures file "fixturesFile" is loaded
  5. @Given the fixtures "fixturesFile" are loaded with the persister "persister_service_id"
  6. @Given the fixtures file "fixturesFile" is loaded with the persister "persister_service_id"
  7. @Given the following fixtures files are loaded:
  8. | fixtures1.yml |
  9. | fixtures2.yml |
  10. @Given the following fixtures files are loaded with the persister "persister_service_id":
  11. | fixtures1.yml |
  12. | 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