function EntityTypeBundleInfoTest::testGetBundleLabels
Same name and namespace in other branches
- main core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php \Drupal\Tests\Core\Entity\EntityTypeBundleInfoTest::testGetBundleLabels()
Tests the getBundleLabels() method.
Attributes
#[DataProvider('providerTestGetBundleLabels')]
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeBundleInfoTest.php, line 325
Class
Namespace
Drupal\Tests\Core\EntityCode
public function testGetBundleLabels(string $entity_type_id, array $expected) : void {
$this->moduleHandler
->invokeAll('entity_bundle_info')
->willReturn([]);
$this->moduleHandler
->alter('entity_bundle_info', Argument::type('array'))
->willReturn(NULL);
$apple = $this->prophesize(EntityTypeInterface::class);
$apple->getLabel()
->willReturn('Apple');
$apple->getBundleEntityType()
->willReturn(NULL);
$apple->get('entity_type_bundle_info')
->willReturn(NULL);
$banana = $this->prophesize(EntityTypeInterface::class);
$banana->getLabel()
->willReturn('Banana');
$banana->getBundleEntityType()
->willReturn(NULL);
$banana->get('entity_type_bundle_info')
->willReturn(NULL);
$this->setUpEntityTypeDefinitions([
'apple' => $apple,
'banana' => $banana,
]);
$this->assertSame($expected, $this->entityTypeBundleInfo
->getBundleLabels($entity_type_id));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.