plozmun/behat-faker-extension

Behat Faker 扩展

安装数2,725

依赖项: 0

建议者: 0

安全性: 0

星标: 1

关注者: 1

分支: 0

公开问题: 0

类型:behat-extension

0.2.3 2022-01-24 18:37 UTC

This package is auto-updated.

Last update: 2024-09-29 06:08:43 UTC


README

Faker PHP 与 Behat Gherkin 语言的集成

安装

  1. 使用 Composer 安装此扩展
composer require --dev plozmun/behat-faker-extension
  1. 在 Behat 配置中启用它
# behat.yaml.dist / behat.yaml

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

用法

在括号中添加您的 PHP Faker 函数

例如:{{firstName}} 或复杂函数 {{dateTimeBetween('-5 years', '-1 years').format('Y-m-d')}}

Faker PHP 文档

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"

贡献者

Pablo Lozano - plozmun [主要开发者]