2017 © Pedro Peláez
 

library behat-placeholder-extension

Behat placeholder extension

image

smarin/behat-placeholder-extension

Behat placeholder extension

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

Behat Placeholder Extension

Build Status Total Downloads Latest Stable Version SensioLabsInsight Build Status Scrutinizer Code Quality Code Coverage, (*1)

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., (*2)

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., (*3)

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., (*4)

Installation

``` bash $ php composer.phar require espend/behat-placeholder-extension, (*5)


```yaml # behat.yaml default: suites: default: contexts: - espend\Behat\PlaceholderExtension\Context\PlaceholderContext extensions: espend\Behat\PlaceholderExtension\PlaceholderExtension: ~

Feature Steps

All placeholder are valid per Scenario scope. They are cleaned before and after every Scenario., (*6)

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

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

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

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, (*8)

class PlaceholderContext implements Context, PlaceholderBagAwareContext {}

TODOs

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

The Versions

10/07 2018

dev-master

9999999-dev

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

10/07 2018

1.1.2

1.1.2.0

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

01/12 2017

dev-gherkin-table-node

dev-gherkin-table-node

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

30/08 2017

1.1

1.1.0.0

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

30/08 2017

dev-feature/placeholder-string-replace

dev-feature/placeholder-string-replace

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

24/03 2017

1.0.2

1.0.2.0

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

19/03 2017

1.0.1

1.0.1.0

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

19/03 2017

1.0

1.0.0.0

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

18/03 2017

dev-feature/sensiolabs-insight

dev-feature/sensiolabs-insight

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

18/03 2017

dev-feature/scrutinizer-code-coverage

dev-feature/scrutinizer-code-coverage

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

18/03 2017

dev-feature/placeholder-bag-inject

dev-feature/placeholder-bag-inject

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context

18/03 2017

dev-feature/init

dev-feature/init

Behat placeholder extension

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension symfony behat context