diff --git a/.travis.yml b/.travis.yml index dd8a2e6..367e7e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -100,7 +100,6 @@ services: - redis-server before_install: - - composer self-update - composer global require "lionsad/drupal_ti:dev-master#396d11d200005eb68491d24170da0a98ae7f51b3" - drupal-ti before_install diff --git a/tests/src/Functional/WebTest.php b/tests/src/Functional/WebTest.php index d868e20..78e05a7 100644 --- a/tests/src/Functional/WebTest.php +++ b/tests/src/Functional/WebTest.php @@ -37,41 +37,52 @@ class WebTest extends BrowserTestBase { $settings = Settings::getAll(); $settings['cache'] = [ 'default' => 'cache.backend.redis', - 'bins' => [ - 'config' => 'cache.backend.chainedfast', - 'bootstrap' => 'cache.backend.chainedfast', - 'discovery' => 'cache.backend.chainedfast', + ]; + $settings['container_yamls'][] = drupal_get_path('module', 'redis') . '/example.services.yml'; + + $settings['bootstrap_container_definition'] = [ + 'parameters' => [], + 'services' => [ + 'redis.factory' => [ + 'class' => 'Drupal\redis\ClientFactory', + ], + 'cache.backend.redis' => [ + 'class' => 'Drupal\redis\Cache\CacheBackendFactory', + 'arguments' => ['@redis.factory', '@cache_tags_provider.container', '@serialization.phpserialize'], + ], + 'cache.container' => [ + 'class' => '\Drupal\redis\Cache\PhpRedis', + 'factory' => ['@cache.backend.redis', 'get'], + 'arguments' => ['container'], + ], + 'cache_tags_provider.container' => [ + 'class' => 'Drupal\redis\Cache\RedisCacheTagsChecksum', + 'arguments' => ['@redis.factory'], + ], + 'serialization.phpserialize' => [ + 'class' => 'Drupal\Component\Serialization\PhpSerialize', + ], ], ]; new Settings($settings); - // Write settings.php for HTTP requests. - $settings = []; - $settings['settings']['cache']['default'] = (object) array( - 'value' => 'cache.backend.redis', - 'required' => TRUE, - ); - $settings['settings']['cache']['bins'] = (object) array( - 'value' => [ - 'config' => 'cache.backend.chainedfast', - 'bootstrap' => 'cache.backend.chainedfast', - 'discovery' => 'cache.backend.chainedfast', - ], - 'required' => TRUE, - ); - - $this->writeSettings($settings); - // Write the containers_yaml update by hand, since writeSettings() doesn't - // support this syntax. + // support some of the definitions. $filename = $this->siteDirectory . '/settings.php'; chmod($filename, 0666); $contents = file_get_contents($filename); - $contents .= "\n\n" . '$settings[\'container_yamls\'][] = \'modules/redis/example.services.yml\';'; + + // Add the container_yaml and cache definition. + $contents .= "\n\n" . '$settings["container_yamls"][] = "' . drupal_get_path('module', 'redis') . '/example.services.yml";'; + $contents .= "\n\n" . '$settings["cache"] = ' . var_export($settings['cache'], TRUE) . ';'; + + // Add the classloader. + $contents .= "\n\n" . '$class_loader->addPsr4(\'Drupal\\\\redis\\\\\', \'' . drupal_get_path('module', 'redis') . '/src\');'; + + // Add the bootstrap container definition. + $contents .= "\n\n" . '$settings["bootstrap_container_definition"] = ' . var_export($settings['bootstrap_container_definition'], TRUE) . ';'; + file_put_contents($filename, $contents); - $settings = Settings::getAll(); - $settings['container_yamls'][] = 'modules/redis/example.services.yml'; - new Settings($settings); OpCodeCache::invalidate(DRUPAL_ROOT . '/' . $filename); // Reset the cache factory. @@ -82,6 +93,7 @@ class WebTest extends BrowserTestBase { db_drop_table('cache_default'); db_drop_table('cache_render'); db_drop_table('cache_config'); + db_drop_table('cache_container'); db_drop_table('cachetags'); db_drop_table('semaphore'); db_drop_table('flood'); @@ -158,6 +170,7 @@ class WebTest extends BrowserTestBase { $this->assertFalse(db_table_exists('cache_default')); $this->assertFalse(db_table_exists('cache_render')); $this->assertFalse(db_table_exists('cache_config')); + $this->assertFalse(db_table_exists('cache_container')); $this->assertFalse(db_table_exists('cachetags')); $this->assertFalse(db_table_exists('semaphore')); $this->assertFalse(db_table_exists('flood'));