function ConfigEntityStorageTest::testCreate

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testCreate()
  2. 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testCreate()
  3. 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testCreate()

@covers ::create @covers ::doCreate

Return value

\Drupal\Core\Entity\EntityInterface

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 199

Class

ConfigEntityStorageTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21Entity%21ConfigEntityStorage.php/class/ConfigEntityStorage/9" title="Defines the storage class for configuration entities." class="local">\Drupal\Core\Config\Entity\ConfigEntityStorage</a> @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testCreate() {
    $this->cacheTagsInvalidator
        ->invalidateTags(Argument::cetera())
        ->shouldNotBeCalled();
    $entity = $this->getMockEntity();
    $entity->set('id', 'foo');
    $entity->set('langcode', 'hu');
    $entity->set('uuid', 'bar');
    $entity->setOriginalId('foo');
    $entity->enforceIsNew();
    $this->moduleHandler
        ->invokeAll('test_entity_type_create', [
        $entity,
    ])
        ->shouldBeCalled();
    $this->moduleHandler
        ->invokeAll('entity_create', [
        $entity,
        'test_entity_type',
    ])
        ->shouldBeCalled();
    $this->uuidService
        ->generate()
        ->willReturn('bar');
    $entity = $this->entityStorage
        ->create([
        'id' => 'foo',
    ]);
    $this->assertInstanceOf(EntityInterface::class, $entity);
    $this->assertSame('foo', $entity->id());
    $this->assertSame('bar', $entity->uuid());
    return $entity;
}

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