PHPackages                             espend/behat-placeholder-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. [Database &amp; ORM](/categories/database)
4. /
5. espend/behat-placeholder-extension

ActiveLibrary[Database &amp; ORM](/categories/database)

espend/behat-placeholder-extension
==================================

Behat placeholder extension

2.0.0(3mo ago)5141.8k↓25.6%2[1 PRs](https://github.com/Haehnchen/behat-placeholder-extension/pulls)MITPHPPHP &gt;=8.0CI passing

Since Mar 18Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Haehnchen/behat-placeholder-extension)[ Packagist](https://packagist.org/packages/espend/behat-placeholder-extension)[ RSS](/packages/espend-behat-placeholder-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (18)Used By (0)

Behat Placeholder Extension
===========================

[](#behat-placeholder-extension)

[![Build Status](https://camo.githubusercontent.com/d8b2f1b129aecd998fc23c34c6e8c018e6598dbca688d3a1fd1de3debb8fd07a/68747470733a2f2f7472617669732d63692e6f72672f486165686e6368656e2f62656861742d706c616365686f6c6465722d657874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Haehnchen/behat-placeholder-extension)[![Total Downloads](https://camo.githubusercontent.com/4386582e5577d7ff7038244dc7d392fbf93d1b3357bbadc627bd6ca37e537f2d/68747470733a2f2f706f7365722e707567782e6f72672f657370656e642f62656861742d706c616365686f6c6465722d657874656e73696f6e2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/espend/behat-placeholder-extension)[![Latest Stable Version](https://camo.githubusercontent.com/b2d7974b9212b508875d49bccb3ff9a4725d4d308689ffb62732d83d120266ef/68747470733a2f2f706f7365722e707567782e6f72672f657370656e642f62656861742d706c616365686f6c6465722d657874656e73696f6e2f762f737461626c652e706e67)](https://packagist.org/packages/espend/behat-placeholder-extension)[![Build Status](https://camo.githubusercontent.com/6fe7481aaba745e65900b27c3e3da39e21a9b604d21119a748136743b5daefa2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f486165686e6368656e2f62656861742d706c616365686f6c6465722d657874656e73696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Haehnchen/behat-placeholder-extension/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9ab5c9912d25d588714be0ff0b73d7f6e99d9d45230d37e1ebaaca380e8508da/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f486165686e6368656e2f62656861742d706c616365686f6c6465722d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Haehnchen/behat-placeholder-extension/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/d9b430b47b4ba1fbfc95e53f87a024a7a7e722f53f0663eea98d9de06d584ec2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f486165686e6368656e2f62656861742d706c616365686f6c6465722d657874656e73696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Haehnchen/behat-placeholder-extension/?branch=master)

Problem to solve
----------------

[](#problem-to-solve)

If you test your application with external service you run into problems of non unique user input. For example registering a user with same email will fail as there is already a user inside your database with this email address.

```
Scenario: Register a new user
    Given I fill in "email" with "foo@exmaple.com"
    And I fill in "password" with "my_scret"
    And I press "Register Now"
    Then I should see "foo@exmaple.com" in the ".account-user" element

Scenario: Register a new user
    Given set a random mail in "%email%" placeholder
    And set a random password in "%password%" placeholder
    And I fill in "email" with "%email%"
    And I fill in "password" with "%password%"
    And I press "Register Now"
    Then I should see "%email%" in the ".account-user" element
    Then I should see "Hello %email%" in the ".account-user" element

```

Also extracting an given value of newly generate user is possible.

```
Scenario: Register a new user and check id
    [...]
    When set placeholder "%user_id%" of "id" on Doctrine model "AppBundle:User" with "email" equals "%email%"
    Then print placeholder value of "%user_id%"
    Then I should see "%user_id%" in the ".account-user-id" element

```

All placeholder are compatible with foreign `Context` arguments.

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

[](#installation)

```
$ composer require espend/behat-placeholder-extension
```

```
# behat.yaml

default:
  suites:
    default:
      contexts:
        - espend\Behat\PlaceholderExtension\Context\PlaceholderContext

  extensions:
    espend\Behat\PlaceholderExtension\PlaceholderExtension: ~
```

### Feature Steps

[](#feature-steps)

All placeholder are valid per Scenario scope. They are cleaned before and after every Scenario.

```
Given set a placeholder "%foobar%" with value "my_foobar"
Given set a random mail in "%mail%" placeholder
Given set a random password in "%password%" placeholder
Given set a random text with length "15" in "%text%" placeholder
Given set current date as "Y-m-d" format in "%date%" placeholder
Given print placeholder value of "%date%"
Given print all placeholder values

```

#### Doctrine

[](#doctrine)

To interact with the underlying Database there also some Doctrine steps. They only work on a Test Suite / Extension using `Behat\Symfony2Extension`

```
Given set placeholder "%foobar%" of "id" on Doctrine model "AppBundle:Car" with "name" equals "bmw"
Given set placeholder "%foobar%" of "id" on Doctrine model "AppBundle\Entity\Car" with "name" equals "bmw"

```

```
# behat.yaml
default:
  suites:
    default:
      contexts:
        - espend\Behat\PlaceholderExtension\Context\DoctrinePlaceholderContext

  extensions:
    # [...]
    Behat\Symfony2Extension: ~
    Behat\MinkExtension:
      sessions:
        default:
          symfony2: ~
```

```
# composer.json
"behat/mink-extension": "*",
"behat/symfony2-extension": "*",

```

#### Placeholder Context Injection

[](#placeholder-context-injection)

If you want access to placeholders in you custom `Context` you implement the `espend\Behat\PlaceholderExtension\Context\PlaceholderBagAwareContextInterface` Interface See `PlaceholderContext` for a full working example

```
class PlaceholderContext implements Context, PlaceholderBagAwareContext {}

```

TODOs
-----

[](#todos)

- Pipe placeholder arguments for console command: `bin/behat --placeholder="%foobar%=foo"`
- More Doctrine related steps
- More Placeholder specific steps

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance84

Actively maintained with recent releases

Popularity37

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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 ~541 days

Recently: every ~811 days

Total

7

Last Release

96d ago

Major Versions

1.2.1 → 2.0.02026-02-11

PHP version history (2 changes)1.0PHP &gt;=7.0

2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1011712?v=4)[Daniel Espendiller](/maintainers/Haehnchen)[@Haehnchen](https://github.com/Haehnchen)

---

Top Contributors

[![Haehnchen](https://avatars.githubusercontent.com/u/1011712?v=4)](https://github.com/Haehnchen "Haehnchen (23 commits)")[![kayue](https://avatars.githubusercontent.com/u/193112?v=4)](https://github.com/kayue "kayue (1 commits)")

---

Tags

behatbehat-contextsbehat-extensiondoctrinephpsymfonysymfonyBDDContextBehatextension

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/espend-behat-placeholder-extension/health.svg)

```
[![Health](https://phpackages.com/badges/espend-behat-placeholder-extension/health.svg)](https://phpackages.com/packages/espend-behat-placeholder-extension)
```

###  Alternatives

[laracasts/behat-laravel-extension

Laravel extension for Behat

2611.3M12](/packages/laracasts-behat-laravel-extension)[dmarynicz/behat-parallel-extension

Parallel extension for Behat

27544.3k](/packages/dmarynicz-behat-parallel-extension)[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)[behat-extension/doctrine-data-fixtures-extension

Doctrine data fixtures extension for Behat

20546.2k1](/packages/behat-extension-doctrine-data-fixtures-extension)[vipsoft/doctrine-data-fixtures-extension

Doctrine data fixtures extension for Behat

21294.8k14](/packages/vipsoft-doctrine-data-fixtures-extension)

PHPackages © 2026

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