consensus/behat-drupal-context

Behat Drupal Context

1.0.4 2023-08-23 19:40 UTC

This package is auto-updated.

Last update: 2024-11-27 18:50:08 UTC


README

Extended support for creating content in a Drupal site.

See: https://packagist.org/packages/consensus/behat-drupal-context

pipeline status | Latest Release

Installation and setup

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

This package extends the DrupalExtension Behat step definitions for a number of variations of content creation in a Drupal 8+ site:

  1. Create Paragraphs
Given a "part_1_paragraph" paragraph named "example_part_1_paragraph":
  | id                | 100         |
  | field_part_1_text | Lorem ipsum |
  1. Create entities (users, nodes, paragraphs) from a .table.txt file:
Given users from "features/entities/users.table.txt"
Given "page" content from "features/entities/node-pages.table.txt"

Where .table.txt is a markdown-formatted table like this:

| title              | status | created            | author  | body             |
| Example Basic Page | 1      | 2023-02-02 09:00am | user101 | This is the BODY |
  1. Create paragraphs in 2 formats, or from a file:
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"

Where .table.txt is a markdown-formatted table like this:

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

DrupalDemoContentContext

Create entities (users, nodes, paragraphs) that persist after the Scenario completes (eg. for demo content).

  1. Users that persist:
Given persistent users:
  | uid | name          | pass | email               | roles          |
  | 101 | user101       | pwd  | user101@example.com |                |
  1. Nodes that persist:
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. Paragraphs that persist:
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"