function EntityControllerTest::testDeleteEditTitleCallbacks
Same name and namespace in other branches
- main core/tests/Drupal/Tests/Core/Entity/Controller/EntityControllerTest.php \Drupal\Tests\Core\Entity\Controller\EntityControllerTest::testDeleteEditTitleCallbacks()
Tests edit and delete title callbacks.
Attributes
#[TestWith([
'deleteTitle',
'example',
'Delete <em class="placeholder">example</em>',
])]
#[TestWith([
'deleteTitle',
NULL,
'Delete',
])]
#[TestWith([
'editTitle',
'example',
'Edit <em class="placeholder">example</em>',
])]
#[TestWith([
'editTitle',
NULL,
'Edit',
])]
Parameters
string $callback: The controller title callback name.
string|null $entity_label: The label of the entity being displayed by the controller.
string $expected_title: The expected title return value.
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Controller/ EntityControllerTest.php, line 33
Class
- EntityControllerTest
- Tests EntityController.
Namespace
Drupal\Tests\Core\Entity\ControllerCode
public function testDeleteEditTitleCallbacks(string $callback, ?string $entity_label, string $expected_title) : void {
$container = new ContainerBuilder();
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
$route_match = $this->createStub(RouteMatchInterface::class);
$entity = $this->createStub(EntityInterface::class);
$entity->method('label')
->willReturn($entity_label);
$controller = $this->createPartialMock(EntityController::class, [
'doGetEntity',
]);
$controller->expects($this->once())
->method('doGetEntity')
->willReturn($entity);
$this->assertEquals($expected_title, (string) $controller->{$callback}($route_match, $entity));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.