0

Adding some tests to an older Drupal 7 site and a few of the tests check for the presence or lack thereof of custom cache items.

Having this in settings.php seems to interfere with Simpletest using default database cache (this is included to settings.php as a local settings override):

  $conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
  $conf['lock_inc'] = 'sites/all/modules/contrib/memcache/memcache-lock.inc';
  $conf['memcache_stampede_protection'] = TRUE;
  $conf['cache_default_class'] = 'MemCacheDrupal';

  // The 'cache_form' bin must be assigned no non-volatile storage.
  $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

  // Don't bootstrap the database when serving pages from the cache.
  $conf['page_cache_without_database'] = TRUE;
  $conf['page_cache_invoke_hooks'] = FALSE;

  $conf['memcache_servers'] = array('cache:11211' => 'default');

Is there any global flag I can look at at this point to determine whether or not to add these overrides in?

I tried checking the $GLOBALS for a test id and drupal_valid_test_ua but in both cases the memcache information was still used.

If I comment out the memcache settings, I can see the cache tables in simpletest are populated as expected. How can I get around this?

edit: looks like testing specific settings.php is not possible in 7.

  • Could you test on a custom (sub)domain? Then you can load a different settings.php just for testing. Not ideal, but testing with a different caching mechanism is not ideal either. Alternatively you could turn off memcache as part of the setup for the specific tests. Not sure of the details but I'm sure it could be done. – Alfred Armstrong Oct 10 '18 at 8:51
0

I wound up creating a new site in Lando and a new site folder just for simpletest. I created a site directory for my main site and moved settings.php into that, and installed a minimal Drupal site to the other.

This resolved my issue, since the site/db specifically for SUT does not use memcache.

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.