PHPackages                             ingenerator/be\_entity - 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. ingenerator/be\_entity

AbandonedLibrary[Testing &amp; Quality](/categories/testing)

ingenerator/be\_entity
======================

Doctrine 2 entity factory and expectation testing helper framework for Behat

v1.0.0(7y ago)12.2kBSD-3-ClausePHPPHP ^7.2

Since Jul 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ingenerator/be_entity)[ Packagist](https://packagist.org/packages/ingenerator/be_entity)[ Docs](http://github.com/ingenerator/be_entity)[ RSS](/packages/ingenerator-be-entity/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

Be\_Entity
==========

[](#be_entity)

Improve clarity of your Behat suites by easily specifying Doctrine2 entities within your feature files instead of in separate fixtures.

[![Build Status](https://camo.githubusercontent.com/daa7a17c19c63356eaa2051bf570b315bb7a01230bf5fba243772c9c4d52b59a/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f696e67656e657261746f722f62655f656e746974792e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/ingenerator/be_entity)

Usage Example
-------------

[](#usage-example)

```
Given a User entity "ingenerator@users.noreply.github.com" with password "12345678"
And I go to "/login"
And I fill in "email" with "ingenerator@users.noreply.github.com"
And I fill in "password" with "12345678"
When I press "Login"
Then I should be on "/"
And I should be logged in

Given no User entity "nobody.here@no.domain"
And I go to "/login"
And I fill in "email" with "ingenerator@users.noreply.github.com"
And I fill in "password" with "12345678"
When I press "Login"
Then I should be on "/login"
And I should see "Invalid user or password"
```

```
namespace Ingenerator\BeEntity\Factory;

class User extends Ingenerator\BeEntity\Factory {

	protected function _locate($identifier)
	{
		return $this->entity_manager->getRepository('Project\User')->findOneBy(array('email' => $identifier));
	}

	protected function _create($identifier)
	{
		$user = new Project\User;
		$user->set_email($identifier);
		$user->set_password('foo');
		return $user;
	}

}
```

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

[](#installation)

Add to your composer.json:

```
{
	"require": {
		"ingenerator/be_entity" : "dev-master"
	}
}
```

Create the BeEntity context as a subcontext of your FeatureContext:

```
class FeatureContext extends Behat\Behat\Context\BehatContext {

	public function __construct()
	{
		$em = new Doctrine\ORM\EntityManager;  // Whatever code you need to get an EntityManager instance in your app

		$this->useContext('be_entity', new Ingenerator\BeEntity\Context\BeEntityContext($em));
	}
}
```

Create factory classes for each type of entity you want to use in your features - see the example User factory above. Your factory defines how to use the step argument to search for an entity of that type and declares sensible defaults for a new entity record.

Note that you can have multiple factory classes for each entity type in your application - for example, you might create an Administrator factory that creates Project\\User entities with a particular field set or role granted.

Roadmap
-------

[](#roadmap)

- Generators for sequences of entities - eg user1, user2, user3
- Entity references - eg `Given the Blog entity "My first blog" has author "User: ingenerator@users.noreply.github.com"`
- Wipe db/wipe table hooks for specific scenarios that require an empty database or integration builds
- Review Entity Manager injection and consider a service container layer

Contributors and Credits
------------------------

[](#contributors-and-credits)

- Andrew Coulton [acoulton](http://github.com/acoulton) \[lead developer\]

Heavily inspired by [thoughtbot's factory\_girl ruby gem](https://github.com/thoughtbot/factory_girl).

Licence
-------

[](#licence)

[BSD Licence - see LICENSE](LICENSE)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.9% 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 ~125 days

Total

3

Last Release

2598d ago

Major Versions

v0.1.0 → v1.0.02019-04-03

PHP version history (2 changes)0.1.x-devPHP &gt;=5.5

v1.0.0PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6ebcc608a86cec9a3ce7a4932994e2b89fabbfcdde69aff43e8139f34e07a5e?d=identicon)[acoulton](/maintainers/acoulton)

---

Top Contributors

[![acoulton](https://avatars.githubusercontent.com/u/416566?v=4)](https://github.com/acoulton "acoulton (17 commits)")[![craig410](https://avatars.githubusercontent.com/u/1156379?v=4)](https://github.com/craig410 "craig410 (6 commits)")

---

Tags

testingwebdoctrine2Behat

### Embed Badge

![Health badge](/badges/ingenerator-be-entity/health.svg)

```
[![Health](https://phpackages.com/badges/ingenerator-be-entity/health.svg)](https://phpackages.com/packages/ingenerator-be-entity)
```

###  Alternatives

[imbo/behat-api-extension

API extension for Behat

1082.5M9](/packages/imbo-behat-api-extension)[robertfausk/behat-panther-extension

Symfony Panther extension for Behat

341.7M87](/packages/robertfausk-behat-panther-extension)[tonicforhealth/behat-parallel-scenario

Behat parallel scenario

24354.7k](/packages/tonicforhealth-behat-parallel-scenario)[vipsoft/code-coverage-extension

Behat code coverage collector

2186.5k2](/packages/vipsoft-code-coverage-extension)[drupal/tqextension

Behat extension for testing Drupal sites

1134.4k](/packages/drupal-tqextension)[jonathanjfshaw/phpunitbehat

Use Behat from within PHPUnit.

2143.8k1](/packages/jonathanjfshaw-phpunitbehat)

PHPackages © 2026

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