function DeleteMultipleFormTest::testUntranslatableEntities
Same name in other branches
- 9 core/tests/Drupal/FunctionalTests/Entity/DeleteMultipleFormTest.php \Drupal\FunctionalTests\Entity\DeleteMultipleFormTest::testUntranslatableEntities()
- 8.9.x core/tests/Drupal/FunctionalTests/Entity/DeleteMultipleFormTest.php \Drupal\FunctionalTests\Entity\DeleteMultipleFormTest::testUntranslatableEntities()
- 11.x core/tests/Drupal/FunctionalTests/Entity/DeleteMultipleFormTest.php \Drupal\FunctionalTests\Entity\DeleteMultipleFormTest::testUntranslatableEntities()
Tests the delete form for untranslatable entities.
File
-
core/
tests/ Drupal/ FunctionalTests/ Entity/ DeleteMultipleFormTest.php, line 118
Class
- DeleteMultipleFormTest
- Tests the delete multiple confirmation form.
Namespace
Drupal\FunctionalTests\EntityCode
public function testUntranslatableEntities() : void {
$selection = [];
$entity1 = EntityTestRev::create([
'type' => 'default',
'name' => 'entity1',
]);
$entity1->save();
$selection[$entity1->id()]['en'] = 'en';
$entity2 = EntityTestRev::create([
'type' => 'default',
'name' => 'entity2',
]);
$entity2->save();
$selection[$entity2->id()]['en'] = 'en';
// This entity will be inaccessible because of
// Drupal\entity_test\EntityTestAccessControlHandler.
$entity3 = EntityTestRev::create([
'type' => 'default',
'name' => 'forbid_access',
]);
$entity3->save();
$selection[$entity3->id()]['en'] = 'en';
// This entity will be inaccessible because of
// Drupal\entity_test\EntityTestAccessControlHandler.
$entity4 = EntityTestRev::create([
'type' => 'default',
'name' => 'forbid_access',
]);
$entity4->save();
$selection[$entity4->id()]['en'] = 'en';
// Add the selection to the tempstore just like DeleteAction would.
$tempstore = \Drupal::service('tempstore.private')->get('entity_delete_multiple_confirm');
$tempstore->set($this->account
->id() . ':entity_test_rev', $selection);
$this->drupalGet('/entity_test_rev/delete_multiple');
$assert = $this->assertSession();
$assert->statusCodeEquals(200);
$assert->elementTextContains('css', 'h1', 'Are you sure you want to delete these test entity - revisions entities?');
$list_selector = '#entity-test-rev-delete-multiple-confirm-form > ul[data-drupal-selector="edit-entities"]';
$assert->elementTextContains('css', $list_selector, 'entity1');
$assert->elementTextContains('css', $list_selector, 'entity2');
$delete_button = $this->getSession()
->getPage()
->findButton('Delete');
$delete_button->click();
$assert = $this->assertSession();
$assert->addressEquals('/user/' . $this->account
->id());
$assert->responseContains('Deleted 2 items.');
$assert->responseContains('2 items have not been deleted because you do not have the necessary permissions.');
\Drupal::entityTypeManager()->getStorage('entity_test_mulrevpub')
->resetCache();
$remaining_entities = EntityTestRev::loadMultiple([
$entity1->id(),
$entity2->id(),
$entity3->id(),
$entity4->id(),
]);
$this->assertCount(2, $remaining_entities);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.