function EntityTypeRepositoryTest::testGetEntityTypeFromClassAmbiguousBundleClass

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Entity/EntityTypeRepositoryTest.php \Drupal\Tests\Core\Entity\EntityTypeRepositoryTest::testGetEntityTypeFromClassAmbiguousBundleClass()

@covers ::getEntityTypeFromClass

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetEntityTypeFromClassAmbiguousBundleClass() : void {
  $blackcurrant = $this->prophesize(EntityTypeInterface::class);
  $blackcurrant->getOriginalClass()
    ->willReturn(Apple::class);
  $blackcurrant->getClass()
    ->willReturn(Blackcurrant::class);
  $blackcurrant->id()
    ->willReturn('blackcurrant');
  $gala = $this->prophesize(EntityTypeInterface::class);
  $gala->getOriginalClass()
    ->willReturn(Apple::class);
  $gala->getClass()
    ->willReturn(RoyalGala::class);
  $gala->id()
    ->willReturn('gala');
  $this->setUpEntityTypeDefinitions([
    'blackcurrant' => $blackcurrant,
    'gala' => $gala,
  ]);
  $this->entityTypeBundleInfo
    ->getAllBundleInfo()
    ->willReturn([
    'gala' => [
      'royal_gala' => [
        'label' => 'Royal Gala',
        'class' => RoyalGala::class,
      ],
    ],
  ]);
  $this->assertSame('gala', $this->entityTypeRepository
    ->getEntityTypeFromClass(RoyalGala::class));
}

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