Problem/Motivation

Some of the current calls to AssertLegacyTrait::assert(No)Field() in functional tests still have a message passed in, even if the methods do not take that in. We need to remove the messages from the calls and inline them as comments where appropriate.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

Ramya Balasubramanian’s picture

Assigned: Unassigned » Ramya Balasubramanian
Ramya Balasubramanian’s picture

Assigned: Ramya Balasubramanian » Unassigned
sja112’s picture

Assigned: Unassigned » sja112
sja112’s picture

Assigned: sja112 » Unassigned
Status: Active » Needs review
FileSize
43.77 KB

Status: Needs review » Needs work

The last submitted patch, 5: 3142755-5.patch, failed testing. View results

sja112’s picture

Assigned: Unassigned » sja112
sja112’s picture

Assigned: sja112 » Unassigned
Status: Needs work » Needs review
FileSize
32.21 KB
11.56 KB

EntityViewsDataTest contains its own assertField method. That's why the test was failing.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

LGTM, thank you.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Nice work -- thank you. Just a few suggestions and grammar fixes:

  1. +++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
    @@ -42,9 +42,12 @@ public function openImportForm() {
    +    // Ensure that the file upload field exists.
    +    $this->assertField('files[upload]');
    +    // Ensure that the remote URL field exists.
    +    $this->assertField('remote');
    +    // Ensure that the refresh field exists.
    +    $this->assertField('refresh');
    

    I'd just add one comment above this hunk that says "Ensure that the file upload, remote URL, and refresh fields exist."

  2. +++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
    @@ -181,21 +181,24 @@ public function testCommentInterface() {
    +    // Verify that the comment body field is found.
    +    $this->assertNoField('edit-comment');
    

    It's asserting the opposite. :) I think we can just drop the message here; no comment needed.

  3. +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
    @@ -85,7 +85,8 @@ public function testCommentTypeCreation() {
    +    // Verify that the entity type file is not present.
    +    $this->assertNoField('target_entity_type_id');
    

    I think we can just drop this one as well (what is an entity type file?).

  4. +++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
    @@ -34,8 +34,10 @@ public function testUIBrowserLanguageMappings() {
    +    // Verify that the Chinese browser language code found.
    ...
    +    // Verify that the Chinese Drupal language code found.
    
    @@ -67,8 +69,10 @@ public function testUIBrowserLanguageMappings() {
    +    // Verify that the browser language code found.
    ...
    +    // Verify that the Drupal language code found.
    
    @@ -89,8 +93,10 @@ public function testUIBrowserLanguageMappings() {
    +    // Verify that browser language code found.
    ...
    +    // Verify that Drupal language code found.
    

    These comments are missing the verb (is found). Edit: Also needs to be the browser language code and the Drupal language code for the last two.

  5. +++ b/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php
    @@ -46,8 +46,9 @@ public function testNodeTypeInitialLanguageDefaults() {
    +    // Verify that language is not selectable on node add/edit page by default.
    
    @@ -66,7 +67,9 @@ public function testNodeTypeInitialLanguageDefaults() {
    +    // Ensure that the language is selectable on node add/edit page when
    +    // language not hidden.
    

    These two are missing an article (the node add page). Also it's only checking the node add page, not the node edit page.

  6. +++ b/core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php
    @@ -37,8 +37,10 @@ public function testConfigForm() {
    +    // Verify that there is an article bundle selector.
    +    $this->assertField('bundles[article]');
    +    // Verify that there is a page bundle selector.
    +    $this->assertField('bundles[page]');
    

    I think we can drop the comments here as well.

sja112’s picture

Assigned: Unassigned » sja112
sja112’s picture

Assigned: sja112 » Unassigned
Status: Needs work » Needs review
FileSize
31.88 KB
7.28 KB

@xjm, thanks for the review.

I have changed the patch as per your suggestions.

ketikagrover’s picture

As per the #10 xjm suggestions changes are updated in the #12
I checked these changes on local via applying patch and it seems good to me.
Moving this to RTBC
Thanks

ketikagrover’s picture

Status: Needs review » Reviewed & tested by the community
ketikagrover’s picture

  $this->assertNoField('target_entity_type_id');
  $this->assertField('bundles[page]');
 $this->assertField('refresh');
  $this->assertField('bundles[page]');
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
@@ -34,8 +34,10 @@ public function testUIBrowserLanguageMappings() {
-    $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.');
+    // Verify that the Chinese browser language code is found.
+    $this->assertField('edit-mappings-zh-cn-browser-langcode');
+    // Verify that the Chinese Drupal language code is found.
+    $this->assertField('edit-mappings-zh-cn-drupal-langcode');

@@ -67,8 +69,10 @@ public function testUIBrowserLanguageMappings() {
-    $this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.');
-    $this->assertField('edit-mappings-xx-drupal-langcode', 'en', 'Drupal language code found.');
+    // Verify that the browser language code is found.
+    $this->assertField('edit-mappings-xx-browser-langcode');
+    // Verify that the Drupal language code is found.
+    $this->assertField('edit-mappings-xx-drupal-langcode');
 

@@ -89,8 +93,10 @@ public function testUIBrowserLanguageMappings() {
-    $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.');
+    // Verify that browser language code is found.
+    $this->assertField('edit-mappings-xx-browser-langcode');
+    // Verify that Drupal language code is found.
+    $this->assertField('edit-mappings-xx-drupal-langcode');

I think the original test author meant to assertFieldValue() - let's see what happens when we change this.

alexpott’s picture

Status: Needs work » Needs review
FileSize
2.52 KB
34.45 KB

Yep and one of them we not as expected - at least now the test makes sense.

mrinalini9’s picture

Rerolled patch #17 as it failed to apply, please review.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Removes messages that are irrelevant now, and fixes a few assertions that were not asserting what they should.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Needs a re-roll.

mondrake’s picture

mondrake’s picture

FileSize
2.08 KB

  • catch committed d7300cc on 9.1.x
    Issue #3142755 by sja112, mondrake, alexpott, mrinalini9, xjm:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed d7300cc and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.