PHPackages                             rezzza/alice-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. rezzza/alice-extension

ActiveBehat-extension[Testing &amp; Quality](/categories/testing)

rezzza/alice-extension
======================

Alice extension for Behat

v3.0.1(6y ago)3237.3k13[4 issues](https://github.com/rezzza/alice-extension/issues)MITPHPPHP &gt;=5.3.2

Since Apr 16Pushed 6y ago5 watchersCompare

[ Source](https://github.com/rezzza/alice-extension)[ Packagist](https://packagist.org/packages/rezzza/alice-extension)[ Docs](https://github.com/rezzza/alice-extension)[ RSS](/packages/rezzza-alice-extension/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (8)Versions (22)Used By (0)

Alice Extension for Behat
=========================

[](#alice-extension-for-behat)

Make [Alice](https://github.com/nelmio/alice) work with [Behat](https://github.com/behat/behat).

You can import fixtures through a yaml file and from a behat step.

**Versions**

- 1.0.x version, for Behat 3.x: [![Build Status](https://camo.githubusercontent.com/e7d47e8e13ba2e2d15a33eb8216d9a0f133996d447a47e42cb141dbededc6a3a/68747470733a2f2f7472617669732d63692e6f72672f72657a7a7a612f616c6963652d657874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rezzza/alice-extension)
- 0.1.x version, for Behat 2.5.x

Installation
------------

[](#installation)

Through Composer :

```
    $ composer require --dev "rezzza/alice-extension:1.0.*@dev"

```

Configure your behat.yml :

```
default:
    extensions:
        Rezzza\AliceExtension\Extension:
            fixtures: /path/to/your/fixtures.yml
            lifetime: (scenario|feature)
            faker:
                locale: en_US #default
                providers: []
```

To write your `fixtures.yml` please report to [Alice documentation](https://github.com/nelmio/alice#creating-fixtures)

This extension need `Symfony2Extension` to work. Have a look to [its documentation](http://extensions.behat.org/symfony2/index.html)

Usage
-----

[](#usage)

In your behat configuration you can activate `AliceContext` for the test suite you need

```
default:
    suites:
        default:
            contexts:
                - Rezzza\AliceExtension\Context\AliceContext
```

So you can now write in your features :

```
Feature: Test My feature

    Background: Write fixtures
        Given I load "Vendor\My\Entity" fixtures where column "key" is the key:
            | key      | id | name |
            | fixture1 | 1  | jean |
            | fixture2 | 2  | marc |
```

If you use yaml file, you should consider put your default values in it thanks to [template inheritance](https://github.com/nelmio/alice#fixture-inheritance).

And use inline fixtures to override values you need.

Hook for specific entities
--------------------------

[](#hook-for-specific-entities)

Sometimes you need to apply specific operations for objects persisted. You can do it through the Symfony2 Bundle packed with this extension.

Activate the bundle:

```

```

Then in your Symfony2 app you will be able to build some Alice processors via service. It should extends `Nelmio\Alice\ProcessorInterface` and registred via the tag `alice_extension.processor`

Adapters
--------

[](#adapters)

Currently we support :

- DoctrineORM
- ElasticSearch (through FOSElasticaBundle)

```
default:
    extensions:
        Rezzza\AliceExtension\Extension:
            adapters:
                elastica: ~
                orm: ~
```

For ElasticSearch we should use `mapping` config to indicate which ElasticSearch type alice should use to persist your mode:

```
default:
    extensions:
        Rezzza\AliceExtension\Extension:
            adapters:
                elastica:
                    index_service: fos_elastica.index.name_of_your_index
                    mapping:
                        myType: My\Fully\Model
                orm: ~
```

Then in your features you should use tag to specify which adapters alice should use :

```
@alice:elastica
Feature: Test My feature

    Background: Write fixtures
        Given I load "Vendor\My\Entity" fixtures where column "key" is the key:
            | key      | id | name |
            | fixture1 | 1  | jean |
            | fixture2 | 2  | marc |
```

Advanced Fixtures
-----------------

[](#advanced-fixtures)

Fixtures can be managed through the configuration.

```
default:
    extensions:
        Rezzza\AliceExtension\Extension:
            default_loading: implicit
            fixtures:
                default: [users, products] # could be scalar if you want only one => users
                key_paths:
                    users: /src/path/to/your/fixtures.yml
                    products: /src/path/to/your/fixtures.yml
```

With this kind of configuration, when you'll call step below, it'll load **default** fixtures (**users** and **products** in this example). **default\_loading** key is important here, if it's defined as `implicit`, it'll implicitly load **default** fixtures when you use step below. If it's defined as `explicit` you'll have to use `Given I load "default" fixtures` to load **default** fixtures.

```
Given I load "Acme\Bundle\Entity\User" fixtures where column "key" is the key:
    | key                  | emailAddress     | password |
    | user1 (extends user) | chuck@norris.com | password |

```

You are able to load fixtures manually:

```
Given I load "default" fixtures   # will load users AND products
Given I load "users" fixtures     # will load users
Given I load "products" fixtures  # will load products

```

Of course, fixtures are loaded once.

Faker Providers
---------------

[](#faker-providers)

Some providers are available on AliceExtension:

- NullProvider: ``
- FixedDateTimeProvider: ``

You can add them (or your own) easily in behat.yml configuration:

```
default:
    extensions:
        Rezzza\AliceExtension\Extension:
            .....
            faker:
                locale: en_US #default
                providers:
                    - \Rezzza\AliceExtension\Providers\NullProvider
                    - \Rezzza\AliceExtension\Providers\FixedDateTimeProvider
                    - \Acme\Providers\YourOwnProvider
```

Lifetime
--------

[](#lifetime)

2 lifetime options are available.

- scenario : will reset fixtures after each scenario. You have to use **background** step to describe your fixtures
- feature : will reset fixtures after each feature. You have to use **scenario** step to describe your fixtures

FAQ
---

[](#faq)

- *I want to use this with Doctrine ODM !*
- You should do a PR
- *I wanto to use this with PostgreSQL !*
- You should do a PR

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 73% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Recently: every ~301 days

Total

20

Last Release

2518d ago

Major Versions

v0.1.4 → v1.0.02014-08-28

v0.4.0 → v1.1.02015-04-15

v0.5.0 → v1.4.02016-02-29

v1.4.0 → v2.0.02016-04-15

v2.0.1 → v3.0.02017-03-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/71b2691f4ac490f3ae00553c722631e184283c2677e2da3f68af8d85e17dc7ce?d=identicon)[tyx](/maintainers/tyx)

![](https://www.gravatar.com/avatar/47c3006a9e7662031ee9d3fa064238fef88479fd7d60f18dd47f038fbbd7dc5a?d=identicon)[steph\_py](/maintainers/steph_py)

---

Top Contributors

[![tyx](https://avatars.githubusercontent.com/u/245494?v=4)](https://github.com/tyx "tyx (65 commits)")[![stephpy](https://avatars.githubusercontent.com/u/232744?v=4)](https://github.com/stephpy "stephpy (13 commits)")[![armandabric](https://avatars.githubusercontent.com/u/95120?v=4)](https://github.com/armandabric "armandabric (5 commits)")[![shouze](https://avatars.githubusercontent.com/u/54712?v=4)](https://github.com/shouze "shouze (4 commits)")[![h4cc](https://avatars.githubusercontent.com/u/2981491?v=4)](https://github.com/h4cc "h4cc (2 commits)")

---

Tags

symfonyfixturesBDDalice

### Embed Badge

![Health badge](/badges/rezzza-alice-extension/health.svg)

```
[![Health](https://phpackages.com/badges/rezzza-alice-extension/health.svg)](https://phpackages.com/packages/rezzza-alice-extension)
```

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[lchrusciel/api-test-case

Perfect PHPUnit TestCase for JSON/XML API TDD with Symfony.

4115.5M63](/packages/lchrusciel-api-test-case)[liip/test-fixtures-bundle

This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications

1798.3M42](/packages/liip-test-fixtures-bundle)[novaway/common-contexts

Novaway Behat common contexts

18187.8k3](/packages/novaway-common-contexts)[macpaw/behat-messenger-context

Behat Context for testing Symfony Messenger component

16232.9k](/packages/macpaw-behat-messenger-context)[polishsymfonycommunity/symfony2-mocker-extension

Behat extension for mocking services defined in the Symfony2 dependency injection container.

26253.1k4](/packages/polishsymfonycommunity-symfony2-mocker-extension)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
