You are here

public function EntityTypeRepositoryTest::testGetEntityTypeLabels in Drupal 8

Same name and namespace in other branches
  1. 9 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 88

Class

EntityTypeRepositoryTest
@coversDefaultClass \Drupal\Core\Entity\EntityTypeRepository @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());
}