'administer nodes',
'bypass node access',
'administer views',
]);
$this->
drupalLogin($admin_user);
$this->
drupalGet('test-entity-operations'
);
/** @var \Drupal\entity_test\Entity\EntityTest $entity */
foreach ($entities as $entity) { /** @var \Drupal\Core\Language\LanguageInterface $language */
foreach ($entity->
getTranslationLanguages() as $language) { $entity =
$entity->
getTranslation($language->
getId());
$operations = \Drupal::
service('entity_type.manager'
)->
getListBuilder('node'
)->
getOperations($entity);
$this->
assertNotEmpty($operations);
foreach ($operations as $operation) { $expected_destination = Url::
fromUri('internal:/test-entity-operations'
)->
toString();
// Update destination property of the URL as generating it in the
// test would by default point to the frontpage.
$operation['url'
]->
setOption('query',
['destination' =>
$expected_destination]);
$this->
assertSession()->
elementsCount('xpath', "//ul[contains(@class, dropbutton)]/li/a[@href='{
$operation['url'
]->
toString()}' and text()='{
$operation['title'
]}']", 1
);
// Entities which were created in Hungarian should link to the Hungarian
// edit form, others to the English one (which has no path prefix here).
$base_path = \Drupal::
request()->
getBasePath();
$parts =
explode('/',
str_replace($base_path, '',
$operation['url'
]->
toString()));