jordigiros/minkfieldrandomizer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jordigiros/minkfieldrandomizer

Composer 安装命令:

composer require jordigiros/minkfieldrandomizer

包简介

Random field filling generator for Behat/Mink/Selenium form tests

README 文档

README

MinkFieldRandomizer is a random (with sense) information generator for filling form fields in Behat Mink tests. It brings the option to run your tests in a more realistic way changing the information you use to fill in the forms in every test you run.

CircleCI

Installing with Composer

composer require jordigiros/MinkFieldRandomizer

How to use

MinkFieldRandomizer includes a trait FieldRandomizerTrait that has some extra methods that will permit you to randomize your features involving forms.

You only need to add that trait to your main FeatureContext Behat Context as follows:

class FeatureContext extends MinkContext {

    use FieldRandomizerTrait;

}

This way you can use the new steps added by the trait directly in the gherkin feature.

Steps added by MinkFieldRandomizer

Documentation

Common methods

Generate and fill with new random values

  • When I fill in :field with a random mail
  • When I fill in :field with a random name
  • When I fill in :field with a random surname
  • When I fill in :field with a random phone
  • When I fill in :field with a random number
  • When I fill in :field with a random text
  • When I fill in :field with a random loremipsum

Fill in with previously generated random values

  • When I fill in :field with an existent mail
  • When I fill in :field with an existent name
  • When I fill in :field with an existent surname
  • When I fill in :field with an existent phone
  • When I fill in :field with an existent number
  • When I fill in :field with an existent text
  • When I fill in :field with an existent loremipsum

Note: If you didn't generate the random information previously (Generate and fill with new random information) they won't work.

Filling multiple fields with a TableNode object:

  • Fills in form fields with provided table.

Gherkin:

When I fill in fields with provided table:
| f_outbound_accommodation_name 			| {RandomName} 		|
| f_outbound_accommodation_phone_number 	| {RandomNumber} 	|
| f_outbound_accommodation_address_1 		| {RandomText(10)}	|

PHP:

$hotel = new TableNode ([  
    ['f_outbound_accommodation_name', '{RandomName}'],
    ['f_outbound_accommodation_phone_number', '{RandomNumber}'],
    ['f_outbound_accommodation_address_1', '{RandomText(10)}'],   
]);
$this->fillFilteredFields($hotel);

Checking that a field has an specific previous random generated information:

Gherkin:

Then the ":field" field should contains ":value" value

PHP:

$this->frtAssertFieldContainsValue('f_customer_first_name', 'name');

It will fail if field contains a value different than the one given.

Filling a field with a custom random value

Gherkin:

When I fill in :field with :value

PHP:

When I fill in "#text" with "{RandomText(100)}"

It brings the option to customize some properties of the random values.

Values and customization

Name Value Comment
Email {RandomEmail}
{RandomEmail(domain)}
RandomEmail accepts at most a parameter, the domain for the random email address - if none is given gmail.com is provided.
Name {RandomName} RandomName does not accept parameters
Surname {RandomSurname} RandomSurname does not accept parameters
Number {RandomNumber}
{RandomNumber(N,M)}
RandomNumber accepts at most two parameters, returns a random number between the two given or between 0 and 9 if no params given.
Phone {RandomPhone}
{RandomPhone(N)}
RandomPhone accepts at most a parameter, the number of numbers in the string. If no parameter is given, it will return a 15 digits number.
Text {RandomText}
{RandomText(N)}
RandomText accepts at most a parameter, the number of characters in the string.If no parameter is given, it will return a 15 chars string.
LoremIpsum {RandomLoremIpsum}
{RandomLoremIpsum(N)}
RandomLoremIpsum accepts at most a parameter, the number of paragraphs in the string. If no parameter is given, it will return a 2 paragraphs string.

Copyright

Copyright (c) 2016 Jordi Girós Guerrero. See LICENSE for details. Contributors: Jordi Bisbal, Alex Skrypnyk.

统计信息

  • 总下载量: 45.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-09-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固