Problem

  1. Web tests have to use writeSettings() to ensure that settings are synchronized between the test runner and the child site.
  2. Unit tests do not have any Drupal environment to begin with.
  3. Only KernelTestBase tests are eligible to use settingsSet().
  4. But yet, settingsSet() is located on TestBase and thus available to all tests.

Proposed solution

  1. Move TestBase::settingsSet() into KernelTestBase.

Comments

sun’s picture

Status: Active » Needs review
StatusFileSize
new1.65 KB
sun’s picture

sun’s picture

Status: Needs review » Needs work

The last submitted patch, 1: test.settings.1.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new1.95 KB
new641 bytes

Whoopsie.

Status: Needs review » Needs work

The last submitted patch, 5: test.settings.5.patch, failed testing.

sun’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.96 KB
new2.11 KB

Moved settingsSet() into UnitTestBase.

Status: Needs review » Needs work

The last submitted patch, 7: test.settings.7.patch, failed testing.

jhedstrom’s picture

Title: settingsSet() is not limited to DrupalUnitTestBase » settingsSet() is not limited to KernelTestBase
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.54 KB

I've updated the issue summary to account for #2347999: DrupalUnitTestBase is deprecated, replace with KernelTestBase, and rerolled the patch.

jhedstrom’s picture

Status: Needs review » Needs work

The last submitted patch, 9: move-settingsset-2253067-09.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review
StatusFileSize
new2.04 KB
new3.57 KB

Status: Needs review » Needs work

The last submitted patch, 12: move-settingsset-2253067-12.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: move-settingsset-2253067-12.patch, failed testing.

dawehner’s picture

Issue tags: +Needs reroll
amitgoyal’s picture

Status: Needs work » Needs review
StatusFileSize
new3.57 KB

Reroll of #12.

amitgoyal’s picture

Issue tags: -Needs reroll

Status: Needs review » Needs work

The last submitted patch, 17: move-settingsset-2253067-17.patch, failed testing.

mgifford’s picture

Assigned: sun » Unassigned
mile23’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Needs work » Needs review

Applies cleanly to 8.1.x, but still has the same failing tests, due to the data structure for $settings, required by drupal_rewrite_settings().

mile23’s picture

Status: Needs review » Needs work

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mile23’s picture

Status: Needs work » Closed (won't fix)

Drupal\simpletest\KernelTestBase is now deprecated in favor of Drupal\KernelTests\KernelTestBase, so no one should be using TestBase::settingsSet().

We also have Drupal\KernelTests\KernelTestBase::setSettings(), which is marked protected.

So while access to settingsSet() is still not limited to Drupal\simpletest\KernelTestBase, it's deprecated and no one should be using it.