From 8ec004ec1f4f7939cd764e6a036e5190b76d2a17 Mon Sep 17 00:00:00 2001 From: "tan.nguyen" Date: Wed, 17 Jan 2024 16:45:31 +0700 Subject: [PATCH] Add negative assertions for the TaxonomyTrait steps. --- tests/behat/features/taxonomy.feature | 86 +++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 5 deletions(-) diff --git a/tests/behat/features/taxonomy.feature b/tests/behat/features/taxonomy.feature index 47a61313..52d3f097 100644 --- a/tests/behat/features/taxonomy.feature +++ b/tests/behat/features/taxonomy.feature @@ -1,16 +1,14 @@ @d9 @d10 Feature: Check that TaxonomyTrait works for or D9 - Background: + @api + Scenario: Assert "Given vocabulary :vid with name :name exists" Given no "tags" terms: | T1 | And "tags" terms: | name | | T1 | - - @api - Scenario: Assert "Given vocabulary :vid with name :name exists" - Given I am logged in as a user with the "administrator" role + And I am logged in as a user with the "administrator" role And vocabulary tags with name "Tags" exists And taxonomy term "T1" from vocabulary "tags" exists When I visit "tags" vocabulary term "T1" @@ -19,3 +17,81 @@ Feature: Check that TaxonomyTrait works for or D9 When I edit "tags" vocabulary term "T1" Then I see the text "Edit term" And I see the text "T1" + + @trait:TaxonomyTrait + Scenario: Assert "Given vocabulary :vid with name :name exists" fail with an error + Given some behat configuration + And scenario steps: + """ + Given vocabulary "non_existing_topics" with name "Non Existing Topics" exists + """ + When I run "behat --no-colors" + Then it should fail with an error: + """ + "non_existing_topics" vocabulary does not exist + """ + + @trait:TaxonomyTrait + Scenario: Assert "Given vocabulary :vid with name :name exists" fail with an error + Given some behat configuration + And scenario steps: + """ + Given vocabulary "tags" with name "Tags Fake" exists + """ + When I run "behat --no-colors" + Then it should fail with an error: + """ + "tags" vocabulary name is not "Tags Fake" + """ + + @trait:TaxonomyTrait + Scenario: Assert "Given taxonomy term :name from vocabulary :vocabulary_id exists" fail with an error + Given some behat configuration + And scenario steps: + """ + Given taxonomy term "Tag Random 1" from vocabulary "tags" exists + """ + When I run "behat --no-colors" + Then it should fail with an error: + """ + Taxonomy term "Tag Random 1" from vocabulary "tags" does not exist + """ + + @trait:TaxonomyTrait + Scenario: Assert "Given taxonomy term :name from vocabulary :vocabulary_id exists" fail with an exception + Given some behat configuration + And scenario steps: + """ + Given taxonomy term "Tag Random 1" from vocabulary "tags_random" exists + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + "tags_random" vocabulary does not exist + """ + + @trait:TaxonomyTrait + Scenario: Assert "When I visit :vocabulary vocabulary term :name" fail with an exception + Given some behat configuration + And scenario steps: + """ + When I visit "tags" vocabulary term "Random Tag" + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + Unable to find tags term "Random Tag" + """ + + @trait:TaxonomyTrait + Scenario: Assert "When I edit :vocabulary vocabulary term :name" fail with an exception + Given some behat configuration + And scenario steps: + """ + When I edit "tags" vocabulary term "Random Tag" + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + Unable to find tags term "Random Tag" + """