function EntityTypeRepositoryTest::testGetEntityTypeFromClassNoMatch

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

@covers ::getEntityTypeFromClass

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetEntityTypeFromClassNoMatch() {
    $apple = $this->prophesize(EntityTypeInterface::class);
    $banana = $this->prophesize(EntityTypeInterface::class);
    $this->setUpEntityTypeDefinitions([
        'apple' => $apple,
        'banana' => $banana,
    ]);
    $apple->getOriginalClass()
        ->willReturn('\\Drupal\\apple\\Entity\\Apple');
    $banana->getOriginalClass()
        ->willReturn('\\Drupal\\banana\\Entity\\Banana');
    $this->expectException(NoCorrespondingEntityClassException::class);
    $this->expectExceptionMessage('The \\Drupal\\pear\\Entity\\Pear class does not correspond to an entity type.');
    $this->entityTypeRepository
        ->getEntityTypeFromClass('\\Drupal\\pear\\Entity\\Pear');
}

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