function EntityTypeManagerTest::testGetHandler

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php \Drupal\Tests\Core\Entity\EntityTypeManagerTest::testGetHandler()
  2. 10 core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php \Drupal\Tests\Core\Entity\EntityTypeManagerTest::testGetHandler()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php \Drupal\Tests\Core\Entity\EntityTypeManagerTest::testGetHandler()

Tests the getHandler() method.

@covers ::getHandler

File

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

Class

EntityTypeManagerTest
@coversDefaultClass \Drupal\Core\Entity\EntityTypeManager @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

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

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