LionsAd / drupal_ti

Drupal - Travis Integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with DrupalExtension

Decipher opened this issue · comments

I've been playing with Drupal Ti for a few hours now, and have mostly got to where I want to be, however I am having one issue that I can't really seem to figure out.

My Behat tests using DrupalExtention seem to be able to communicate with the Drupal API. On my local tests it runs fine, but on Travis CI I'm not getting any luck.

Specifically, what I'm doing in Behat is running module_enable() in a @BeforeSuite hook to turn on a test module, but I'm getting the following error on Travis:

PHP Fatal error:  Call to undefined function module_enable() in /home/travis/build/Decipher/test/tests/behat/features/bootstrap/WysiwygFieldsFeatureContext.php on line 14

https://travis-ci.org/Decipher/test/jobs/73371096#L443

You can see my test repo (and it's excessive test commits) at https://github.com/decipher/test

Take into account that I have not used Behat until a few days ago, and Travis until a few hours ago, so no doubt it could be something clearly simple and stupid ;)

Maybe you need the drupal driver instead of the drush driver?

I don't think calling functions like module_enable() directly works - maybe only as a side effect.

What probably works though for this case is:

drush = $this->getDrush();
drush->drush('pm-enable', array('module_name'));

So, from what I can tell, Drupal is being bootstraped correctly in the Travis CI instance, where it is locally.

https://travis-ci.org/Decipher/test/jobs/73480577#L428 is the output of print_r($GLOBALS);, which is missing any evidence of a bootstraped Drupal install. Locally I get essentially the same results as I would running the command from within Drupal.

As such, at that particular point I can't run any native Drupal functions.

@Decipher I am not sure you are supposed to be when using the drush driver:

https://github.com/Decipher/test/blob/master/tests/behat/behat.yml.dist#L16-L21

is missing something as far as I can tell:

https://github.com/panopoly/panopoly/pull/2/files#diff-63f34abbeedb18244e565e4c2b7eb2bcR12

I used drupal_root as well.

And I think without that, it can't find the drupal_root.

Thanks, I think that was exactly what I needed. Appreciate the help.

I am happy to accept a PR for adding that to the default behat.yml.dist file in drupal_ti for the test modules.

And also happy to accept a patch testing that by e.g. enabling drupal_ti_test via behat.

Or lets say it like that:

We probably should write a test, so if you don't I will probably do so in the future, opening an issue for that now.

Opened: #32

Sounds good. I would have, but I had already turned in for the night. Timezones.