UwWcmsBasicTest.php 43.5 KB
Newer Older
1
2
3
4
<?php

namespace Drupal\Tests\uw_base_profile\Functional;

5
use Drupal\Core\StringTranslation\StringTranslationTrait;
6
7
8
9
10
11
12
13
14
use Drupal\Tests\BrowserTestBase;

/**
 * Basic WCMS test.
 *
 * @group UwWcms
 */
class UwWcmsBasicTest extends BrowserTestBase {

15
16
  use StringTranslationTrait;

17
18
19
20
21
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'uw_fdsu_theme_resp';

22
23
24
25
26
27
28
  /**
   * See https://www.drupal.org/node/1911318.
   *
   * @var string
   */
  protected $profile = 'uw_base_profile';

29
  // phpcs:disable DrupalPractice.Objects.StrictSchemaDisabled.StrictConfigSchema
30
31
32
33
  /**
   * It would be better if we didn't need this, but tests fail without it.
   *
   * @var bool
34
35
36
   *
   * @todo Remove $strictConfigSchema so that the default TRUE is used. Remove
   * this comment and the phpcs:disable comment above when doing this.
37
38
39
   */
  protected $strictConfigSchema = FALSE;

40
41
42
43
44
45
46
  /**
   * Array of user objects keyed by the role they have.
   *
   * @var array
   */
  public $drupalUsers = [];

47
48
49
50
51
52
53
  /**
   * Basic test.
   */
  public function testPage() {
    $this->drupalGet('');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains('200 University Avenue West');
54
55
56

    $big_pipe_enabled = \Drupal::moduleHandler()->moduleExists('big_pipe');
    $this->assertFalse($big_pipe_enabled, 'BigPipe module is not enabled.');
57
58
59

    $this->createUsers();

60
    $this->webformTests();
61
62

    $this->createContent();
63
64

    $this->taxonomies();
65

66
    $this->catalogTest();
67

68
    $this->schemaTest();
69

70
    $this->configBlockTest();
71
72

    $this->previewButtonTest();
73

74
    $this->layoutBuilderBrowserTest();
75

76
    $this->globalFooterTest();
Lily Yan's avatar
Lily Yan committed
77

Igor Biki's avatar
Igor Biki committed
78
79
80
81
    $this->menusTest();

    $this->dashboardTest();

82
    $this->ctaBlockTest();
83
84

    $this->permissionsTest();
85
86
87
88
89
90
  }

  /**
   * Test Webforms.
   */
  private function webformTests() {
91
92
93
94
95
96
97
98
99
    // Create test Webform.
    $this->drupalLogin($this->drupalUsers['uw_role_form_editor']);
    $edit = [
      'id' => 'test_form',
      'title' => 'Test Form',
      'status' => 'open',
    ];
    $this->drupalPostForm('admin/structure/webform/add', $edit, 'Save');

100
101
102
103
104
105
106
    // The variable $test_paths stores Drupal paths and permission information.
    // In this array, the keys are paths. If the value is TRUE, everyone has
    // access. Otherwise, the value must be an array of roles that have access.
    // Other roles do not have access.
    $test_paths = [
      '' => TRUE,
      'admin' => [
107
        'uw_role_site_owner',
108
109
110
111
        'uw_role_site_manager',
        'uw_role_content_editor',
        'uw_role_content_author',
      ],
112
113

      // Webform.
Liam Morland's avatar
Liam Morland committed
114
115
116
117
      'admin/structure/webform' => [
        'uw_role_form_editor',
        'uw_role_form_results_access',
      ],
118
119
120
121
122
123
124
125
126
127
128
129
130
      'admin/structure/webform/add' => ['uw_role_form_editor'],
      'admin/structure/webform/addons' => ['uw_role_form_editor'],
      'admin/structure/webform/config' => ['uw_role_form_editor'],
      'admin/structure/webform/config/advanced' => ['uw_role_form_editor'],
      'admin/structure/webform/config/advanced' => ['uw_role_form_editor'],
      'admin/structure/webform/config/elements' => ['uw_role_form_editor'],
      'admin/structure/webform/config/exporters' => ['uw_role_form_editor'],
      'admin/structure/webform/config/handlers' => ['uw_role_form_editor'],
      'admin/structure/webform/config/libraries' => ['uw_role_form_editor'],
      'admin/structure/webform/config/options/manage' => ['uw_role_form_editor'],
      'admin/structure/webform/config/submissions' => ['uw_role_form_editor'],
      'admin/structure/webform/config/variants' => ['uw_role_form_editor'],
      'admin/structure/webform/help' => TRUE,
Liam Morland's avatar
Liam Morland committed
131
132
133
134
      'admin/structure/webform/submissions/manage' => [
        'uw_role_form_editor',
        'uw_role_form_results_access',
      ],
135
136
      // Test Webform.
      'admin/structure/webform/manage/test_form' => ['uw_role_form_editor'],
Liam Morland's avatar
Liam Morland committed
137
138
139
140
      'admin/structure/webform/manage/test_form/results/submissions' => [
        'uw_role_form_editor',
        'uw_role_form_results_access',
      ],
141
142
143
      'admin/structure/webform/manage/test_form/settings' => ['uw_role_form_editor'],
      'form/test-form' => TRUE,
      'webform/test_form/test' => ['uw_role_form_editor'],
144
145
146
    ];
    // Test these paths with each user.
    foreach ($this->drupalUsers as $role => $user) {
147
148
149
150
      // Admin always has access so there is no point testing.
      if ($role === 'administrator') {
        continue;
      }
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
      if ($user) {
        $this->drupalLogin($user);
      }
      elseif ($this->loggedInUser) {
        $this->drupalLogout();
      }
      foreach ($test_paths as $path => $permissions) {
        // Get the expected HTTP response code.
        $expected_code = ($permissions === TRUE || in_array($role, $permissions, TRUE)) ? 200 : 403;
        // Test this path for the HTTP response code.
        $this->drupalGet($path);
        $this_code = $this->getSession()->getStatusCode();
        $message = sprintf('Response status code for %s on path %s is %d; %d expected.', $role, $path, $this_code, $expected_code);
        $this->assert(intval($this_code) === $expected_code, $message);
      }
    }
167
168
  }

169
170
171
172
173
174
175
176
177
178
179
180
  /**
   * Populate $drupalUsers with an array of users with various roles.
   */
  private function createUsers() {
    // Test if property is already populated.
    if ($this->drupalUsers) {
      return;
    }
    // Create users.
    $this->drupalUsers = ['anonymous user' => NULL];
    $roles = [
      'authenticated user',
181
      'administrator',
182
      'uw_role_site_owner',
183
184
185
      'uw_role_site_manager',
      'uw_role_content_editor',
      'uw_role_content_author',
186
187
      'uw_role_form_editor',
      'uw_role_form_results_access',
188
189
190
191
192
193
194
    ];
    foreach ($roles as $role) {
      $user = ['roles' => [$role]];
      $this->drupalUsers[$role] = $this->createUser([], $role, FALSE, $user);
    }
  }

195
196
197
198
199
200
  /**
   * Test content creation.
   */
  private function createContent() {
    $this->drupalLogin($this->drupalUsers['uw_role_content_author']);

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
    // Array of content types.
    // Keys: Content types.
    // Values: Array of extra fields and their types.
    $content_types = [
      'uw_ct_web_page' => [],
      'uw_ct_site_footer' => [],
      'uw_ct_blog' => ['edit-field-uw-blog-summary-0-value' => 'string'],
      'uw_ct_news_item' => ['edit-field-uw-news-summary-0-value' => 'string'],
      'uw_ct_event' => [
        'edit-field-uw-event-summary-0-value' => 'string',
        'edit-field-uw-event-date-0-value-date' => 'date',
        'edit-field-uw-event-date-0-value-time' => 'time',
        'edit-field-uw-event-date-0-end-value-date' => 'date',
        'edit-field-uw-event-date-0-end-value-time' => 'time',
      ],
216
      // uw_ct_sidebar is tested separately below.
217
    ];
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

    foreach ($content_types as $content_type => $extra_fields) {
      // Create node.
      $edit = [
        'edit-title-0-value' => $this->randomString(),
      ];
      foreach ($extra_fields as $field => $type) {
        switch ($type) {
          case 'date':
            $edit[$field] = date('Y-m-d');
            break;

          case 'time':
            $edit[$field] = date('H:i:s');
            break;

          default:
            $edit[$field] = $this->randomString();
        }
      }
      $this->drupalPostForm('node/add/' . $content_type, $edit, 'Save');
239
240

      // On node creation, the user is redirected to the layout edit page.
241
242
243
      $this->assertSession()->addressMatches(',^/node/\d+/layout,');
      // Check node title.
      $this->assertSession()->pageTextContains('Edit layout for ' . $edit['edit-title-0-value']);
244
245
246

      // On node edit, the user is not redirected to the layout edit page.
      $this->clickLink('Edit');
247
248
249
      // Store edit link for later use.
      $url = $this->getSession()->getCurrentUrl();
      // Save edit form without making changes.
250
      $this->submitForm([], 'Save');
251
      // Verify that we are not on the layout edit page.
252
253
      $this->assertSession()->pageTextContains($edit['edit-title-0-value'] . ' has been updated');
      $this->assertSession()->pageTextNotContains('Edit layout for');
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279

      // Test "Menu Settings", "Place in site hierarchy" and "Add menu link".
      // This is custom WCMS functionality in uw_sites_all.
      if ($content_type === 'uw_ct_web_page') {
        $title = $edit['edit-title-0-value'];
        $this->drupalLogin($this->drupalUsers['administrator']);
        // By default, "Place in site hierarchy" is unchecked. There should be
        // no menu item.
        $this->drupalGet('admin/structure/menu/manage/main');
        $this->assertSession()->pageTextNotContains($title);
        // Check "Place in site hierarchy", creating enabled menu item.
        $edit = [
          'menu[enabled]' => TRUE,
          // The title defaults via JS to the page title. Specify since no JS.
          'menu[title]' => $title,
        ];
        $this->drupalPostForm($url, $edit, 'Save');
        $this->drupalGet('admin/structure/menu/manage/main');
        $this->assertSession()->pageTextContains($title);
        $this->assertSession()->pageTextNotContains($title . ' (disabled)');
        // Uncheck "Add menu link", making menu item be disabled.
        $edit = ['menu[place_in_menu]' => FALSE];
        $this->drupalPostForm($url, $edit, 'Save');
        $this->drupalGet('admin/structure/menu/manage/main');
        $this->assertSession()->pageTextContains($title . ' (disabled)');
      }
280
    }
281
282
283
284
285
286
287
288
289
290
291
292

    // Test uw_ct_sidebar. There is no title in the content type, only a node
    // reference field.
    $edit = [
      // The actual title is ignored, but has to be present. The number in
      // brackets is used as the nid of the page to attach this sidebar to.
      'edit-field-uw-attach-page-0-target-id' => 'Title (1)',
    ];
    $this->drupalPostForm('node/add/uw_ct_sidebar', $edit, 'Save');
    // Verify that the user is redirected to the layout edit page.
    $this->assertSession()->addressMatches(',^/node/\d+/layout,');
    $this->assertSession()->pageTextContains('You are editing the layout for this Sidebar content item.');
293
294
  }

295
296
297
298
299
300
301
302
303
304
305
306
  /**
   * Test taxonomies.
   */
  private function taxonomies() {
    $this->drupalLogin($this->drupalUsers['administrator']);

    $this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_faculties_and_schools/overview');
    $this->assertSession()->statusCodeEquals(200);

    $this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_audience/overview');
    $this->assertSession()->statusCodeEquals(200);

307
308
309
310
311
312
    $this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_catalogs/overview');
    $this->assertSession()->statusCodeEquals(200);

    $this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_catalog_categories/overview');
    $this->assertSession()->statusCodeEquals(200);

313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
    $this->drupalGet('admin/config/search/path');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains('/catalogs/faculties-and-schools/faculty-');
    $this->assertSession()->pageTextContains('/audience/current-');
    $this->assertSession()->pageTextContains('/events/types/');

    $this->drupalGet('admin/config/search/path/patterns');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains('Audience path pattern');
    $this->assertSession()->pageTextContains('Vocabulary is uw_vocab_audience');
    $this->assertSession()->pageTextContains('Catalogs path pattern');
    $this->assertSession()->pageTextContains('Vocabulary is uw_vocab_catalogs');
    $this->assertSession()->pageTextContains('Catalog categories path pattern');
    $this->assertSession()->pageTextContains('Vocabulary is uw_vocab_catalog_categories');
    $this->assertSession()->pageTextContains('Faculties and schools path pattern');
    $this->assertSession()->pageTextContains('Vocabulary is uw_vocab_faculties_and_schools');
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350

    // Make sure URL alias fields off of taxonomy forms for all vocabularies.
    $vocabs = [
      'uw_vocab_audience',
      'uw_vocab_blog_tags',
      'uw_vocab_catalog_categories',
      'uw_vocab_catalogs',
      'uw_tax_event_tags',
      'uw_tax_event_type',
      'uw_vocab_faculties_and_schools',
      'uw_vocab_news_tags',
    ];
    foreach ($vocabs as $vocab) {
      // Load the term-add page.
      $this->drupalGet('admin/structure/taxonomy/manage/' . $vocab . '/add');
      $this->assertSession()->statusCodeEquals(200);
      // Check if URL alias field is off of taxomoy form.
      $this->assertSession()->pageTextNotContains('Generate automatic URL alias');
      $this->assertNoFieldById('edit-path-0-pathauto');
      $this->assertSession()->pageTextNotContains('URL alias');
      $this->assertNoFieldById('edit-path-0-alias');
    }
351
352
  }

353
  /**
Liam Morland's avatar
Liam Morland committed
354
355
356
357
358
   * Catalog tests.
   *
   * Case 1: Make sure workflows exist.
   * Case 2: Make sure roles at default install are set up as expected.
   * Case 3: Make sure "preview" button does not exist.
359
   */
360
  private function catalogTest() {
361
362
363
364
365
    // Make sure work flows exist.
    $this->drupalLogin($this->drupalUsers['administrator']);
    $this->drupalGet('admin/config/workflow/workflows/manage/uw_workflow');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains('Catalog item');
366

367
    // Make sure roles at default install are set up as expected.
368
369
370
371
    $roles = [
      'uw_role_content_author',
      'uw_role_content_editor',
      'uw_role_site_manager',
372
373
    ];

374
375
376
377
378
379
380
381
    foreach ($roles as $role) {
      // Login as the given role.
      $this->drupalLogin($this->drupalUsers[$role]);
      // Prepare $edit for catalog term name.
      $edit = [
        'edit-name-0-value' => $this->randomString(),
      ];
      // Create a catalog term based on the above catalog term name.
382
      $this->drupalPostForm('admin/structure/taxonomy/manage/uw_vocab_catalogs/add', $edit, $this->t('Save'));
383
384
385
386
387
      // Prepare $edit for catalog categories term name.
      $edit = [
        'edit-name-0-value' => $this->randomString(),
      ];
      // Create a catalog categories term based on the above catalog term name.
388
      $this->drupalPostForm('admin/structure/taxonomy/manage/uw_vocab_catalog_categories/add', $edit, $this->t('Save'));
389
390
391
392
393
394
      // Prepare $edit for catalog item node.
      $edit = [
        'edit-title-0-value' => $this->randomString(),
        'edit-field-uw-catalog-summary-0-value' => $this->randomString(),
        'edit-field-uw-catalog-popularity-0-value' => rand(1, 9),
        'edit-field-uw-catalog-category-target-id-value-field' => $this->randomString(),
395
        'edit-field-uw-catalog-faculty-21' => 21,
396
        'edit-moderation-state-0-state' => 'uw_wf_needs_review',
397
398
399
      ];
      // Create a catalog item node.
      $this->drupalPostForm('node/add/uw_ct_catalog_item', $edit, 'Save');
400
401
      // Make sure "preview" button does not exist.
      $this->assertSession()->buttonNotExists('Preview');
402
    }
403
  }
404

405
406
407
  /**
   * Test schema_metatag.
   */
408
  private function schemaTest() {
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
    // Make sure the below modules are enabled.
    $modules = [
      'schema_article' => 'Schema.org Article',
      'schema_event' => 'Schema.org Event',
      'schema_metatag' => 'Schema.org Metatag',
      'schema_organization' => 'Schema.org Organization',
      'schema_service' => 'Schema.org Service',
      'schema_web_page' => 'Schema.org WebPage',
    ];

    foreach ($modules as $key => $module) {
      $enabled = \Drupal::moduleHandler()->moduleExists($key);
      $this->assertTrue($enabled, $module . ' module is not enabled.');
    }

424
425
426
427
    // Make sure the below path exists.
    $this->drupalLogin($this->drupalUsers['administrator']);
    $this->drupalGet('admin/config/search/metatag/settings');
    $this->assertSession()->statusCodeEquals(200);
428
429
430
431
432
433
434
435
436
437
438
439
440

    // Make sure content blog post some are checked, and some are not checked.
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-basic');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-advanced');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-open-graph');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-twitter-cards');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-article');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-event');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-organization');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-person');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-service');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-web-page');

441
442
443
444
445
446
447
448
449
450
451
452
    // Make sure content catalog item some are checked, and some are not.
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-basic');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-advanced');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-open-graph');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-twitter-cards');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-web-page');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-article');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-event');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-organization');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-person');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-service');

453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
    // Make sure content event some are checked, and some are not checked.
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-basic');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-advanced');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-open-graph');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-twitter-cards');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-event');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-article');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-organization');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-person');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-service');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-web-page');

    // Make sure content news item some are checked, and some are not checked.
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-basic');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-advanced');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-open-graph');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-twitter-cards');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-article');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-event');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-organization');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-person');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-service');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-web-page');

    // Make sure content web page some are checked, and some are not checked.
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-basic');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-advanced');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-open-graph');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-twitter-cards');
    $this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-web-page');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-article');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-event');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-organization');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-person');
    $this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-service');
488
489
490
491
492
493
494
495
496
497

    // Make sure meta tag info fields exist when
    // add a node of the given content type.
    $types = $this->getContentTypes(TRUE);
    foreach ($types as $type) {
      $this->drupalGet('node/add/' . $type);
      $this->assertSession()->statusCodeEquals(200);
      $this->assertFieldById('edit-field-uw-meta-description-0-value');
      $this->assertSession()->buttonExists('edit-field-uw-meta-image-open-button');
    }
498
  }
Igor Biki's avatar
Igor Biki committed
499

500
501
  /**
   * Test config block.
Liam Morland's avatar
Liam Morland committed
502
   *
503
   * Test help text of Block ID and hiding url alias.
504
   * Test timeline block.
505
   */
506
  private function configBlockTest() {
507
508
    $this->drupalLogin($this->drupalUsers['administrator']);

509
510
511
512
513
514
515
516
517
    $blocks = [
      'Blockquote',
      'Call to action',
      'Copy text',
      'Facts and figures',
      'Full width image',
      'Image gallery',
      'Mailman subscription',
      'Related links',
518
      'Timeline',
519
520
521
522
523
524
525
526
527
528
      'Facebook',
      'Instagram',
      'Remote video',
      'Tableau visualization',
      'Twitter',
    ];

    foreach ($blocks as $block) {
      $this->drupalGet('node/1/layout');
      $this->assertSession()->statusCodeEquals(200);
529

530
531
      // On the layout edit page to click 'Add block'.
      $this->clickLink('Add block');
532

533
534
      // Verify that Blockquote and others are on the layout edit page.
      $this->assertSession()->pageTextContains('Choose a block');
535

Liam Morland's avatar
Liam Morland committed
536
      // Click 'Blockquote'.
537
      $this->clickLink($block);
538

Liam Morland's avatar
Liam Morland committed
539
      // Show Configure block.
540
      $this->drupalPlaceBlock('layout_builder_add_block');
541

Liam Morland's avatar
Liam Morland committed
542
      // Check help text of Block ID.
543
544
545
546
547
548
      $this->assertSession()->pageTextContains('Block ID is an optional setting which is used to support an anchor link to this block');

      // Check if URL alias field exists.
      $this->assertSession()->pageTextNotContains('Generate automatic URL alias');
      $this->assertSession()->pageTextNotContains('URL alias');
    }
549
550
551
552
553
554
555
556

    // Test timeline Step 1: Visit the home page layout.
    $this->drupalGet('node/1/layout');
    $this->assertSession()->statusCodeEquals(200);

    // Test timeline Step 2: Look on the layout edit page to click 'Add block'.
    $this->clickLink('Add block');

Liam Morland's avatar
Liam Morland committed
557
558
    // Test timeline Step 3: Verify that Blockquote and others are on the
    // layout edit page.
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
    $this->assertSession()->pageTextContains('Choose a block');

    // Test timeline Step 4: Look on the page for the 'Timeline' link.
    $this->assertSession()->linkExists('Timeline');

    // Test timeline Step 5: Click 'Timeline'.
    $this->clickLink('Timeline');

    // Test timeline Step 6: Show Configure block (pop-up window).
    $this->drupalPlaceBlock('layout_builder_add_block');

    // Test timeline Step 7: Check all fields and buttons of timeline block.
    $this->assertSession()->pageTextContains('Title');
    $this->assertFieldById('edit-settings-label');
    $this->assertSession()->pageTextContains('Timeline style');
    $this->assertFieldById('edit-settings-block-form-field-uw-timeline-style');
    $this->assertSession()->pageTextContains('Timeline sort');
    $this->assertFieldById('edit-settings-block-form-field-uw-timeline-sort');
    $this->assertSession()->pageTextContains('Date');
    $this->assertFieldById('edit-settings-block-form-field-uw-timeline-0-subform-field-uw-timeline-date-0-value-date');
    $this->assertSession()->pageTextContains('Headline');
    $this->assertFieldById('edit-settings-block-form-field-uw-timeline-0-subform-field-uw-timeline-headline-0-value');
    $this->assertSession()->pageTextContains('One or both of the "Headline" and "Content" fields must be populated.');
    $this->assertSession()->pageTextContains('PHOTO');
    $this->assertSession()->buttonExists('Add media');
    $this->assertSession()->pageTextContains('One media item remaining.');
    $this->assertSession()->pageTextContains('Link');
    $this->assertSession()->pageTextContains('Links the entire content to a URL. If entered, do not use links inside the content itself.');
    $this->assertSession()->pageTextContains('Content');
    $this->assertSession()->buttonExists('Add Timeline');
589
  }
Liam Morland's avatar
Liam Morland committed
590

591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
  /**
   * Test preview button option.
   */
  private function previewButtonTest() {

    // Administrator login.
    $this->drupalLogin($this->drupalUsers['administrator']);

    // Add new content type.
    $this->drupalGet('admin/structure/types/add');
    // Test that "Preview before submitting" is set to "Disabled".
    $this->assertFieldChecked('edit-preview-mode-0');
    $this->assertNoFieldChecked('edit-preview-mode-1');
    $this->assertNoFieldChecked('edit-preview-mode-2');

606
    $types = $this->getContentTypes();
607
608
609
610
611
612
613
614
    foreach ($types as $type) {
      // Load the node-add page.
      $this->drupalGet('node/add/' . $type);
      // Preview button doesn't exist.
      $this->assertSession()->buttonNotExists('edit-preview');
    }
  }

615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
  /**
   * A function to get all UW content types.
   *
   * @param bool $filter
   *   When TRUE, return only content types that have metatag enabled.
   *
   * @return array
   *   An array of all UW content types filtered by TRUE/FALSE.
   */
  public function getContentTypes(bool $filter = FALSE): array {

    // This is the list of all UW content types, with a TRUE/FALSE, indicating
    // whether or not a metatag tag can be attached to this content type.
    $content_types = [
      'uw_ct_blog' => TRUE,
      'uw_ct_catalog_item' => TRUE,
      'uw_ct_event' => TRUE,
      'uw_ct_news_item' => TRUE,
      'uw_ct_sidebar' => FALSE,
      'uw_ct_site_footer' => FALSE,
      'uw_ct_web_page' => TRUE,
    ];

    $return_content_types = [];
    foreach ($content_types as $key => $value) {
      if (($filter && $value) || !$filter) {
        $return_content_types[] = $key;
      }
    }

    return $return_content_types;
  }

648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
  /**
   * Test Layout Builder Browser.
   *
   * Test Layout builder browser configuration and its weights.
   */
  private function layoutBuilderBrowserTest() {

    // Administrator login.
    $this->drupalLogin($this->drupalUsers['administrator']);
    // Go to Layout Builder Browser configuration page.
    $this->drupalGet('admin/config/content/layout-builder-browser');
    $this->assertSession()->statusCodeEquals(200);
    // Items include Content, External embeds, Listings,
    // Searches, Teasers and Webforms, and blocks related.
    $items = [
      '.region-title-uw_bc_content',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-blockquote"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-call-to-action"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-copy-text"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-facts-and-figures"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-image"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-mailman"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-related-links"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-timeline"]',
      '.region-title-uw_bc_external_embeds',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-facebook"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-google-maps"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-instagram"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-powerbi"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-remote-video"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-tableau"]',
      'tr[data-drupal-selector="edit-categories-inline-blockuw-cbl-twitter"]',
      '.region-title-uw_bc_listings',
      'tr[data-drupal-selector="edit-categories-uw-cbl-multi-type-list"]',
      'tr[data-drupal-selector="edit-categories-views-blockuw-view-blogs-blogs-listing-block"]',
      'tr[data-drupal-selector="edit-categories-views-blockuw-view-events-events-listing-block"]',
      'tr[data-drupal-selector="edit-categories-views-blockuw-view-news-items-news-items-listing-block"]',
      '.region-title-uw_bc_searches',
      '.region-title-uw_bc_teasers',
      'tr[data-drupal-selector="edit-categories-uw-cbl-blog-teaser"]',
      'tr[data-drupal-selector="edit-categories-uw-cbl-event-teaser"]',
      'tr[data-drupal-selector="edit-categories-uw-cbl-news-teaser"]',
      '.region-title-uw_bc_webforms',
      'tr[data-drupal-selector="edit-categories-webform-block"]',
    ];
    foreach ($items as $item) {
      $this->assertSession()->elementExists('css', $item);
    }

    // All weights except the below three fields are 0.
    // The weight of blog post list is -2.
    // The weight of event list is -1.
    // The weight of news item list is 1.
    $this->assertOptionSelected('edit-categories-uw-cbl-multi-type-list-weight', '0');
    $this->assertOptionSelected('edit-categories-views-blockuw-view-blogs-blogs-listing-block-weight', '-2');
    $this->assertOptionSelected('edit-categories-views-blockuw-view-events-events-listing-block-weight', '-1');
    $this->assertOptionSelected('edit-categories-views-blockuw-view-news-items-news-items-listing-block-weight', '1');
705
  }
Lily Yan's avatar
Lily Yan committed
706

707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
  /**
   * Test global footer.
   *
   * Test update territorial acknowledgement.
   * Test update the 'Media' link to read 'News'.
   */
  private function globalFooterTest() {
    $this->drupalGet('');
    $this->assertSession()->statusCodeEquals(200);
    // Find all 'News' links.
    $news = $this->getSession()->getPage()->findAll('xpath', "//span[contains(text(), 'News')]");
    // Current we have two 'News' links.
    $this->assertCount(2, $news);
    // Make sure the second 'News' link is 'uwaterloo.ca/news'.
    $this->assertEquals('https://uwaterloo.ca/news/', $news[1]->getParent()->getAttribute('href'));
    // Media link doesn't exist.
    $this->assertSession()->linkNotExists('Media');
    // 'the land granted to the Six Nations' can be found.
    $this->assertSession()->pageTextContains('the land granted to the Six Nations');
726
727
  }

Lily Yan's avatar
Lily Yan committed
728
729
730
731
732
733
734
735
736
737
738
739
  /**
   * Test menu links.
   *
   * Test content management menu links.
   * Test site information menu links.
   */
  private function menusTest() {
    // Administrator login.
    $this->drupalLogin($this->drupalUsers['administrator']);
    // Go to content management menu links.
    $this->drupalGet('admin/structure/menu/manage/uw-menu-content-management');
    $this->assertSession()->statusCodeEquals(200);
740

Lily Yan's avatar
Lily Yan committed
741
742
    // Check content management menu links.
    $content_links = [
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
      'admin/structure/types' => 'Content types',
      'node/add/uw_ct_blog' => 'Blog post',
      'admin/structure/taxonomy/manage/uw_vocab_blog_tags/add' => 'Add blog tag',
      'admin/structure/taxonomy/manage/uw_vocab_blog_tags/overview' => 'List blog tags',
      'node/add/uw_ct_catalog_item' => 'Catalog item',
      'admin/structure/taxonomy/manage/uw_vocab_catalog_categories/add' => 'Add catalog category',
      'admin/structure/taxonomy/manage/uw_vocab_catalogs/add' => 'Add catalog',
      'admin/structure/taxonomy/manage/uw_vocab_catalog_categories/overview' => 'List catalog categories',
      'admin/structure/taxonomy/manage/uw_vocab_catalogs/overview' => 'List catalogs',
      'node/add/uw_ct_event' => 'Event',
      'admin/structure/taxonomy/manage/uw_tax_event_tags/add' => 'Add event tag',
      'admin/structure/taxonomy/manage/uw_tax_event_type/add' => 'Add event type',
      'admin/structure/taxonomy/manage/uw_tax_event_tags/overview' => 'List event tags',
      'admin/structure/taxonomy/manage/uw_tax_event_type/overview' => 'List event types',
      'node/add/uw_ct_news_item' => 'News item',
      'admin/structure/taxonomy/manage/uw_vocab_news_tags/add' => 'Add news tag',
      'admin/structure/taxonomy/manage/uw_vocab_news_tags/overview' => 'List news tags',
      'node/add/uw_ct_site_footer' => 'Site footer',
      'node/add/uw_ct_web_page' => 'Web page',
      'admin/structure/webform' => 'Forms',
      'admin/structure/webform/add' => 'Form',
      'admin/structure/webform/submissions/manage' => 'Manage submissions',
      'admin/structure/taxonomy' => 'Global vocabularies',
      'admin/structure/taxonomy/manage/uw_vocab_audience' => 'Audience',
      'admin/structure/taxonomy/manage/uw_vocab_audience/add' => 'Add term',
      'admin/structure/taxonomy/manage/uw_vocab_audience/overview' => 'List terms',
Lily Yan's avatar
Lily Yan committed
769
770
771
    ];
    foreach ($content_links as $key => $item) {
      $this->assertSession()->linkExists($item);
772
      $this->assertEquals(base_path() . $key, $this->getSession()->getPage()->findLink($item)->getAttribute('href'));
Lily Yan's avatar
Lily Yan committed
773
774
775
776
777
778
    }
    // Go to site information menu links.
    $this->drupalGet('admin/structure/menu/manage/uw-menu-site-management');
    $this->assertSession()->statusCodeEquals(200);
    // Check site information menu links.
    $site_links = [
779
780
      base_path() . 'admin/content-access' => 'Content access',
      base_path() . 'admin/structure/menu' => 'Menus',
Lily Yan's avatar
Lily Yan committed
781
782
783
784
785
786
787
788
789
      'mailto:rt-ist-wcms@rt.uwaterloo.ca' => 'Submit request',
      'https://uwaterloo.ca/web-resources/wcms-users/training-and-support/wcms-how-documents' => 'WCMS how-to documents',
    ];
    foreach ($site_links as $key => $item) {
      $this->assertSession()->linkExists($item);
      $this->assertEquals($key, $this->getSession()->getPage()->findLink($item)->getAttribute('href'));
    }
  }

790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
  /**
   * Test dashboard.
   *
   * Test default dashboard.
   */
  private function dashboardTest() {
    // Administrator login.
    $this->drupalLogin($this->drupalUsers['administrator']);
    // Go to My Dashboard.
    $this->drupalGet('dashboard/my_dashboard');
    $this->assertSession()->statusCodeEquals(200);
    // 'web-resources-news', 'recent-content' and 'whos-online'
    // are under 'layout--uw-3-col even-split', the rest four
    // are under 'layout--uw-2-col larger-left'.
    $ids = [
805
806
807
808
809
810
811
      'web-resources-news' => 'uw-full-width layout layout--uw-3-col even-split',
      'recent-content' => 'uw-full-width layout layout--uw-3-col even-split',
      'whos-online' => 'uw-full-width layout layout--uw-3-col even-split',
      'content-list' => 'uw-full-width layout layout--uw-2-col larger-left',
      'forms-list' => 'uw-full-width layout layout--uw-2-col larger-left',
      'content-management-menu' => 'uw-full-width layout layout--uw-2-col larger-left',
      'site-management-menu' => 'uw-full-width layout layout--uw-2-col larger-left',
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
    ];
    foreach ($ids as $key => $id) {
      $class = $this->getSession()->getPage()->findById($key)->getParent()->getParent()->getParent()->getAttribute('class');
      $this->assertEquals($id, $class);
    }
    // In section one, the first column is 'web-resources-news', the second is
    // 'recent-content', and the third is 'whos-online'.
    // In section two, the first column is 'content-list' and 'form-list',
    // and the second column is 'content-management-menu' and
    // 'site-management-menu'.
    $section_ids = [
      'web-resources-news' => 'layout__region layout__region--first',
      'recent-content' => 'layout__region layout__region--second',
      'whos-online' => 'layout__region layout__region--third',
      'content-list' => 'layout__region layout__region--first',
      'forms-list' => 'layout__region layout__region--first',
      'content-management-menu' => 'layout__region layout__region--second',
      'site-management-menu' => 'layout__region layout__region--second',
    ];
    foreach ($section_ids as $key => $id) {
      $class = $this->getSession()->getPage()->findById($key)->getParent()->getParent()->getAttribute('class');
      $this->assertEquals($id, $class);
    }
  }

837
838
839
  /**
   * Tests for Custom block CTA.
   */
Igor Biki's avatar
Igor Biki committed
840
  private function ctaBlockTest() {
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
    $this->drupalLogin($this->drupalUsers['administrator']);

    // Test step 1: Visit the home page layout.
    $this->drupalGet('node/1/layout');
    $this->assertSession()->statusCodeEquals(200);

    // Test step 2: Look on the layout edit page to click 'Add block'.
    $this->clickLink('Add block');

    // Test step 3: Verify that cta block and others are on the
    // layout edit page.
    $this->assertSession()->pageTextContains('Choose a block');

    // Test step 4: Look on the page for the 'Call to action' link.
    $this->assertSession()->linkExists('Call to action');

    // Test step 6: Click 'Call to action'.
    $this->clickLink('Call to action');

    // Use random string as cta label, saving for later compare.
    $cta_label = $this->randomString();

    $this->submitForm([
      'edit-settings-label' => 'Block description title',
      'edit-settings-block-form-field-uw-cta-details-0-subform-field-uw-cta-link-0-uri' => '/home',
      'edit-settings-block-form-field-uw-cta-details-0-subform-field-uw-cta-link-0-title' => $this->randomString(),
      'edit-settings-block-form-field-uw-cta-details-0-subform-field-uw-cta-text-details-0-text-value' => $cta_label,
      'edit-settings-block-form-field-uw-cta-details-0-subform-field-uw-cta-theme' => 'org-default',
    ], 'Add block');

    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains($cta_label);
  }
Igor Biki's avatar
Igor Biki committed
874

875
876
877
878
  /**
   * Tests permissions.
   *
   * Site owner role has administer users permission.
Lily Yan's avatar
Lily Yan committed
879
880
881
   * Site owner role has assign roles permission.
   * Configure the role assign to allow assigning
   * all roles except admin and site owner.
882
883
   */
  private function permissionsTest() {
Lily Yan's avatar
Lily Yan committed
884
    // Only administer can access permissions and roleassign pages.
885
    $this->drupalLogin($this->drupalUsers['administrator']);
Lily Yan's avatar
Lily Yan committed
886
887
888
889
890
891
892
893
894
895
896
897
898
    // Check admin/people/roleassign page.
    $this->drupalGet('admin/people/roleassign');
    $this->assertSession()->statusCodeEquals(200);
    // Configure the role assign to allow assigning
    // all roles except admin and site owner.
    $this->assertSession()->checkboxNotChecked('edit-roleassign-roles-administrator');
    $this->assertSession()->checkboxNotChecked('edit-roleassign-roles-uw-role-site-owner');
    $this->assertSession()->checkboxChecked('edit-roleassign-roles-uw-role-site-manager');
    $this->assertSession()->checkboxChecked('edit-roleassign-roles-uw-role-content-editor');
    $this->assertSession()->checkboxChecked('edit-roleassign-roles-uw-role-content-author');
    $this->assertSession()->checkboxChecked('edit-roleassign-roles-uw-role-form-editor');
    $this->assertSession()->checkboxChecked('edit-roleassign-roles-uw-role-form-results-access');
    // Check admin/people/permissions page.
899
900
    $this->drupalGet('admin/people/permissions');
    $this->assertSession()->statusCodeEquals(200);
Lily Yan's avatar
Lily Yan committed
901
902
903
904
905
906
907
908
909
    // Site owner role has administer users.
    $this->assertSession()->checkboxChecked('edit-uw-role-site-owner-administer-users');
    // Only the site owner role assign roles permissions.
    $this->assertSession()->checkboxChecked('edit-uw-role-site-owner-assign-roles');
    $this->assertSession()->checkboxNotChecked('edit-uw-role-site-manager-assign-roles');
    $this->assertSession()->checkboxNotChecked('edit-uw-role-content-editor-assign-roles');
    $this->assertSession()->checkboxNotChecked('edit-uw-role-content-author-assign-roles');
    $this->assertSession()->checkboxNotChecked('edit-uw-role-form-editor-assign-roles');
    $this->assertSession()->checkboxNotChecked('edit-uw-role-form-results-access-assign-roles');
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
    // Check Edit protection rule Authenticated user page.
    $this->drupalGet('admin/config/people/userprotect/manage/uw_protect_authenticated_user');
    $this->assertSession()->statusCodeEquals(200);
    // Get Name field value: Authenticated user.
    $this->getSession()->getPage()->findField('edit-label')->getValue('Authenticated user');
    // Get Role field value: Authenticated user.
    $this->getSession()->getPage()->findById('edit-entity-id')->getValue('Authenticated user');
    // Only status and cancel operation are checked in proection field.
    $this->assertSession()->checkboxChecked('edit-protection-user-status');
    $this->assertSession()->checkboxChecked('edit-protection-user-delete');
    $this->assertSession()->checkboxNotChecked('edit-protection-user-name');
    $this->assertSession()->checkboxNotChecked('edit-protection-user-mail');
    $this->assertSession()->checkboxNotChecked('edit-protection-user-pass');
    $this->assertSession()->checkboxNotChecked('edit-protection-user-roles');
    $this->assertSession()->checkboxNotChecked('edit-protection-user-edit');
    // Only Administrator is checked in Bypass for roles.
    $this->assertSession()->checkboxChecked('edit-bypass-roles-administrator');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-anonymous');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-authenticated');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-uw-role-site-owner');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-uw-role-site-manager');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-uw-role-content-editor');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-uw-role-content-author');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-uw-role-form-editor');
    $this->assertSession()->checkboxNotChecked('edit-bypass-roles-uw-role-form-results-access');

Lily Yan's avatar
Lily Yan committed
936
    // The other users do not have access permissions and roleassign pages.
937
938
939
940
941
942
943
944
945
946
947
948
    $roles = [
      'authenticated user',
      'uw_role_site_manager',
      'uw_role_content_editor',
      'uw_role_content_author',
      'uw_role_form_editor',
      'uw_role_form_results_access',
    ];
    foreach ($roles as $role) {
      $this->drupalLogin($this->drupalUsers[$role]);
      $this->drupalGet('admin/people/permissions');
      $this->assertSession()->statusCodeEquals(403);
Lily Yan's avatar
Lily Yan committed
949
950
      $this->drupalGet('admin/people/roleassign');
      $this->assertSession()->statusCodeEquals(403);
951
952
      $this->drupalGet('admin/config/people/userprotect/manage/uw_protect_authenticated_user');
      $this->assertSession()->statusCodeEquals(403);
953
    }
Lily Yan's avatar
Lily Yan committed
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987

    // Administrator still has access to "status" and "cancel account"
    // options for users with all roles..
    $this->drupalLogin($this->drupalUsers['administrator']);
    $this->drupalGet('admin/people');
    $this->assertSession()->statusCodeEquals(200);
    $this->getSession()->getPage()->clickLink('uw_role_site_owner');
    $this->getSession()->getPage()->clickLink('Edit');
    $this->assertSession()->pageTextContains('Status');
    $this->assertSession()->buttonExists('edit-delete');
    $this->drupalLogout();

    // Site owner oes not have access to "status" and "cancel account"
    // for other users.
    $this->drupalLogin($this->drupalUsers['uw_role_site_owner']);
    $this->drupalGet('admin/people');
    $this->assertSession()->statusCodeEquals(200);
    $this->getSession()->getPage()->clickLink('uw_role_site_manager');
    $this->getSession()->getPage()->clickLink('Edit');
    $this->assertSession()->pageTextContains('has been protected from the following editing operations: Status');
    $this->assertSession()->buttonNotExists('edit-delete');
    $this->drupalLogout();

    // All other roles (e.g. site manager) do not have access
    // to other accounts (e.g. content author).
    $this->drupalLogin($this->drupalUsers['uw_role_site_manager']);
    $this->drupalGet('users/uwrolecontentauthor');
    $this->assertSession()->statusCodeEquals(403);

    // The users are able to change their own account (email and password).
    $this->drupalGet('users/uwrolesitemanager');
    $this->assertSession()->statusCodeEquals(200);
    $this->clickLink('Edit profile');
    $this->assertSession()->statusCodeEquals(200);
988
989
  }

990
}