Commit c40f7f54 authored by Liam Morland's avatar Liam Morland
Browse files

Merge branch 'feature/ISTWCMS-4535-l26yan-Update-tests-with-deprecated-methods' into '3.0.x'

ISTWCMS-4535 Update tests with deprecated methods

See merge request !237
parents ab8dc593 ffbcd1ed
......@@ -151,13 +151,15 @@ class UwWcmsBasicTest extends BrowserTestBase {
// 'Slide speed' is required.
$slide_speed_required = $this->getSession()->getPage()->find('xpath', "//label[contains(text(), 'Slide speed')]");
$this->assertEquals('js-form-required form-required', $slide_speed_required->getAttribute('class'));
$this->assertFieldByXPath('//input[@value="7000" and @name="settings[block_form][field_uw_slide_speed][0][value]"]', NULL, 'Default value is 7000ms.');
// The default value of 'Slide speed' is 7000ms.
$this->assertTrue((bool) $this->xpath('//input[@value="7000" and @name="settings[block_form][field_uw_slide_speed][0][value]"]'), '7000 ms is selected.');
$this->assertSession()->pageTextContains('Enter the time, in milliseconds, that should elapse between slides when the slideshow is playing.');
// 'Transition speed' is required.
$slide_speed_required = $this->getSession()->getPage()->find('xpath', "//label[contains(text(), 'Transition speed')]");
$this->assertEquals('js-form-required form-required', $slide_speed_required->getAttribute('class'));
$this->assertFieldByXPath('//input[@value="400" and @name="settings[block_form][field_uw_transition_speed][0][value]"]', NULL, 'Default value is 400ms.');
// The default value of 'Transition speed' is 400ms.
$this->assertTrue((bool) $this->xpath('//input[@value="400" and @name="settings[block_form][field_uw_transition_speed][0][value]"]'), '400 ms is selected.');
$this->assertSession()->pageTextContains('Enter the time, in milliseconds, the banner transition should take to complete.');
// Autoplay is checked by default.
......@@ -176,10 +178,11 @@ class UwWcmsBasicTest extends BrowserTestBase {
];
$options = $this->getOptions('settings[block_form][field_uw_text_overlay_style]');
foreach ($expected_options as $key => $expected_option) {
$this->assertEqual($options[$key], $expected_option);
$this->assertEquals($options[$key], $expected_option);
}
// Full banner is selected as default.
$this->assertFieldByXPath('//option[@value="full-width" and @selected="selected"]', NULL, 'Full banner width, bottom, theme colour background ("FDSU" style) is selected.');
// Full banner width, bottom, theme colour background
// ("FDSU" style) is selected as default.
$this->assertTrue((bool) $this->xpath('//option[@value="full-width" and @selected="selected"]'), 'Full banner width, bottom, theme colour background ("FDSU" style) is selected as default.');
$this->assertSession()->pageTextContains('Note that all options other than "FDSU" style are unsupported at this time, and are provided for future use.');
// Click 'Add Image banner'.
......@@ -257,17 +260,19 @@ class UwWcmsBasicTest extends BrowserTestBase {
'title' => 'Test Form',
'status' => 'open',
];
$this->drupalPostForm('admin/structure/webform/add', $edit, 'Save');
$this->drupalGet('admin/structure/webform/add');
$this->submitForm($edit, 'Save');
// Test for existence Webform CAPTCHA component on newly-created Webform.
$this->assertFieldByXPath('//table[@id="edit-webform-ui-elements"]/tbody/tr[@data-webform-type="captcha"]', NULL, 'CAPTCHA component exists.');
$this->assertTrue((bool) $this->xpath('//table[@id="edit-webform-ui-elements"]/tbody/tr[@data-webform-type="captcha"]'), 'CAPTCHA component exists.');
// Save the access page. If a form is altered by unsetting parts of it
// instead of setting #access, empty access values will be saved leading to
// access issues later. Save the page here to verify that no access values
// get changed.
$edit = [];
$this->drupalPostForm('admin/structure/webform/manage/test_form/access', $edit, 'Save');
$this->drupalGet('admin/structure/webform/manage/test_form/access');
$this->submitForm($edit, 'Save');
// The variable $test_paths stores Drupal paths and permission information.
// In this array, the keys are paths. If the value is TRUE, everyone has
......@@ -335,7 +340,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
$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);
$this->assertTrue(intval($this_code) === $expected_code, $message);
if ($path === 'form/test-form' && !$this->loggedInUser) {
// Test for Honeypot element.
......@@ -424,7 +429,8 @@ class UwWcmsBasicTest extends BrowserTestBase {
}
foreach ($edits as $content_type => $items) {
foreach ($items as $item) {
$this->drupalPostForm('node/add/uw_ct_' . $content_type, $item, 'Save');
$this->drupalGet('node/add/uw_ct_' . $content_type);
$this->submitForm($item, 'Save');
}
}
......@@ -463,10 +469,10 @@ class UwWcmsBasicTest extends BrowserTestBase {
foreach ($rows as $key => $row) {
preg_match("/\d{4}\-\d{2}-\d{2}/", $row->getText(), $matches);
if ($view == 'events') {
$this->assertEqual($matches[0], $expected_dates[$key]);
$this->assertEquals($matches[0], $expected_dates[$key]);
}
else {
$this->assertEqual($matches[0], $expected_date_fields[$key]);
$this->assertEquals($matches[0], $expected_date_fields[$key]);
}
}
}
......@@ -512,9 +518,9 @@ class UwWcmsBasicTest extends BrowserTestBase {
}
if ($key === 'event') {
$this->assertFieldByXPath('//select[@id="edit-location-presets-select"]', NULL, 'Location lookup menu exists.');
$this->assertTrue((bool) $this->xpath('//select[@id="edit-location-presets-select"]'), 'Location lookup menu exists.');
// Test field_uw_event_map exists.
$this->assertFieldByXPath('//input[@type="url" and @id="edit-field-uw-event-map-0-uri"]', NULL, 'Map link field exists.');
$this->assertTrue((bool) $this->xpath('//input[@type="url" and @id="edit-field-uw-event-map-0-uri"]'), 'Map link field exists.');
$this->assertSession()->pageTextContains('Optional: provide a link to a map with the event location (e.g. https://uwaterloo.ca/map/)');
}
}
......@@ -523,7 +529,8 @@ class UwWcmsBasicTest extends BrowserTestBase {
$edit = [
'edit-name-0-value' => $this->randomString(),
];
$this->drupalPostForm('admin/structure/taxonomy/manage/uw_vocab_catalogs/add', $edit, $this->t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_catalogs/add');
$this->submitForm($edit, 'Save');
// Array of content types.
// Keys: Content types.
......@@ -564,7 +571,8 @@ class UwWcmsBasicTest extends BrowserTestBase {
$edit[$field] = $this->randomString();
}
}
$this->drupalPostForm('node/add/' . $content_type, $edit, 'Save');
$this->drupalGet('node/add/' . $content_type);
$this->submitForm($edit, 'Save');
// Make sure no 'Revert to default' on the above content type layout page.
$this->assertSession()->buttonNotExists('Revert to defaults');
// Make sure 'Clone' tab not exist for site footer content type.
......@@ -581,7 +589,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
$nid = $this->xpath('//a[text() = "View"]');
preg_match('/^node\/(\d+)$/', $nid[0]->getAttribute('data-drupal-link-system-path'), $matches);
$nid = (int) $matches[1];
$this->assert($nid > 0, 'Positive nid found.');
$this->assertTrue($nid > 0, 'Positive nid found.');
$content_nids[$content_type] = $nid;
// On node creation, the user is redirected to the layout edit page.
......@@ -623,13 +631,15 @@ class UwWcmsBasicTest extends BrowserTestBase {
// The title defaults via JS to the page title. Specify since no JS.
'menu[title]' => $title,
];
$this->drupalPostForm($url, $edit, 'Save');
$this->drupalGet($url);
$this->submitForm($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($url);
$this->submitForm($edit, 'Save');
$this->drupalGet('admin/structure/menu/manage/main');
$this->assertSession()->pageTextContains($title . ' (disabled)');
......@@ -651,7 +661,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->drupalGet('node/add/uw_ct_site_footer');
$match = preg_match(',site-footer/[^/]+/edit$,', $this->getSession()->getCurrentUrl());
$this->assert($match, 'Node add page for site footer redirects to edit page when a footer already exists.');
$this->assertTrue($match, 'Node add page for site footer redirects to edit page when a footer already exists.');
// Test uw_ct_sidebar. There is no title in the content type, only a node
// reference field.
......@@ -660,7 +670,8 @@ class UwWcmsBasicTest extends BrowserTestBase {
// 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');
$this->drupalGet('node/add/uw_ct_sidebar');
$this->submitForm($edit, 'Save');
// Make sure no 'Revert to defaults' button on sidebar layout page.
$this->assertSession()->buttonNotExists('Revert to defaults');
// Make sure 'Clone' tab exist for sidebar content type.
......@@ -688,7 +699,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
$url = $this->getSession()->getCurrentUrl();
// Check that moderation form URL is in the expected format.
$match = preg_match(',/admin/uw-content-moderation/\d+/\d+/\d+$,', $url);
$this->assert($match, 'Moderation form URL is in the expected format.');
$this->assertTrue($match, 'Moderation form URL is in the expected format.');
// Load home page edit page.
$this->drupalGet('home/edit');
......@@ -702,7 +713,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
// UWService::nodeIsHomePage().
$this->drupalLogin($this->drupalUsers['uw_role_site_manager']);
$this->assert(!UWService::nodeIsHomePage($content_nids['uw_ct_web_page']), 'UWService::nodeIsHomePage() correctly identifies page as not the home page.');
$this->assertTrue(!UWService::nodeIsHomePage($content_nids['uw_ct_web_page']), 'UWService::nodeIsHomePage() correctly identifies page as not the home page.');
// Test that certain options are available when not editing home page.
$this->drupalGet('node/' . $content_nids['uw_ct_web_page'] . '/edit');
......@@ -722,7 +733,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
$path = \Drupal::service('path_alias.manager')->getAliasByPath('/node/' . $content_nids['uw_ct_web_page']);
\Drupal::service('config.factory')->getEditable('system.site')->set('page.front', $path)->save();
$this->assert(UWService::nodeIsHomePage($content_nids['uw_ct_web_page']), 'UWService::nodeIsHomePage() correctly identifies page as the home page.');
$this->assertTrue(UWService::nodeIsHomePage($content_nids['uw_ct_web_page']), 'UWService::nodeIsHomePage() correctly identifies page as the home page.');
// Test that certain options are not available when editing home page.
$this->drupalGet('node/' . $content_nids['uw_ct_web_page'] . '/edit');
......@@ -794,9 +805,9 @@ class UwWcmsBasicTest extends BrowserTestBase {
$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()->fieldNotExists('edit-path-0-pathauto');
$this->assertSession()->pageTextNotContains('URL alias');
$this->assertNoFieldById('edit-path-0-alias');
$this->assertSession()->fieldNotExists('edit-path-0-alias');
}
}
......@@ -837,8 +848,8 @@ class UwWcmsBasicTest extends BrowserTestBase {
$tvi = $this->getSession()->getPage()->find('xpath', "//span[contains(text(), 'Taxonomy Views Integrator Settings')]");
$this->assertEquals('edit-tvi', $tvi->getParent()->getParent()->getAttribute('id'));
$this->assertSession()->checkboxChecked('edit-tvi-enable-override');
$this->assertOptionSelected('edit-tvi-view', 'uw_view_catalog_show_nodes');
$this->assertOptionSelected('edit-tvi-view-display', 'catalog_a_z_page');
$this->assertSession()->optionExists('edit-tvi-view', 'uw_view_catalog_show_nodes')->isSelected();
$this->assertSession()->optionExists('edit-tvi-view-display', 'catalog_a_z_page')->isSelected();
$this->assertSession()->checkboxChecked('tvi-inherit-check');
$this->assertSession()->checkboxChecked('tvi-pass-arguments');
......@@ -853,7 +864,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
'List (text)',
];
foreach ($expected_items as $key => $value) {
$this->assertEqual($elements[$key]->getText(), $value);
$this->assertEquals($elements[$key]->getText(), $value);
}
// Make sure 'Tabs to display' field in creating catalog term.
......@@ -888,13 +899,15 @@ class UwWcmsBasicTest extends BrowserTestBase {
'edit-name-0-value' => $this->randomString(),
];
// Create a catalog term based on the above catalog term name.
$this->drupalPostForm('admin/structure/taxonomy/manage/uw_vocab_catalogs/add', $edit, $this->t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_catalogs/add');
$this->submitForm($edit, 'Save');
// 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.
$this->drupalPostForm('admin/structure/taxonomy/manage/uw_vocab_catalog_categories/add', $edit, $this->t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_catalog_categories/add');
$this->submitForm($edit, 'Save');
// Prepare $edit for catalog item node.
$edit = [
'edit-title-0-value' => $this->randomString(),
......@@ -902,7 +915,8 @@ class UwWcmsBasicTest extends BrowserTestBase {
'edit-moderation-state-0-state' => 'uw_wf_needs_review',
];
// Create a catalog item node.
$this->drupalPostForm('node/add/uw_ct_catalog_item', $edit, 'Save');
$this->drupalGet('node/add/uw_ct_catalog_item');
$this->submitForm($edit, 'Save');
}
$this->drupalLogin($this->drupalUsers['uw_role_site_manager']);
// Create the first taxonomy term which the vocab is
......@@ -910,13 +924,15 @@ class UwWcmsBasicTest extends BrowserTestBase {
$editCatalog = [
'edit-name-0-value' => $this->randomMachineName(),
];
$this->drupalPostForm('admin/structure/taxonomy/manage/uw_vocab_catalogs/add', $editCatalog, $this->t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_catalogs/add');
$this->submitForm($editCatalog, 'Save');
// Create the second taxonomy term which the vocab is
// category and the tid should be 36.
$editCategory = [
'edit-name-0-value' => 'apple',
];
$this->drupalPostForm('admin/structure/taxonomy/manage/uw_vocab_catalog_categories/add', $editCategory, $this->t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/uw_vocab_catalog_categories/add');
$this->submitForm($editCategory, 'Save');
// Prepare $editNode for creating a catalog item node.
// Use tid=35 as catalog term and tid=36 (apple) as category term.
......@@ -929,7 +945,8 @@ class UwWcmsBasicTest extends BrowserTestBase {
'edit-moderation-state-0-state' => 'uw_wf_needs_review',
];
// Create a catalog item node with needs review.
$this->drupalPostForm('node/add/uw_ct_catalog_item', $editNode, 'Save');
$this->drupalGet('node/add/uw_ct_catalog_item');
$this->submitForm($editNode, 'Save');
// Check node title.
$this->assertSession()->pageTextContains('Edit layout for Test catalog item');
// Check that there is no moderation form.
......@@ -962,7 +979,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
// Make sure Metatags display extender is enabled.
$views_display_extender_settings = \Drupal::config('views.settings')->get('display_extenders');
$this->assert(in_array('metatag_display_extender', $views_display_extender_settings), 'The metatags display extender is expected to be enabled.');
$this->assertTrue(in_array('metatag_display_extender', $views_display_extender_settings), 'The metatags display extender is expected to be enabled.');
}
/**
......@@ -990,88 +1007,88 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->assertSession()->statusCodeEquals(200);
// 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');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-blog-0-basic');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-blog-0-advanced');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-blog-0-open-graph');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-blog-0-twitter-cards');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-article');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-event');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-organization');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-person');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-service');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-blog-0-schema-web-page');
// 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');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-basic');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-advanced');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-open-graph');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-twitter-cards');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-web-page');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-article');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-event');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-organization');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-person');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-catalog-item-0-schema-service');
// Make sure content contact some are checked, and some are not.
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-basic');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-advanced');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-open-graph');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-twitter-cards');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-person');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-article');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-event');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-organization');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-service');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-web-page');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-contact-0-basic');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-contact-0-advanced');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-contact-0-open-graph');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-contact-0-twitter-cards');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-person');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-article');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-event');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-organization');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-service');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-contact-0-schema-web-page');
// 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');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-event-0-basic');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-event-0-advanced');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-event-0-open-graph');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-event-0-twitter-cards');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-event');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-article');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-organization');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-person');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-event-0-schema-service');
$this->assertSession()->checkboxNotChecked('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');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-news-item-0-basic');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-news-item-0-advanced');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-news-item-0-open-graph');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-news-item-0-twitter-cards');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-article');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-event');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-organization');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-person');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-service');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-news-item-0-schema-web-page');
// Make sure content profile some are checked, and some are not.
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-basic');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-advanced');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-open-graph');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-twitter-cards');
$this->assertFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-person');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-article');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-event');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-organization');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-service');
$this->assertNoFieldChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-web-page');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-profile-0-basic');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-profile-0-advanced');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-profile-0-open-graph');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-profile-0-twitter-cards');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-person');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-article');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-event');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-organization');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-profile-0-schema-service');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-profile-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');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-web-page-0-basic');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-web-page-0-advanced');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-web-page-0-open-graph');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-web-page-0-twitter-cards');
$this->assertSession()->checkboxChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-web-page');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-article');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-event');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-organization');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-person');
$this->assertSession()->checkboxNotChecked('edit-entity-type-groups-node-uw-ct-web-page-0-schema-service');
// Make sure meta tag info fields exist when
// add a node of the given content type.
......@@ -1079,7 +1096,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
foreach ($types as $type) {
$this->drupalGet('node/add/' . $type);
$this->assertSession()->statusCodeEquals(200);
$this->assertFieldById('edit-field-uw-meta-description-0-value');
$this->assertSession()->fieldExists('edit-field-uw-meta-description-0-value');
$this->assertSession()->buttonExists('edit-field-uw-meta-image-open-button');
}
}
......@@ -1157,7 +1174,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
// Test that the CodePen block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//div[@class="uw-codepen"]/div[
$this->xpath('//div[@class="uw-codepen"]/div[
@class="codepen"
and @data-height="' . $edit['edit-settings-block-form-field-codepen-pixel-height-0-value'] . '"
and @data-theme-id="dark"
......@@ -1167,7 +1184,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
and @data-pen-title="' . $edit['edit-settings-block-form-field-codepen-displayed-title-0-value'] . '"
and @data-preview="true"
]/a[@href="https://codepen.io/' . $edit['edit-settings-block-form-field-codepen-username-0-value'] . '/pen/' . $edit['edit-settings-block-form-field-codepen-id-0-value'] . '/"]');
$this->assertFieldByXPath('//div[@class="uw-codepen"]/script[@src="https://static.codepen.io/assets/embed/ei.js"]');
$this->assertTrue((bool) $this->xpath('//div[@class="uw-codepen"]/script[@src="https://static.codepen.io/assets/embed/ei.js"]'));
break;
case 'Google Maps':
......@@ -1181,13 +1198,13 @@ class UwWcmsBasicTest extends BrowserTestBase {
// Test that the Google Maps block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//div[@class="uw-google-maps"]/div[text()="Enable JavaScript to view map."]');
$this->assertFieldByXPath('//div[@class="uw-google-maps"]/iframe[@height="' . $edit['edit-settings-block-form-field-gmaps-height-0-value'] . '" and @src="' . $edit['edit-settings-block-form-field-gmaps-embedded-url-0-uri'] . '"]');
$this->assertTrue((bool) $this->xpath('//div[@class="uw-google-maps"]/div[text()="Enable JavaScript to view map."]'));
$this->assertTrue((bool) $this->xpath('//div[@class="uw-google-maps"]/iframe[@height="' . $edit['edit-settings-block-form-field-gmaps-height-0-value'] . '" and @src="' . $edit['edit-settings-block-form-field-gmaps-embedded-url-0-uri'] . '"]'));
break;
case 'Multi-type list':
$this->assertField('edit-settings-show-all-items');
$this->assertField('edit-settings-show-view-all');
$this->assertSession()->fieldExists('edit-settings-show-all-items');
$this->assertSession()->fieldExists('edit-settings-show-view-all');
break;
case 'PowerBI':
......@@ -1200,7 +1217,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
// Test that the PowerBI block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//div[@class="uw-powerbi"]/iframe[@src="' . $edit['edit-settings-block-form-field-uw-powerbi-url-0-value'] . '"]');
$this->assertTrue((bool) $this->xpath('//div[@class="uw-powerbi"]/iframe[@src="' . $edit['edit-settings-block-form-field-uw-powerbi-url-0-value'] . '"]'));
break;
case 'Related links':
......@@ -1225,10 +1242,10 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
// Internal link.
$xpath_prefix = '//div[contains(@class, "block-inline-blockuw-cbl-related-links")]/div[@class="item-list"]/ul/li';
$this->assertFieldByXPath($xpath_prefix . '/a[@href="' . base_path() . 'home" and text()="Home"]');
$this->assertTrue((bool) $this->xpath($xpath_prefix . '/a[@href="' . base_path() . 'home" and text()="Home"]'));
$this->assertSession()->pageTextNotContains($edit['edit-settings-block-form-field-uw-rl-related-link-0-title']);
// External link.
$this->assertFieldByXPath($xpath_prefix . '/a[@href="' . $edit['edit-settings-block-form-field-uw-rl-related-link-1-uri'] . '" and text()="' . $edit['edit-settings-block-form-field-uw-rl-related-link-1-title'] . '"]');
$this->assertTrue((bool) $this->xpath($xpath_prefix . '/a[@href="' . $edit['edit-settings-block-form-field-uw-rl-related-link-1-uri'] . '" and text()="' . $edit['edit-settings-block-form-field-uw-rl-related-link-1-title'] . '"]'));
unset($xpath_prefix);
break;
......@@ -1246,12 +1263,12 @@ class UwWcmsBasicTest extends BrowserTestBase {
// Test that the appropriate Tableau block markup appears on the page.
$this->assertSession()->pageTextContains($edit['edit-settings-label']);
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="host_url" and @value="https://public.tableau.com/"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="site_root" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-site-name-0-value'] . '"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="name" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-tableau-name-0-value'] . '"]');
$this->assertFieldByXPath('//object[@class="tableauViz"]/param[@name="tabs" and @value="yes"]');
$this->assertFieldByXPath('//div[@class="uw-tableau__wrapper"]/script');
$this->assertRaw("vizElement.style.height = '" . $edit['edit-settings-block-form-field-uw-tbl-tableau-height-0-value'] . "px';");
$this->assertTrue((bool) $this->xpath('//object[@class="tableauViz"]/param[@name="host_url" and @value="https://public.tableau.com/"]'));
$this->assertTrue((bool) $this->xpath('//object[@class="tableauViz"]/param[@name="site_root" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-site-name-0-value'] . '"]'));
$this->assertTrue((bool) $this->xpath('//object[@class="tableauViz"]/param[@name="name" and @value="' . $edit['edit-settings-block-form-field-uw-tbl-tableau-name-0-value'] . '"]'));
$this->assertTrue((bool) $this->xpath('//object[@class="tableauViz"]/param[@name="tabs" and @value="yes"]'));
$this->assertTrue((bool) $this->xpath('//div[@class="uw-tableau__wrapper"]/script'));
$this->assertSession()->responseContains("vizElement.style.height = '" . $edit['edit-settings-block-form-field-uw-tbl-tableau-height-0-value'] . "px';");
break;
}
}
......@@ -1278,15 +1295,15 @@ class UwWcmsBasicTest extends BrowserTestBase {
// Test timeline Step 7: Check all fields and buttons of timeline block.
$this->assertSession()->pageTextContains('Title');
$this->assertFieldById('edit-settings-label');
$this->assertSession()->fieldExists('edit-settings-label');
$this->assertSession()->pageTextContains('Timeline style');
$this->assertFieldById('edit-settings-block-form-field-uw-timeline-style');
$this->assertSession()->fieldExists('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()->fieldExists('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()->fieldExists('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()->fieldExists('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');
......@@ -1308,9 +1325,9 @@ class UwWcmsBasicTest extends BrowserTestBase {
// 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');
$this->assertSession()->checkboxChecked('edit-preview-mode-0');
$this->assertSession()->checkboxNotChecked('edit-preview-mode-1');
$this->assertSession()->checkboxNotChecked('edit-preview-mode-2');
$types = $this->getContentTypes();
foreach ($types as $type) {
......@@ -1528,7 +1545,7 @@ class UwWcmsBasicTest extends BrowserTestBase {
*/
private function dashboardTest() {
// Used by dropbutton test.
$layout_link_xpath = $this->buildXPathQuery('//ul[@class=:class]/li/a[contains(@href, :href)]', [
$layout_link_xpath = $this->assertSession()->buildXPathQuery('//ul[@class=:class]/li/a[contains(@href, :href)]', [
':class' => 'dropbutton',
':href' => '/home/layout',
]);
......@@ -1734,12 +1751,12 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->clickLink('Add block');
$this->clickLink('Facts and figures');
// The top-level remove button doesn't exist.
$this->assertNoFieldByName('settings_block_form_field_uw_ff_fact_figure_0_remove');
$this->assertSession()->buttonNotExists('settings_block_form_field_uw_ff_fact_figure_0_remove');
// Check 'Default background colour' field help text.
$this->assertSession()->pageTextContains('When gold is selected, the default colour will always be black.');
// Check 'Default background colour' field default value.
$this->assertFieldByXPath('//option[@value="grey" and @selected="selected"]', NULL, 'Grey is selected.');
$this->assertFieldByName('settings[block_form][field_uw_ff_fact_figure][0][subform][field_uw_ff_def_color]');
$this->assertTrue((bool) $this->xpath('//option[@value="grey" and @selected="selected"]'));
$this->assertSession()->fieldExists('settings[block_form][field_uw_ff_fact_figure][0][subform][field_uw_ff_def_color]');
// Select 'gold', then 'Default background colour' field is gone.
$this->getSession()->getPage()->selectFieldOption('settings[block_form][field_uw_ff_fact_figure][0][subform][field_uw_ff_dbg_color]', 'gold');
$this->assertTrue($this->assertSession()->optionExists('Default background colour', 'gold')->isSelected());
......@@ -1749,9 +1766,9 @@ class UwWcmsBasicTest extends BrowserTestBase {