Commit d7300cc3 authored by catch's avatar catch
Browse files

Issue #3142755 by sja112, mondrake, alexpott, mrinalini9, xjm:...

Issue #3142755 by sja112, mondrake, alexpott, mrinalini9, xjm: AssertLegacyTrait::assert(No)Field() in functional tests still have a message passed in
parent fad8b52c
......@@ -47,9 +47,10 @@ public function openImportForm() {
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->assertText('A single OPML document may contain many feeds.', 'Found OPML help text.');
$this->assertField('files[upload]', 'Found file upload field.');
$this->assertField('remote', 'Found Remote URL field.');
$this->assertField('refresh', '', 'Found Refresh field.');
// Ensure that the file upload, remote URL, and refresh fields exist.
$this->assertField('files[upload]');
$this->assertField('remote');
$this->assertField('refresh');
}
/**
......
......@@ -54,9 +54,10 @@ public function testLanguageBlockVisibility() {
// Check if the visibility setting is available.
$default_theme = $this->config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
$this->assertField('visibility[language][langcodes][en]', 'Language visibility field is visible.');
$this->assertNoField('visibility[language][context_mapping][language]', 'Language type field is not visible.');
// Ensure that the language visibility field is visible without a type
// setting.
$this->assertField('visibility[language][langcodes][en]');
$this->assertNoField('visibility[language][context_mapping][language]');
// Enable a standard block and set the visibility setting for one language.
$edit = [
......@@ -138,8 +139,8 @@ public function testMultipleLanguageTypes() {
// Check if the visibility setting is available with a type setting.
$default_theme = $this->config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
$this->assertField('visibility[language][langcodes][en]', 'Language visibility field is visible.');
$this->assertField('visibility[language][context_mapping][language]', 'Language type field is visible.');
$this->assertField('visibility[language][langcodes][en]');
$this->assertField('visibility[language][context_mapping][language]');
// Enable a standard block and set visibility to French only.
$block_id = strtolower($this->randomMachineName(8));
......
......@@ -121,11 +121,11 @@ public function testBlockAdminUiPage() {
$element = $this->xpath('//*[@id="blocks"]/tbody/tr[' . $values['tr'] . ']/td[1]/text()');
$this->assertEquals($element[0]->getText(), $label, 'The "' . $label . '" block title is set inside the ' . $values['settings']['region'] . ' region.');
// Look for a test block region select form element.
$this->assertField('blocks[' . $values['settings']['id'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.');
$this->assertField('blocks[' . $values['settings']['id'] . '][region]');
// Move the test block to the header region.
$edit['blocks[' . $values['settings']['id'] . '][region]'] = 'header';
// Look for a test block weight select form element.
$this->assertField('blocks[' . $values['settings']['id'] . '][weight]', 'The block "' . $values['label'] . '" has a weight assignment field.');
$this->assertField('blocks[' . $values['settings']['id'] . '][weight]');
// Change the test block's weight.
$edit['blocks[' . $values['settings']['id'] . '][weight]'] = $values['test_weight'];
}
......
......@@ -72,7 +72,8 @@ public function testBookCommentPrint() {
$this->assertText($comment_subject, 'Comment subject found');
$this->assertText($comment_body, 'Comment body found');
$this->assertText(t('Add new comment'), 'Comment form found');
$this->assertField('subject[0][value]', 'Comment form subject found');
// Ensure that the comment form subject field exists.
$this->assertField('subject[0][value]');
$this->drupalGet('book/export/html/' . $book_node->id());
......@@ -81,7 +82,8 @@ public function testBookCommentPrint() {
$this->assertText($comment_body, 'Comment body found');
$this->assertNoText(t('Add new comment'), 'Comment form not found');
$this->assertNoField('subject[0][value]', 'Comment form subject not found');
// Verify that the comment form subject field is not found.
$this->assertNoField('subject[0][value]');
}
}
......@@ -179,21 +179,22 @@ public function testCommentInterface() {
$this->assertNotNull($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertSession()->statusCodeEquals(403);
$this->assertNoField('edit-comment', 'Comment body field found.');
$this->assertNoField('edit-comment');
// Attempt to post to node with read-only comments.
$this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::CLOSED]]]);
$this->assertNotNull($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertSession()->statusCodeEquals(403);
$this->assertNoField('edit-comment', 'Comment body field found.');
$this->assertNoField('edit-comment');
// Attempt to post to node with comments enabled (check field names etc).
$this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::OPEN]]]);
$this->assertNotNull($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertNoText('This discussion is closed', 'Posting to node with comments enabled');
$this->assertField('edit-comment-body-0-value', 'Comment body field found.');
// Ensure that the comment body field exists.
$this->assertField('edit-comment-body-0-value');
// Delete comment and make sure that reply is also removed.
$this->drupalLogout();
......
......@@ -85,7 +85,7 @@ public function testCommentTypeCreation() {
// Edit the comment-type and ensure that we cannot change the entity-type.
$this->drupalGet('admin/structure/comment/manage/foo');
$this->assertNoField('target_entity_type_id', 'Entity type file not present');
$this->assertNoField('target_entity_type_id');
$this->assertText(t('Target entity type'));
// Save the form and ensure the entity-type value is preserved even though
// the field isn't present.
......
......@@ -79,7 +79,7 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-new-state', 'The node view page has a moderation form.');
$this->assertField('edit-new-state');
// The latest version page should not show, because there is no pending
// revision.
......@@ -96,7 +96,7 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-new-state', 'The node view page has a moderation form.');
$this->assertField('edit-new-state');
// Preview the draft.
$this->drupalPostForm($edit_path, [
......@@ -111,7 +111,7 @@ public function testModerationForm() {
]);
$this->assertSession()->statusCodeEquals(200);
$this->assertUrl($preview_url);
$this->assertNoField('edit-new-state', 'The node preview page has no moderation form.');
$this->assertNoField('edit-new-state');
// The latest version page should not show, because there is still no
// pending revision.
......@@ -141,7 +141,7 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertNoField('edit-new-state', 'The node view page has no moderation form.');
$this->assertNoField('edit-new-state');
// The latest version page should not show, because there is still no
// pending revision.
......@@ -158,13 +158,13 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertNoField('edit-new-state', 'The node view page has no moderation form.');
$this->assertNoField('edit-new-state');
// The latest version page should show the moderation form and have "Draft"
// status, because the pending revision is in "Draft".
$this->drupalGet($latest_version_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-new-state', 'The latest-version page has a moderation form.');
$this->assertField('edit-new-state');
$this->assertText('Draft', 'Correct status found on the latest-version page.');
// Submit the moderation form to change status to published.
......
......@@ -123,7 +123,8 @@ public function testFieldFormSingle() {
$token_description = Html::escape($this->config('system.site')->get('name')) . '_description';
$this->assertText($token_description, 'Token replacement for description is displayed');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
$this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[1][value]");
// Check that hook_field_widget_form_alter() does not believe this is the
// default value form.
......@@ -155,7 +156,8 @@ public function testFieldFormSingle() {
// Display edit form.
$this->drupalGet('entity_test/manage/' . $id . '/edit');
$this->assertFieldByName("{$field_name}[0][value]", $value, 'Widget is displayed with the correct default value');
$this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[1][value]");
// Update the entity.
$value = mt_rand(1, 127);
......@@ -265,7 +267,8 @@ public function testFieldFormUnlimited() {
// Display creation form -> 1 widget.
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
$this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[1][value]");
// Check if aria-describedby attribute is placed on multiple value widgets.
$elements = $this->xpath('//table[@id="field-unlimited-values" and @aria-describedby="edit-field-unlimited--description"]');
......@@ -275,7 +278,8 @@ public function testFieldFormUnlimited() {
$this->drupalPostForm(NULL, [], t('Add another item'));
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
$this->assertFieldByName("{$field_name}[1][value]", '', 'New widget is displayed');
$this->assertNoField("{$field_name}[2][value]", 'No extraneous widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[2][value]");
// TODO : check that non-field inputs are preserved ('title'), etc.
// Yet another time so that we can play with more values -> 3 widgets.
......@@ -314,7 +318,8 @@ public function testFieldFormUnlimited() {
$this->assertPattern("|$pattern|s", 'Widgets are displayed in the correct order');
$this->assertFieldByName("{$field_name}[$delta][value]", '', "New widget is displayed");
$this->assertFieldByName("{$field_name}[$delta][_weight]", $delta, "New widget has the right weight");
$this->assertNoField("{$field_name}[" . ($delta + 1) . '][value]', 'No extraneous widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[" . ($delta + 1) . '][value]');
// Submit the form and create the entity.
$this->drupalPostForm(NULL, $edit, t('Save'));
......@@ -411,7 +416,8 @@ public function testFieldFormMultivalueWithRequiredRadio() {
// Verify that the widget is added.
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
$this->assertFieldByName("{$field_name}[1][value]", '', 'New widget is displayed');
$this->assertNoField("{$field_name}[2][value]", 'No extraneous widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[2][value]");
}
/**
......@@ -588,7 +594,7 @@ public function testHiddenField() {
// Create an entity and test that the default value is assigned correctly to
// the field that uses the hidden widget.
$this->assertNoField("{$field_name}[0][value]", 'The field does not appear in the form');
$this->assertNoField("{$field_name}[0][value]");
$this->drupalPostForm(NULL, [], t('Save'));
preg_match('|' . $entity_type . '/manage/(\d+)|', $this->getUrl(), $match);
$id = $match[1];
......
......@@ -353,7 +353,7 @@ private function doAdminTests($user) {
// Test term edit form alterations.
$this->drupalGet('taxonomy/term/' . $this->forumContainer['tid'] . '/edit');
// Test parent field been hidden by forum module.
$this->assertNoField('parent[]', 'Parent field not found.');
$this->assertNoField('parent[]');
// Create a default vocabulary named "Tags".
$description = 'Use tags to group articles on similar topics into categories.';
......
......@@ -37,8 +37,8 @@ public function testUIBrowserLanguageMappings() {
// Check that defaults are loaded from language.mappings.yml.
$this->drupalGet('admin/config/regional/language/detection/browser');
$this->assertField('edit-mappings-zh-cn-browser-langcode', 'zh-cn', 'Chinese browser language code found.');
$this->assertField('edit-mappings-zh-cn-drupal-langcode', 'zh-hans-cn', 'Chinese Drupal language code found.');
$this->assertFieldById('edit-mappings-zh-cn-browser-langcode', 'zh-cn');
$this->assertFieldById('edit-mappings-zh-cn-drupal-langcode', 'zh-hans');
// Delete zh-cn language code.
$browser_langcode = 'zh-cn';
......@@ -60,8 +60,8 @@ public function testUIBrowserLanguageMappings() {
// Check we went back to the browser negotiation mapping overview.
$this->assertUrl(Url::fromRoute('language.negotiation_browser', [], ['absolute' => TRUE])->toString());
// Check that ch-zn no longer exists.
$this->assertNoField('edit-mappings-zh-cn-browser-langcode', 'Chinese browser language code no longer exists.');
// Check that Chinese browser language code no longer exists.
$this->assertNoField('edit-mappings-zh-cn-browser-langcode');
// Add a new custom mapping.
$edit = [
......@@ -70,8 +70,8 @@ public function testUIBrowserLanguageMappings() {
];
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
$this->assertUrl(Url::fromRoute('language.negotiation_browser', [], ['absolute' => TRUE])->toString());
$this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.');
$this->assertField('edit-mappings-xx-drupal-langcode', 'en', 'Drupal language code found.');
$this->assertFieldById('edit-mappings-xx-browser-langcode', 'xx');
$this->assertFieldById('edit-mappings-xx-drupal-langcode', 'en');
// Add the same custom mapping again.
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
......@@ -92,8 +92,8 @@ public function testUIBrowserLanguageMappings() {
];
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
$this->assertUrl(Url::fromRoute('language.negotiation_browser', [], ['absolute' => TRUE])->toString());
$this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.');
$this->assertField('edit-mappings-xx-drupal-langcode', 'zh-hans', 'Drupal language code found.');
$this->assertFieldById('edit-mappings-xx-browser-langcode', 'xx');
$this->assertFieldById('edit-mappings-xx-drupal-langcode', 'zh-hans');
}
}
......@@ -142,7 +142,7 @@ public function testMenuLanguage() {
// Check that the language selector is not available on menu link add page.
$this->drupalGet("admin/structure/menu/manage/$menu_name/add");
$this->assertNoField('edit-langcode-0-value', 'The language selector field was hidden the page');
$this->assertNoField('edit-langcode-0-value');
}
}
......@@ -53,8 +53,9 @@ public function testNodeTypeInitialLanguageDefaults() {
$language_field = $this->xpath('//*[@id="field-overview"]/*[@id="language"]');
$this->assert(empty($language_field), 'Language field is not visible on manage fields tab.');
// Verify that language is not selectable on node add page by default.
$this->drupalGet('node/add/article');
$this->assertNoField('langcode', 'Language is not selectable on node add/edit page by default.');
$this->assertNoField('langcode');
// Adds a new language and set it as default.
$edit = [
......@@ -73,7 +74,9 @@ public function testNodeTypeInitialLanguageDefaults() {
];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->drupalGet('node/add/article');
$this->assertField('langcode[0][value]', 'Language is selectable on node add/edit page when language not hidden.');
// Ensure that the language is selectable on node add page when language
// not hidden.
$this->assertField('langcode[0][value]');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'hu')->isSelected());
// Tests if the language field can be rearranged on the manage form display
......
......@@ -54,13 +54,13 @@ public function testAuthProvidersOptions() {
$this->drupalGet("admin/structure/views/nojs/display/$view_id/$view_display/auth");
// The "basic_auth" will always be available since module,
// providing it, has the same name.
$this->assertField('edit-auth-basic-auth', 'Basic auth is available for choosing.');
$this->assertField('edit-auth-basic-auth');
// The "cookie" authentication provider defined by "user" module.
$this->assertField('edit-auth-cookie', 'Cookie-based auth can be chosen.');
$this->assertField('edit-auth-cookie');
// Wrong behavior in "getAuthOptions()" method makes this option available
// instead of "cookie".
// @see \Drupal\rest\Plugin\views\display\RestExport::getAuthOptions()
$this->assertNoField('edit-auth-user', 'Wrong authentication option is unavailable.');
$this->assertNoField('edit-auth-user');
$this->drupalPostForm(NULL, ['auth[basic_auth]' => 1, 'auth[cookie]' => 1], 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
......
......@@ -37,8 +37,8 @@ public function testConfigForm() {
$article->save();
$this->drupalGet('condition_test');
$this->assertField('bundles[article]', 'There is an article bundle selector.');
$this->assertField('bundles[page]', 'There is a page bundle selector.');
$this->assertField('bundles[article]');
$this->assertField('bundles[page]');
$this->drupalPostForm(NULL, ['bundles[page]' => 'page', 'bundles[article]' => 'article'], t('Submit'));
// @see \Drupal\condition_test\FormController::submitForm()
$this->assertText('Bundle: page');
......
......@@ -54,7 +54,7 @@ public function testLanguageSelectElementOptions() {
'edit-languages-config-and-locked' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED,
];
foreach ($ids as $id => $flags) {
$this->assertField($id, new FormattableMarkup('The @id field was found on the page.', ['@id' => $id]));
$this->assertField($id);
$options = [];
/* @var $language_manager \Drupal\Core\Language\LanguageManagerInterface */
$language_manager = $this->container->get('language_manager');
......@@ -65,7 +65,7 @@ public function testLanguageSelectElementOptions() {
}
// Test that the #options were not altered by #languages.
$this->assertField('edit-language-custom-options', new FormattableMarkup('The @id field was found on the page.', ['@id' => 'edit-language-custom-options']));
$this->assertField('edit-language-custom-options');
$this->_testLanguageSelectElementOptions('edit-language-custom-options', ['opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option']);
}
......@@ -82,7 +82,7 @@ public function testHiddenLanguageSelectElement() {
// Check that the language fields were rendered on the page.
$ids = ['edit-languages-all', 'edit-languages-configurable', 'edit-languages-locked', 'edit-languages-config-and-locked'];
foreach ($ids as $id) {
$this->assertNoField($id, new FormattableMarkup('The @id field was not found on the page.', ['@id' => $id]));
$this->assertNoField($id);
}
// Check that the submitted values were the default values of the language
......
......@@ -58,13 +58,13 @@ public function testMainContentFallback() {
// Drupal should fall back to SimplePageVariant. Both for the admin and the
// front-end theme.
$this->drupalGet('admin/config/system/site-information');
$this->assertField('site_name', 'Fallback to SimplePageVariant works for admin theme.');
$this->assertField('site_name');
$this->drupalGet('system-test/main-content-fallback');
$this->assertText(t('Content to test main content fallback'), 'Fallback to SimplePageVariant works for front-end theme.');
// Request a user* page and see if it is displayed.
$this->drupalLogin($this->webUser);
$this->drupalGet('user/' . $this->webUser->id() . '/edit');
$this->assertField('mail', 'User interface still available.');
$this->assertField('mail');
// Enable the block module again.
$this->drupalLogin($this->adminUser);
......
......@@ -54,7 +54,7 @@ public function testTermLanguage() {
// Add a term.
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
// Check that we have the language selector.
$this->assertField('edit-langcode-0-value', t('The language selector field was found on the page.'));
$this->assertField('edit-langcode-0-value');
// Submit the term.
$edit = [
'name[0][value]' => $this->randomMachineName(),
......
......@@ -44,7 +44,7 @@ public function testVocabularyLanguage() {
$this->drupalGet('admin/structure/taxonomy/add');
// Check that we have the language selector available.
$this->assertField('edit-langcode', 'The language selector field was found on the page.');
$this->assertField('edit-langcode');
// Create the vocabulary.
$vid = mb_strtolower($this->randomMachineName());
......
......@@ -236,7 +236,7 @@ public function testVocabularyPermissionsTaxonomyTerm() {
// Visit the main taxonomy administration page.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-name-0-value', 'Add taxonomy term form opened successfully.');
$this->assertField('edit-name-0-value');
// Submit the term.
$edit = [];
......
......@@ -39,7 +39,7 @@ public function testVocabularyLanguage() {
$this->drupalGet('admin/structure/taxonomy/add');
// Check that the field to enable content translation is available.
$this->assertField('edit-default-language-content-translation', 'The content translation checkbox is present on the page.');
$this->assertField('edit-default-language-content-translation');
// Create the vocabulary.
$vid = mb_strtolower($this->randomMachineName());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment