PHPackages                             smarin/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. [Testing &amp; Quality](/categories/testing)
4. /
5. smarin/behat-placeholder-extension

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

smarin/behat-placeholder-extension
==================================

Behat placeholder extension

1.1.2(7y ago)013MITPHPPHP &gt;=7.0

Since Mar 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/sergeym/behat-placeholder-extension)[ Packagist](https://packagist.org/packages/smarin/behat-placeholder-extension)[ RSS](/packages/smarin-behat-placeholder-extension/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (12)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)[![SensioLabsInsight](https://camo.githubusercontent.com/ca7c5a4e4e71c089d97c0068b22d80de18c6187706fb35709529f5ccd6e79ad1/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f62623335363962392d396337632d343863652d393765612d3931613461646638376339632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/bb3569b9-9c7c-48ce-97ea-91a4adf87c9c)[![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)

```
$ php composer.phar 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

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~119 days

Total

5

Last Release

2863d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/345282be5b5745d49cc2265f4fb2bc0373dc9001856609c92028d61773948b4e?d=identicon)[Sergey Marin](/maintainers/Sergey%20Marin)

---

Top Contributors

[![Haehnchen](https://avatars.githubusercontent.com/u/1011712?v=4)](https://github.com/Haehnchen "Haehnchen (12 commits)")[![sergeym](https://avatars.githubusercontent.com/u/445293?v=4)](https://github.com/sergeym "sergeym (2 commits)")

---

Tags

symfonyBDDContextBehatextension

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/smarin-behat-placeholder-extension/health.svg)](https://phpackages.com/packages/smarin-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)[soyuka/contexts

Behatch contexts

282.1M11](/packages/soyuka-contexts)[zalas/behat-no-extension

The ultimate Behat extension

31137.9k1](/packages/zalas-behat-no-extension)

PHPackages © 2026

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