You are here

public function WebformEntityStorageTest::testWebformEntityStorage in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Functional/WebformEntityStorageTest.php \Drupal\Tests\webform\Functional\WebformEntityStorageTest::testWebformEntityStorage()

Test webform storage.

File

tests/src/Functional/WebformEntityStorageTest.php, line 15

Class

WebformEntityStorageTest
Tests for webform storage tests.

Namespace

Drupal\Tests\webform\Functional

Code

public function testWebformEntityStorage() {

  // Check webform entity storage caching.
  // @see \Drupal\webform\WebformEntityStorage::load

  /** @var \Drupal\webform\WebformEntityStorage $storage */
  $storage = \Drupal::entityTypeManager()
    ->getStorage('webform');
  $webform = $storage
    ->load('contact');
  $webform->cached = TRUE;

  // Check that load (single) has the custom 'cached' property.
  $this
    ->assertEqual($webform->cached, $storage
    ->load('contact')->cached);

  // Check that loadMultiple does not have the custom 'cached' property.
  // The below test will fail when and if
  // 'Issue #1885830: Enable static caching for config entities.'
  // is resolved.
  $this
    ->assertFalse(isset($storage
    ->loadMultiple([
    'contact',
  ])->cached));
}