0

I am trying to run the following behat step:

@Given I am logged in as a user with the :role role(s) and I have the following fields:

This is defined in DrupalContext.php on lines 68-106. I have a standard behat install from composer. When I run this, I get the following error:

--- FeatureContext has missing steps. Define them with these snippets:

/** * @Given I am logged in as a user with the :arg1 and I have the following fields: */ public function iAmLoggedInAsAUserWithTheAndIHaveTheFollowingFields($arg1, TableNode $table) { throw new PendingException(); }

I am still pretty new to OOPHP so when I read this I took it to mean that it couldn't find the original method. I added a use statement in my feature/bootstrap/FeatureContext.php:

use Drupal\DrupalExtension\Context\assertAuthenticatedByRole;

But I still get the same results. Here is my implementation of the behat scenario:

@api
Scenario: An administrator should not be able to create a page content
  Given I am logged in as a user with the 'administrator' and I have the 
  following fields:
    | field_user_username     | drupaltest  |
  • Sounds like your test class is missing the method your definition claims will be available: iAmLoggedInAsAUserWithTheAndIHaveTheFollowingFields() – Clive Apr 3 '17 at 11:31
  • Could it also be missing role(s) text after administrator? – Kevin Apr 3 '17 at 13:21
  • @Kevin ding ding ding. We have a winner. – powpow12 Apr 16 '17 at 12:30
  • Adding as answer. – Kevin Apr 16 '17 at 12:32
2

You have a typo in your Given condition - you need to have role(s) after administrator.

Given I am logged in as a user with the 'administrator' role(s) and I have the following fields:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.