共识/behat-drupal-context

Behat Drupal Context

1.0.4 2023-08-23 19:40 UTC

This package is auto-updated.

Last update: 2024-08-27 18:19:58 UTC


README

扩展Drupal网站内容创建的支持。

查看:https://packagist.org.cn/packages/consensus/behat-drupal-context

pipeline status | Latest Release

安装和设置

composer require consensus/behat-drupal-context

behat.yml

default:
  suites:
    default:
      contexts:
        - Consensus\BehatDrupalContext\Context\DrupalTestContentContext
        - Consensus\BehatDrupalContext\Context\DrupalDemoContentContext
        - Drupal\DrupalExtension\Context\DrupalContext

DrupalTestContentContext

此包扩展了DrupalExtension Behat步骤定义,用于Drupal 8+网站中内容创建的多种变体

  1. 创建段落
Given a "part_1_paragraph" paragraph named "example_part_1_paragraph":
  | id                | 100         |
  | field_part_1_text | Lorem ipsum |
  1. .table.txt文件创建实体(用户、节点、段落)
Given users from "features/entities/users.table.txt"
Given "page" content from "features/entities/node-pages.table.txt"

其中.table.txt是一个如下所示的Markdown格式表格

| title              | status | created            | author  | body             |
| Example Basic Page | 1      | 2023-02-02 09:00am | user101 | This is the BODY |
  1. 以2种格式或从文件创建段落
Given a "simple_paragraph" paragraph named "example_paragraph_1":
  | field_paragraph_title | Paragraph Title |
  | field_paragraph_desc  | Paragraph Desc  |

Given "simple_paragraph" paragraphs:
  | paragraph_name    | field_simple_paragraph_title | field_simple_paragraph_desc |
  | example_paragraph | Title goes here              | Decription goes here        |

Given "simple_paragraph" paragraphs from "features/entities/paragraphs.table.txt"

其中.table.txt是一个如下所示的Markdown格式表格

| paragraph_name    | field_simple_paragraph_title | field_simple_paragraph_desc |
| example_paragraph | Title goes here              | Decription goes here        |

DrupalDemoContentContext

创建在场景完成后持久存在的实体(例如,用于演示内容)

  1. 持久存在的用户
Given persistent users:
  | uid | name          | pass | email               | roles          |
  | 101 | user101       | pwd  | user101@example.com |                |
  1. 持久存在的节点
Given persistent "page" content:
  | title              | status | created            | author  | body             |
  | Example Basic Page | 1      | 2023-02-02 09:00am | user101 | This is the BODY |

Given persistent "page" content from "features/entities/node-page.table.txt"
  1. 持久存在的段落
Given a "simple_paragraph" persistent paragraph named "example_paragraph_1":
  | field_paragraph_title | Paragraph Title |
  | field_paragraph_desc  | Paragraph Desc  |

Given persistent "simple_paragraph" paragraphs:
  | paragraph_name    | field_simple_paragraph_title | field_simple_paragraph_desc |
  | example_paragraph | Title goes here              | Decription goes here        |

Given persistent "simple_paragraph" paragraphs from "features/entities/paragraphs-simple.table.txt"