function EntityTypeManagerTest::testGetHandler

Tests the getHandler() method.

@legacy-covers ::getHandler

File

core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php, line 302

Class

EntityTypeManagerTest
Tests Drupal\Core\Entity\EntityTypeManager.

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetHandler() : void {
  $apple = $this->prophesize(EntityTypeInterface::class);
  $apple->getHandlerClass('storage')
    ->willReturn(StubEntityHandlerBase::class);
  $this->setUpEntityTypeDefinitions([
    'apple' => $apple,
  ]);
  $apple_controller = $this->entityTypeManager
    ->getHandler('apple', 'storage');
  $this->assertInstanceOf(StubEntityHandlerBase::class, $apple_controller);
  $this->assertInstanceOf(ModuleHandlerInterface::class, $apple_controller->moduleHandler);
  $this->assertInstanceOf(TranslationInterface::class, $apple_controller->stringTranslation);
}

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