function KernelTestBase::setSetting

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::setSetting()
  2. 10 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::setSetting()
  3. 11.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::setSetting()

Sets an in-memory Settings variable.

Parameters

string $name: The name of the setting to set.

bool|string|int|array|null $value: The value to set. Note that array values are replaced entirely; use \Drupal\Core\Site\Settings::get() to perform custom merges.

22 calls to KernelTestBase::setSetting()
DateFormatterTest::setUp in core/tests/Drupal/KernelTests/Core/Datetime/DateFormatterTest.php
DirectoryTest::testFileCheckDirectoryHandling in core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
Tests directory handling functions.
DrupalKernelSiteTest::testServicesYml in core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelSiteTest.php
Tests services.yml in site directory.
DrupalKernelTest::getTestKernel in core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
Build a kernel for testings.
DrupalKernelTest::testClassLoaderAutoDetect in core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
Tests class_loader_auto_detect setting.

... See full list

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 937

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

protected function setSetting($name, $value) {
    $settings = Settings::getInstance() ? Settings::getAll() : [];
    $settings[$name] = $value;
    new Settings($settings);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.