Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / entity / tests / src / Functional / DeleteMultipleFormTest.php
1 <?php
2
3 namespace Drupal\Tests\entity\Functional;
4
5 use Drupal\entity_module_test\Entity\EnhancedEntity;
6 use Drupal\entity_module_test\Entity\EnhancedEntityBundle;
7 use Drupal\Tests\BrowserTestBase;
8
9 /**
10  * Tests the delete multiple confirmation form.
11  *
12  * @group entity
13  * @runTestsInSeparateProcesses
14  * @preserveGlobalState disabled
15  */
16 class DeleteMultipleFormTest extends BrowserTestBase {
17
18   /**
19    * The current user.
20    *
21    * @var \Drupal\Core\Session\AccountInterface
22    */
23   protected $account;
24
25   /**
26    * Modules to enable.
27    *
28    * @var array
29    */
30   public static $modules = ['entity_module_test', 'user', 'entity'];
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function setUp() {
36     parent::setUp();
37
38     EnhancedEntityBundle::create([
39       'id' => 'default',
40       'label' => 'Default',
41     ])->save();
42     $this->account = $this->drupalCreateUser(['administer entity_test_enhanced']);
43     $this->drupalLogin($this->account);
44   }
45
46   /**
47    * Tests the add page.
48    */
49   public function testForm() {
50     $entities = [];
51     $selection = [];
52     for ($i = 0; $i < 2; $i++) {
53       $entity = EnhancedEntity::create([
54         'type' => 'default',
55       ]);
56       $entity->save();
57       $entities[$entity->id()] = $entity;
58
59       $langcode = $entity->language()->getId();
60       $selection[$entity->id()][$langcode] = $langcode;
61     }
62     // Add the selection to the tempstore just like DeleteAction would.
63     $tempstore = \Drupal::service('tempstore.private')->get('entity_delete_multiple_confirm');
64     $tempstore->set($this->account->id() . ':entity_test_enhanced', $selection);
65
66     $this->drupalGet('/entity_test_enhanced/delete');
67     $assert = $this->assertSession();
68     $assert->statusCodeEquals(200);
69     $assert->elementTextContains('css', '.page-title', 'Are you sure you want to delete these enhanced entities?');
70     $delete_button = $this->getSession()->getPage()->findButton('Delete');
71     $delete_button->click();
72     $assert = $this->assertSession();
73     $assert->addressEquals('/entity_test_enhanced');
74     $assert->responseContains('Deleted 2 items.');
75
76     \Drupal::entityTypeManager()->getStorage('entity_test_enhanced')->resetCache();
77     $remaining_entities = EnhancedEntity::loadMultiple(array_keys($selection));
78     $this->assertEmpty($remaining_entities);
79   }
80
81 }