I'm using the Behat Drupal Extension. When I try to run a behat test on a sandbox server, I see the following. I see that a temporary admin user is being create but it can't seem to log in. How might I remedy this so that behat can login?

$ behat

Feature: First   Playing with features and exploring

  @api   Scenario: Run cron                                           
# features/first.feature:6
    Given I am logged in as a user with the "administrator" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
      Failed to log in as user 'ss5vWjZY' with role 'administrator' (Exception)
    When I run cron                                              # Drupal\DrupalExtension\Context\DrupalContext::assertCron()
    And am on "admin/reports/dblog"                              # Drupal\DrupalExtension\Context\MinkContext::visit()
    Then I should see the link "Cron run completed"              # Drupal\DrupalExtension\Context\MinkContext::assertLinkVisible()

I've changed my LDAP configuration back to mixed mode:

enter image description here

And only admins are allowed to create a new account

enter image description here


I had this issue as well. It turned out to be a problem with LDAP. Switching to Mixed Mode allow the DrupalExtension to function properly. Since we don't want mixed by default, I added a pre-test setup function

public static function prepare($scope)
        $data = array(
          'sids' => array (
            'directory' => 'directory',
          'authenticationMode' => 1,
          'loginConflictResolve' => 2,
          'acctCreation' => 4,
          'loginUIUsernameTxt' => NULL,
          'loginUIPasswordTxt' => NULL,
          'ldapUserHelpLinkUrl' => NULL,
          'ldapUserHelpLinkText' => 'Logon Help',
          'emailOption' => 3,
          'emailUpdate' => 1,
          'allowOnlyIfTextInDn' => array (),
          'excludeIfTextInDn' => array (),
          'allowTestPhp' => '',
          'excludeIfNoAuthorizations' => NULL,
          'ssoRemoteUserStripDomainName' => NULL,
          'seamlessLogin' => NULL,
          'ldapImplementation' => NULL,
          'cookieExpire' => NULL,

        variable_set('ldap_authentication_conf', $data);

The key is the line 'authenticationMode' => 1,

| improve this answer | |
  • To clarify, this would be added as a method to the FeatureContext class? – Rick Jul 20 '15 at 16:08
  • OUTCOME: I added this function as a method to FeatureContext and it worked like a charm! Marking correct answer. – Rick Jul 20 '15 at 16:11
  • Why not do like $mixed_authentication_mode = 1; and then set 'authenticationMode' => $mixed_authentication_mode, ... it seems by renaming the variables, and probably the function name prepare() you could make the code be more self explanitory, and rely less on magic numbers and conventions .... just saying. – tenken Jul 21 '15 at 16:13
  • That data array/naming is from the Drupal LDAP conf variable. I like keeping the definition the same so that it is easy to diff what I see in drush to my behat config. – fullerja Jul 21 '15 at 19:27
  • I threw in a bounty after the fact to say thanks. You really helped me through a big hurdle. – Rick Jul 22 '15 at 15:34

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.