X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fentity%2Ftests%2Fsrc%2FFunctional%2FDeleteMultipleFormTest.php;fp=web%2Fmodules%2Fcontrib%2Fentity%2Ftests%2Fsrc%2FFunctional%2FDeleteMultipleFormTest.php;h=aaf70c60ed54989a488a6e7a0a55aa62391fd462;hb=f3baf763d342a5f82576890e2a8111a5aaf139dc;hp=0000000000000000000000000000000000000000;hpb=059867c3f96750652c80f39e44c442a58c2549ee;p=yaffs-website diff --git a/web/modules/contrib/entity/tests/src/Functional/DeleteMultipleFormTest.php b/web/modules/contrib/entity/tests/src/Functional/DeleteMultipleFormTest.php new file mode 100644 index 000000000..aaf70c60e --- /dev/null +++ b/web/modules/contrib/entity/tests/src/Functional/DeleteMultipleFormTest.php @@ -0,0 +1,76 @@ +account = $this->drupalCreateUser(['administer entity_test_enhanced']); + $this->drupalLogin($this->account); + } + + /** + * Tests the add page. + */ + public function testForm() { + $entities = []; + $selection = []; + for ($i = 0; $i < 2; $i++) { + $entity = EnhancedEntity::create([ + 'type' => 'default', + ]); + $entity->save(); + $entities[$entity->id()] = $entity; + + $langcode = $entity->language()->getId(); + $selection[$entity->id()][$langcode] = $langcode; + } + // 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_enhanced', $selection); + + $this->drupalGet('/entity_test_enhanced/delete'); + $assert = $this->assertSession(); + $assert->statusCodeEquals(200); + $assert->elementTextContains('css', '.page-title', 'Are you sure you want to delete these enhanced entities?'); + $delete_button = $this->getSession()->getPage()->findButton('Delete'); + $delete_button->click(); + $assert = $this->assertSession(); + $assert->addressEquals('/entity_test_enhanced'); + $assert->responseContains('Deleted 2 items.'); + + \Drupal::entityTypeManager()->getStorage('entity_test_enhanced')->resetCache(); + $remaining_entities = EnhancedEntity::loadMultiple(array_keys($selection)); + $this->assertEmpty($remaining_entities); + } + +}