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  |
4
  • Sounds like your test class is missing the method your definition claims will be available: iAmLoggedInAsAUserWithTheAndIHaveTheFollowingFields()
    – Clive
    Commented Apr 3, 2017 at 11:31
  • Could it also be missing role(s) text after administrator?
    – Kevin
    Commented Apr 3, 2017 at 13:21
  • @Kevin ding ding ding. We have a winner.
    – powpow12
    Commented Apr 16, 2017 at 12:30
  • Adding as answer.
    – Kevin
    Commented Apr 16, 2017 at 12:32

1 Answer 1

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 and acknowledge you have read our privacy policy.

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