function EntityTypeManagerTest::testHasHandler

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

Tests the hasHandler() method.

@covers ::hasHandler

@dataProvider providerTestHasHandler

File

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

Class

EntityTypeManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityTypeManager.php/class/EntityTypeManager/11.x" title="Manages entity type plugin definitions." class="local">\Drupal\Core\Entity\EntityTypeManager</a> @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testHasHandler($entity_type_id, $expected) : void {
    $apple = $this->prophesize(EntityTypeInterface::class);
    $apple->hasHandlerClass('storage')
        ->willReturn(TRUE);
    $banana = $this->prophesize(EntityTypeInterface::class);
    $banana->hasHandlerClass('storage')
        ->willReturn(FALSE);
    $this->setUpEntityTypeDefinitions([
        'apple' => $apple,
        'banana' => $banana,
    ]);
    $entity_type = $this->entityTypeManager
        ->hasHandler($entity_type_id, 'storage');
    $this->assertSame($expected, $entity_type);
}

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