comparison core/tests/Drupal/KernelTests/KernelTestBase.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 1fec387a4317
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
18 use Drupal\Core\Site\Settings; 18 use Drupal\Core\Site\Settings;
19 use Drupal\Core\Test\TestDatabase; 19 use Drupal\Core\Test\TestDatabase;
20 use Drupal\simpletest\AssertContentTrait; 20 use Drupal\simpletest\AssertContentTrait;
21 use Drupal\Tests\AssertHelperTrait; 21 use Drupal\Tests\AssertHelperTrait;
22 use Drupal\Tests\ConfigTestTrait; 22 use Drupal\Tests\ConfigTestTrait;
23 use Drupal\Tests\PhpunitCompatibilityTrait;
23 use Drupal\Tests\RandomGeneratorTrait; 24 use Drupal\Tests\RandomGeneratorTrait;
24 use Drupal\Tests\TestRequirementsTrait; 25 use Drupal\Tests\TestRequirementsTrait;
25 use Drupal\simpletest\TestServiceProvider; 26 use Drupal\simpletest\TestServiceProvider;
26 use PHPUnit\Framework\TestCase; 27 use PHPUnit\Framework\TestCase;
27 use Symfony\Component\DependencyInjection\Reference; 28 use Symfony\Component\DependencyInjection\Reference;
74 use AssertContentTrait; 75 use AssertContentTrait;
75 use AssertHelperTrait; 76 use AssertHelperTrait;
76 use RandomGeneratorTrait; 77 use RandomGeneratorTrait;
77 use ConfigTestTrait; 78 use ConfigTestTrait;
78 use TestRequirementsTrait; 79 use TestRequirementsTrait;
80 use PhpunitCompatibilityTrait;
79 81
80 /** 82 /**
81 * {@inheritdoc} 83 * {@inheritdoc}
82 * 84 *
83 * Back up and restore any global variables that may be changed by tests. 85 * Back up and restore any global variables that may be changed by tests.
322 * Bootstraps a kernel for a test. 324 * Bootstraps a kernel for a test.
323 */ 325 */
324 private function bootKernel() { 326 private function bootKernel() {
325 $this->setSetting('container_yamls', []); 327 $this->setSetting('container_yamls', []);
326 // Allow for test-specific overrides. 328 // Allow for test-specific overrides.
327 $settings_services_file = $this->root . '/sites/default' . '/testing.services.yml'; 329 $settings_services_file = $this->root . '/sites/default/testing.services.yml';
328 if (file_exists($settings_services_file)) { 330 if (file_exists($settings_services_file)) {
329 // Copy the testing-specific service overrides in place. 331 // Copy the testing-specific service overrides in place.
330 $testing_services_file = $this->root . '/' . $this->siteDirectory . '/services.yml'; 332 $testing_services_file = $this->siteDirectory . '/services.yml';
331 copy($settings_services_file, $testing_services_file); 333 copy($settings_services_file, $testing_services_file);
332 $this->setSetting('container_yamls', [$testing_services_file]); 334 $this->setSetting('container_yamls', [$testing_services_file]);
333 } 335 }
334 336
335 // Allow for global test environment overrides. 337 // Allow for global test environment overrides.
825 $active_storage = $this->container->get('config.storage'); 827 $active_storage = $this->container->get('config.storage');
826 $extension_config = $active_storage->read('core.extension'); 828 $extension_config = $active_storage->read('core.extension');
827 829
828 foreach ($modules as $module) { 830 foreach ($modules as $module) {
829 if ($module_handler->moduleExists($module)) { 831 if ($module_handler->moduleExists($module)) {
830 throw new \LogicException("$module module is already enabled."); 832 continue;
831 } 833 }
832 $module_handler->addModule($module, $module_list[$module]->getPath()); 834 $module_handler->addModule($module, $module_list[$module]->getPath());
833 // Maintain the list of enabled modules in configuration. 835 // Maintain the list of enabled modules in configuration.
834 $extension_config['module'][$module] = 0; 836 $extension_config['module'][$module] = 0;
835 } 837 }