function EntityTypeRepositoryTest::testGetEntityTypeFromClassAmbiguous

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php \Drupal\Tests\Core\Entity\EntityTypeRepositoryTest::testGetEntityTypeFromClassAmbiguous()
  2. 8.9.x 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 170

Class

EntityTypeRepositoryTest
@coversDefaultClass \Drupal\Core\Entity\EntityTypeRepository[[api-linebreak]] @group Entity

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.