function EntityTypeRepositoryTest::testGetEntityTypeLabels

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

Tests the getEntityTypeLabels() method.

@covers ::getEntityTypeLabels

File

core/tests/Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php, line 87

Class

EntityTypeRepositoryTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityTypeRepository.php/class/EntityTypeRepository/9" title="Provides helper methods for loading entity types." class="local">\Drupal\Core\Entity\EntityTypeRepository</a> @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetEntityTypeLabels() {
    $apple = $this->prophesize(EntityTypeInterface::class);
    $apple->getLabel()
        ->willReturn('Apple');
    $apple->getBundleOf()
        ->willReturn(NULL);
    $banana = $this->prophesize(EntityTypeInterface::class);
    $banana->getLabel()
        ->willReturn('Banana');
    $banana->getBundleOf()
        ->willReturn(NULL);
    $this->setUpEntityTypeDefinitions([
        'apple' => $apple,
        'banana' => $banana,
    ]);
    $expected = [
        'apple' => 'Apple',
        'banana' => 'Banana',
    ];
    $this->assertSame($expected, $this->entityTypeRepository
        ->getEntityTypeLabels());
}

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