You are here

protected function ResourceTestBase::refreshTestStateAfterRestConfigChange in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::refreshTestStateAfterRestConfigChange()
  2. 9 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::refreshTestStateAfterRestConfigChange()

Refreshes the state of the tester to be in sync with the testee.

Should be called after every change made to:

  • RestResourceConfig entities
2 calls to ResourceTestBase::refreshTestStateAfterRestConfigChange()
EntityResourceTestBase::testGet in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a GET request for an entity, plus edge cases to ensure good DX.
MediaResourceTestBase::uploadFile in core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php
This duplicates some of the 'file_upload' REST resource plugin test coverage, to be able to test it on a concrete use case.

File

core/modules/rest/tests/src/Functional/ResourceTestBase.php, line 169

Class

ResourceTestBase
Subclass this for every REST resource, every format and every auth provider.

Namespace

Drupal\Tests\rest\Functional

Code

protected function refreshTestStateAfterRestConfigChange() {

  // Ensure that the cache tags invalidator has its internal values reset.
  // Otherwise the http_response cache tag invalidation won't work.
  $this
    ->refreshVariables();

  // Tests using this base class may trigger route rebuilds due to changes to
  // RestResourceConfig entities. Ensure the test generates routes using an
  // up-to-date router.
  \Drupal::service('router.builder')
    ->rebuildIfNeeded();
}