function ConfigEntityStorageTest::testHasData

Same name 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()
  3. 11.x 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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.