function ContentEntityStorageBaseTest::testCreate

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Entity/ContentEntityStorageBaseTest.php \Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest::testCreate()
  2. 9 core/tests/Drupal/KernelTests/Core/Entity/ContentEntityStorageBaseTest.php \Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest::testCreate()
  3. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/ContentEntityStorageBaseTest.php \Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest::testCreate()

Tests create.

@legacy-covers ::create

Attributes

#[DataProvider('providerTestCreate')]

File

core/tests/Drupal/KernelTests/Core/Entity/ContentEntityStorageBaseTest.php, line 40

Class

ContentEntityStorageBaseTest
Tests Drupal\Core\Entity\ContentEntityStorageBase.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testCreate(string|array $bundle) : void {
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('entity_test');
  $entity = $storage->create([
    'type' => $bundle,
  ]);
  $this->assertEquals('test_bundle', $entity->bundle());
}

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