Skip to content

Commit

Permalink
[#279] Updated ContentTrait.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Nov 6, 2024
1 parent 5209ee4 commit ce51b67
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 191 deletions.
9 changes: 9 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ A migration map of the step definitions available in v2 to v3.

| V2 | V3 |
|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **[`ContentTrait`](src/ContentTrait.php) ([example](tests/behat/features/content.feature))** | |
| `Given no :type content type` | `Given the content type :content_type does not exist` |
| `Given no ([a-zA-z0-9_-]+) content:$/` | `Given the following :content_type content does not exist:` |
| `When I visit :type :title` | `When I visit the :content_type content page with the title :title` |
| `When I edit :type :title` | `When I visit the :content_type content edit page with the title :title` |
| `When I delete :type :title` | `When I visit the :content_type content delete page with the title :title` |
| `When the moderation state of :type :title changes from :old_state to :new_state` | `When I change the moderation state of the :content_type content with the title :title to the :new_state` |
| `When I visit :type :title scheduled transitions` | `When I visit the scheduled transitions page of the :content_type content with the title :title` |
|   | |
| **[`DraggableviewsTrait`](src/DraggableviewsTrait.php) ([example](tests/behat/features/draggableviews.feature))** | |
| `Then I save draggable views :view_id view :views_display_id display :bundle items in the following order:` | `When I save the draggable views items of the view :view_id and the display :views_display_id for the :bundle content in the following order:` |
|   | |
Expand Down
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,66 +122,74 @@ For example, to skip `beforeScenario` hook from `JsTrait`, add
#### Delete content type

```gherkin
@Given no :type content type
@Given the content type :content_type does not exist
```
Example:
```gherkin
Given no "article" content type
Given the content type "article" does not exist
```

#### Remove content defined by provided properties

```gherkin
@Given /^no ([a-zA-z0-9_-]+) content:$/
@Given the following :content_type content does not exist:
```
Example:
```gherkin
Given no "article" content:
Given the following "article" content does not exist:
| title |
| Test article |
| Another test article |
```

#### Navigate to page with specified type and title
#### Visit a page of a type with a specified title

```gherkin
@When I visit :type :title
@When I visit the :content_type content page with the title :title
```
Example:
```gherkin
When I visit "article" "Test article"
When I visit the "article" content page with the title "Test article"
```

#### Navigate to edit page with specified type and title
#### Visit an edit page of a type with a specified title

```gherkin
@When I edit :type :title
@When I visit the :content_type content edit page with the title :title
```
Example:
```gherkin
When I edit "article" "Test article"
When I visit the "article" content edit page with the title "Test article"
```

#### Navigate to delete page with specified type and title
#### Visit a delete page of a type with a specified title

```gherkin
@When I delete :type :title
@When I visit the :content_type content delete page with the title :title
```
Example:
```gherkin
When I visit the "article" content delete page with the title "Test article"
```

#### Change moderation state of a content with specified title
#### Visit a scheduled transitions page of a type with a specified title

```gherkin
@When the moderation state of :type :title changes from :old_state to :new_state
@When I visit the :content_type content scheduled transitions page with the title :title
```
Example:
```gherkin
When the moderation state of "article" "Test article" changes from "draft" to "published"
When I visit the "article" content scheduled transitions page with the title "Test article"
```

#### Visit scheduled-transition page for node with title
#### Change moderation state of a content with the specified title

```gherkin
@When I visit :type :title scheduled transitions
@When I change the moderation state of the :content_type content with the title :title to the :new_state state
```
Example:
```gherkin
When I change the moderation state of the "article" content with the title "Test article" to the "published" state
```

### CookieTrait
Expand Down
12 changes: 8 additions & 4 deletions docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,21 @@ function print_report(array $info): void {
$method['description'] = is_string($method['description']) ? $method['description'] : '';
$method['example'] = is_string($method['example']) ? $method['example'] : '';

$step = $method['steps'][0];
$step = (string) $method['steps'][0];

if (str_starts_with((string) $step, '@When') && !str_contains((string) $method['steps'][0], 'I ')) {
if (str_starts_with($step, '@Given') && str_ends_with($step, ':') && !str_contains($step, 'following')) {
printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "following" in the step');
}

if (str_starts_with($step, '@When') && !str_contains($step, 'I ')) {
printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "I " in the step');
}

if (str_starts_with((string) $step, '@Then') && !str_contains((string) $method['steps'][0], 'should')) {
if (str_starts_with($step, '@Then') && !str_contains($step, 'should')) {
printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "should" in the step');
}

if (str_starts_with((string) $step, '@Then') && !str_contains((string) $method['steps'][0], 'the')) {
if (str_starts_with($step, '@Then') && !str_contains($step, 'the')) {
printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "the" in the step');
}

Expand Down
Loading

0 comments on commit ce51b67

Please sign in to comment.