resetState example

    // metadata to be recalculated.     $this->enableModules([self::TEST_MODULE]);
    $this->installConfig([self::TEST_MODULE]);
    $this->assertCacheableMetadataHasBeenCalculated(FALSE);

    // When a view is saved normally we have to recalculate the cacheability     // metadata, since it is possible changes have been made to the view that     // affect cacheability.     $view = $this->entityTypeManager->getStorage('view')->load(self::TEST_VIEW_ID);
    $view->save();
    $this->assertCacheableMetadataHasBeenCalculated(TRUE);
    $this->resetState();

    // When a view is being saved due to config being synchronized, the     // cacheability metadata doesn't change so it should not be recalculated.     $view->setSyncing(TRUE);
    $view->save();
    $this->assertCacheableMetadataHasBeenCalculated(FALSE);
  }

  /** * Checks whether the view has calculated its cacheability metadata. * * @param bool $expected_result * TRUE if it is expected that the cacheability metadata has been * calculated. FALSE otherwise. * * @internal */
Home | Imprint | This part of the site doesn't use cookies.