public function EntityTypeBundleInfoTest::testGetAllBundleInfoWithEntityBundleInfo in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php \Drupal\Tests\Core\Entity\EntityTypeBundleInfoTest::testGetAllBundleInfoWithEntityBundleInfo()
@covers ::getAllBundleInfo
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeBundleInfoTest.php, line 272
Class
- EntityTypeBundleInfoTest
- @coversDefaultClass \Drupal\Core\Entity\EntityTypeBundleInfo @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testGetAllBundleInfoWithEntityBundleInfo() {
// Ensure that EntityTypeBundleInfo::getAllBundleInfo() does not add
// additional bundles if hook_entity_bundle_info() defines some and the
// entity_type does not define a bundle entity type.
$this->moduleHandler
->invokeAll('entity_bundle_info')
->willReturn([
'banana' => [
'fig' => [
'label' => 'Fig banana',
],
],
]);
$this->moduleHandler
->alter('entity_bundle_info', Argument::type('array'))
->willReturn(NULL);
$apple = $this
->prophesize(EntityTypeInterface::class);
$apple
->getLabel()
->willReturn('Apple');
$apple
->getBundleEntityType()
->willReturn(NULL);
$banana = $this
->prophesize(EntityTypeInterface::class);
$banana
->getLabel()
->willReturn('Banana');
$banana
->getBundleEntityType()
->willReturn(NULL);
$this
->setUpEntityTypeDefinitions([
'apple' => $apple,
'banana' => $banana,
]);
$expected = [
'banana' => [
'fig' => [
'label' => 'Fig banana',
],
],
'apple' => [
'apple' => [
'label' => 'Apple',
],
],
];
$bundle_info = $this->entityTypeBundleInfo
->getAllBundleInfo();
$this
->assertSame($expected, $bundle_info);
}