You are here

public function ConfigEntityStorageTest::testHasData in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStorageTest::testHasData()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php \Drupal\KernelTests\Core\Config\ConfigEntityStorageTest::testHasData()

Tests the hasData() method for config entity storage.

@covers \Drupal\Core\Config\Entity\ConfigEntityStorage::hasData

File

core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php, line 59

Class

ConfigEntityStorageTest
Tests sync and importing config entities with IDs and UUIDs that match existing config.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testHasData() {
  $storage = \Drupal::entityTypeManager()
    ->getStorage('config_test');
  $this
    ->assertFalse($storage
    ->hasData());

  // Add a test config entity and check again.
  $storage
    ->create([
    'id' => $this
      ->randomMachineName(),
  ])
    ->save();
  $this
    ->assertTrue($storage
    ->hasData());
}