3 namespace Drupal\Tests\entity\Functional;
5 use Drupal\entity_module_test\Entity\EnhancedEntity;
6 use Drupal\Tests\BrowserTestBase;
9 * Tests the delete multiple confirmation form.
12 * @runTestsInSeparateProcesses
13 * @preserveGlobalState disabled
15 class DeleteMultipleFormTest extends BrowserTestBase {
20 * @var \Drupal\Core\Session\AccountInterface
29 public static $modules = ['entity_module_test', 'user', 'entity'];
34 protected function setUp() {
37 $this->account = $this->drupalCreateUser(['administer entity_test_enhanced']);
38 $this->drupalLogin($this->account);
44 public function testForm() {
47 for ($i = 0; $i < 2; $i++) {
48 $entity = EnhancedEntity::create([
52 $entities[$entity->id()] = $entity;
54 $langcode = $entity->language()->getId();
55 $selection[$entity->id()][$langcode] = $langcode;
57 // Add the selection to the tempstore just like DeleteAction would.
58 $tempstore = \Drupal::service('tempstore.private')->get('entity_delete_multiple_confirm');
59 $tempstore->set($this->account->id() . ':entity_test_enhanced', $selection);
61 $this->drupalGet('/entity_test_enhanced/delete');
62 $assert = $this->assertSession();
63 $assert->statusCodeEquals(200);
64 $assert->elementTextContains('css', '.page-title', 'Are you sure you want to delete these enhanced entities?');
65 $delete_button = $this->getSession()->getPage()->findButton('Delete');
66 $delete_button->click();
67 $assert = $this->assertSession();
68 $assert->addressEquals('/entity_test_enhanced');
69 $assert->responseContains('Deleted 2 items.');
71 \Drupal::entityTypeManager()->getStorage('entity_test_enhanced')->resetCache();
72 $remaining_entities = EnhancedEntity::loadMultiple(array_keys($selection));
73 $this->assertEmpty($remaining_entities);