plozmun/behat-faker-extension

Behat Faker Extension

Installs: 2 397

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:behat-extension

0.2.3 2022-01-24 18:37 UTC

This package is auto-updated.

Last update: 2024-04-29 04:48:09 UTC


README

Faker PHP integration with Behat Gherkin language

Instalation

  1. Require this extension using Composer:
composer require --dev plozmun/behat-faker-extension
  1. Enable it within your Behat configuration:
# behat.yaml.dist / behat.yaml

default:
    extensions:
        Plozmun\FakerExtension:
            locale: 'es_es' # Optional to enable locale functions

Usage

Add your PHP Faker function between braces:

Ej: {{firsName}} or complex functions {{dateTimeBetween('-5 years', '-1 years').format('Y-m-d')}}

Faker PHP Documentation

Feature: Create a Book
  In order to create a new book
  As a admin user
  I need to be able to create a book

  Scenario: Send post to create a new book
    When I add "Content-Type" header equal to "application/json"
    When I send a "POST" request to "/api/v1/book/{{ean13}}" with body:
    """
    {
      "author": {
          "firsName": "{{firstName}}",
          "lastName": "{{lastName}}"
      },
      "title": "{{sentence}}",
      "createdAt": "{{dateTimeInInterval('-5 years', '-1 years').format('Y-m-d')}}
    }
    """
    And the response status code should be 200

  Scenario: Show published books
    Given the following products exist:
      | ean     | title         |
      | {{ean}} | {{sentence}}  |
      | {{ean}} | {{sentence}}  |
    When I go to "/admin/books"

Contributors

Pablo Lozano - plozmun [lead developer]