Problem

I've a module created via Features that export, a text format, a user role and the permission for user with this role to use this format. I've also a SimpleTest test case to validate other behavior of the module. When running this simple test case using Drush test-run command, I get an Undefined index error message for each test method in my test case class:
Test user_permission_features_export_render() failed: Undefined index: use text format machine_name

The (edited) stack trace of the error is

#1  call_user_func_array(user_permission_features_export_render, Array ([2] => MODULE,[3] => Array ([0] => use text format machine_name),[4] => ,[5] => user_permission)) called at [.../sites/all/modules/contrib/features/features.module:435]
#2  features_invoke(user_permission, features_export_render, MODULE, Array ([0] => use text format machine_name)) called at [.../sites/all/modules/contrib/features/features.export.inc:585]
#3  features_get_normal(user_permission, MODULE, 1) called at [.../sites/all/modules/contrib/features/features.export.inc:517]
#4  features_get_signature(normal, MODULE, user_permission, 1) called at [.../sites/all/modules/contrib/features/features.export.inc:729]
#5  features_get_component_states(Array (), 1, 1) called at [.../sites/all/modules/contrib/features/features.module:775]
#6  _features_restore(rebuild, Array ()) called at [.../sites/all/modules/contrib/features/features.module:813]
#7  features_rebuild() called at [.../sites/all/modules/contrib/features/features.module:216]
#8  features_flush_caches()
#9  call_user_func_array(features_flush_caches, Array ()) called at [.../includes/module.inc:819]
#10 module_invoke_all(flush_caches) called at [.../includes/common.inc:7149]
#11 drupal_flush_all_caches() called at [.../modules/simpletest/drupal_web_test_case.php:1417]
#12 DrupalWebTestCase->resetAll() called at [.../modules/simpletest/drupal_web_test_case.php:1336]
#13 DrupalWebTestCase->setUp(Array ([0] => MODULE)) called at [.../sites/all/modules/custom/MODULE/test/MODULE.test:8]
#14 PweTestCase->setUp() called at [.../modules/simpletest/drupal_web_test_case.php:476]
#15 DrupalTestCase->run() called at [/opt/drush/commands/core/test.drush.inc:129]
#16 simpletest_drush_run_test(MODULETestCase) called at [/opt/drush/commands/core/test.drush.inc:91]
#17 drush_test_run(MODULETestCase)
#18 call_user_func_array(drush_test_run, Array ([0] => MODULETestCase)) called at [/opt/drush/includes/command.inc:134]
#19 _drush_invoke_args(test-run, Array ([0] => MODULETestCase), test) called at [/opt/drush/includes/command.inc:806]
#20 drush_command(MODULETestCase)
#21 call_user_func_array(drush_command, Array ([0] => MODULETestCase)) called at [/opt/drush/includes/command.inc:214]
#22 drush_dispatch([...]) called at [/opt/drush/drush.php:101]
#23 drush_main() called at [/opt/drush/drush.php:41]
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pbuyle’s picture

The attached patch is a workaround the issue. It uses isset($perm_modules[$perm_name]) the avoid the undefined index error. This avoid breaking test cases when running from Drush. But I'm not sure this is the right way to address the issue.

mpotter’s picture

Status: Active » Fixed

This is actually related to a similar patch #1063204: Adding a new permission causes integrity constraint violation I just committed, but I also get this error sometimes when installing a profile, so I'm going to commit this also: 0fa80c4

hefox’s picture

Hm, and core doesn't mind a missing 'module' key?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

stacktrace