function EntityTypeRepositoryTest::testGetEntityTypeLabels

Tests the getEntityTypeLabels() method.

@legacy-covers ::getEntityTypeLabels

File

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

Class

EntityTypeRepositoryTest
Tests Drupal\Core\Entity\EntityTypeRepository.

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetEntityTypeLabels() : void {
  $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.