function EntityTypeRepositoryTest::testGetEntityTypeFromClassAmbiguous

Tests get entity type from class ambiguous.

@legacy-covers ::getEntityTypeFromClass

File

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

Class

EntityTypeRepositoryTest
Tests Drupal\Core\Entity\EntityTypeRepository.

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetEntityTypeFromClassAmbiguous() : void {
  $jazz = $this->prophesize(EntityTypeInterface::class);
  $jazz->getOriginalClass()
    ->willReturn('\\Drupal\\apple\\Entity\\Apple');
  $jazz->id()
    ->willReturn('jazz');
  $gala = $this->prophesize(EntityTypeInterface::class);
  $gala->getOriginalClass()
    ->willReturn('\\Drupal\\apple\\Entity\\Apple');
  $gala->id()
    ->willReturn('gala');
  $this->setUpEntityTypeDefinitions([
    'jazz' => $jazz,
    '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.