function EntityTypeRepositoryTest::testGetEntityTypeFromClassAmbiguous

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

@covers ::getEntityTypeFromClass

File

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

Class

EntityTypeRepositoryTest
@coversDefaultClass \Drupal\Core\Entity\EntityTypeRepository @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetEntityTypeFromClassAmbiguous() {
    $boskoop = $this->prophesize(EntityTypeInterface::class);
    $boskoop->getOriginalClass()
        ->willReturn('\\Drupal\\apple\\Entity\\Apple');
    $boskoop->id()
        ->willReturn('boskop');
    $gala = $this->prophesize(EntityTypeInterface::class);
    $gala->getOriginalClass()
        ->willReturn('\\Drupal\\apple\\Entity\\Apple');
    $gala->id()
        ->willReturn('gala');
    $this->setUpEntityTypeDefinitions([
        'boskoop' => $boskoop,
        'gala' => $gala,
    ]);
    $this->expectException(AmbiguousEntityClassException::class);
    $this->expectExceptionMessage('Multiple entity types found for \\Drupal\\apple\\Entity\\Apple.');
    $this->entityTypeRepository
        ->getEntityTypeFromClass('\\Drupal\\apple\\Entity\\Apple');
}

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