Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
First, what I tried to do is to add profile2 informations to a user created with the step:
Given users
Here my step definition:
/**
* @Given /^profiles:$/
*/
public function createProfiles(TableNode $profilesTable) {
foreach ($profilesTable->getHash() as $profileHash) {
$profileHash['user'] = $this->users[$profileHash['drupal_username']];
$profile = profile2_create($profileHash);
profile2_save($profile);
}
}
Problem is, I couldn't manage to find how to to call the profile2_create method, it is not found. I searched how and where the Drupal bootstrap is loaded, but no success so far.
Anybody can help me to achieve this?
Comments
Comment #1
jhedstromHmm, since
profile2_create()
is in theprofile2.module
file, it should always be available once Drupal is bootstrapped. Can you post a stack trace for the fatal error?Comment #2
b2f CreditAttribution: b2f commentedBefore I do that, can you confirm that Drupal is bootstrapped when a subcontext class of the form *behat.inc is constructed ? Because when I place a debugging string in drush driver's bootstrap function, it is not showing before the error stack trace (@api tag is set on the Feature).
---
Comment #3
b2f CreditAttribution: b2f commentedI went further in my investigations, it seems that the Drupal bootstrap only occurs when getDriver() is called inside the DrupalContext class. It doesn't seem to be possible to bootstrap from a module.behat.inc context as is. Am I correct or am I missing something ?
Comment #4
b2f CreditAttribution: b2f commentedThe answer to this may be getMainContext. I am going to try that.
Comment #5
b2f CreditAttribution: b2f commentedEDIT: a quick note to explain how I fixed it, I added drupal_root in behat.yml next to the drupal driver section. Drush driver alone was unable to bootstrap, but by adding drupal driver support in beyat.yml, Drupal Extension managed to bootstrap even without explicitly adding @drupal to the scenario.
Comment #5.0
b2f CreditAttribution: b2f commentedformat