function KeyValueEntityStorageTest::testLoadMultipleIds

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testLoadMultipleIds()
  2. 10 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testLoadMultipleIds()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testLoadMultipleIds()

@covers ::loadMultiple @covers ::postLoad @covers ::mapFromStorageRecords @covers ::doLoadMultiple

File

core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php, line 524

Class

KeyValueEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage @group Entity

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

public function testLoadMultipleIds() {
    $entity = $this->getMockEntity('Drupal\\Core\\Entity\\EntityBase', [
        [
            'id' => 'foo',
        ],
    ]);
    $this->entityType
        ->expects($this->once())
        ->method('getClass')
        ->willReturn(get_class($entity));
    $this->setUpKeyValueEntityStorage();
    $expected[] = $entity;
    $this->keyValueStore
        ->expects($this->once())
        ->method('getMultiple')
        ->with([
        'foo',
    ])
        ->willReturn([
        [
            'id' => 'foo',
        ],
    ]);
    $entities = $this->entityStorage
        ->loadMultiple([
        'foo',
    ]);
    foreach ($entities as $id => $entity) {
        $this->assertInstanceOf('Drupal\\Core\\Entity\\EntityInterface', $entity);
        $this->assertSame($id, $entity->id());
    }
}

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