0

A user provided a set of site caching configuration settings that cause some errors. For example:

$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache';
$settings['cache']['bins']['discovery'] = 'cache.backend.memcache';

On top of that, the memcache module states that users must include the following in their site configuration:

$settings['cache']['default'] = 'cache.backend.memcache';

I would like to extend some core Kernel tests to run with the memcache module configured the way the user described. I can easily enable the module by adding it to the $modules array in the MyTest class. What else do I need to add to ensure the “site configuration settings” are the way the user recommends. I was hoping I could add something to the MyTest::setUp() function to change the settings, or better yet, have a dataProvider to supply a variety of settings to the test function to test against. I thought there would be something obvious in the system.performance configuration item, but it looks like cache.default is a service. Do I need to redefine this service programmically? How do I do that? The memcache module does not automatically override the cache.default service in its services.yml file.

1 Answer 1

0

Take a look the Memcache module. The module has tests, and seems you need write

  protected function setUp() {
    $this->config = [
      'memcache' => [
        'servers' => ['127.0.0.2:12345' => 'default'],
        'bin' => ['default' => 'default'],
      ],
      'hash_salt' => $this->randomMachineName(),
    ];
    $settings = new Settings($this->config);
    $this->settings = new MemcacheSettings($settings);
  }
1
  • I wouldn’t trust anything seen in the module’s tests. They all throw exceptions because the Factory parameters are not correct. May 13, 2020 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.