Uncovered over at #582584: form_required_marker() isn't passed the form element (theme_hook definition is wrong). I couldn't fix this via #582956: FormsTestCase::testRequiredFields() is broken in various ways since we weren't trying to drupal_render() at that point. DamZ says (and I believe him) that these tests are all wrong, and we shouldn't be doing the unholy things were doing in a failing attempt to unit test FAPI like this. Instead of doing the full form build/render/submit cycle, we're trying to just do pieces of it, and I believe that's what's causing all the PHP notices when you attempt to call drupal_render() on a FAPI form element of type 'radios' that's only been partially built and processed.

For now, #582584 just doesn't attempt to test if the required marker shows up on the radios. I really don't feel like completely rewriting the FAPI tests for what started as a trivial FAPI patch that mushroomed into a multi-day effort. :/

chx said he was okay with #582584 if I created this issue and reference it in an @todo code comment. So, here's the issue.

Someone, someday, should either rewrite these tests to do the full form lifecycle, or they should debug and figure out why attempting to render the bogus valued radios results in PHP notices.

CommentFileSizeAuthor
#12 588438-12.patch1.18 KBdww

Comments

effulgentsia’s picture

subscribing to look at later.

mlncn’s picture

sun’s picture

Title: SimpleTest for FAPI testRequiredFields() can't drupal_render() elements of type 'radios' » FormTest::testRequiredFields() fails to drupal_render() elements of #type 'radios'
Version: 7.x-dev » 8.x-dev
Issue summary: View changes
Issue tags: +Testing system, +Test suite performance

I just discovered this code/hack in #2192419: Use a WCAG-compliant fieldset (fieldgroup) for #type radios/checkboxes.

The entire test class should be converted to be based on DrupalUnitTestBase.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dww’s picture

Status: Active » Needs review
Issue tags: +Bug Smash Initiative
StatusFileSize
new1.18 KB

As part of my #BugSmash homework to triage bug reports I opened, re-found this issue. ;)

There's still a @todo for the work-around still in the test. Happily, Drupal\Tests\system\Functional\Form\FormTest still passes with the hack removed. So the original problems have since been solved and we can remove the tech debt in the test.

Thanks,
-Derek

p.s. Queuing for testing on 9.2.x, but it applies back to 8.9.x if we want it that far...

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Nice find, we must have refactored something over the years that means this works correctly now!

alexpott’s picture

Version: 8.9.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 4731e3c6de to 9.3.x and bf341805c8 to 9.2.x. Thanks!

  • alexpott committed 4731e3c on 9.3.x
    Issue #588438 by dww: FormTest::testRequiredFields() fails to...

  • alexpott committed bf34180 on 9.2.x
    Issue #588438 by dww: FormTest::testRequiredFields() fails to...
dww’s picture

Yay, thanks! Great to see a 2009 bug smashed. 😀

Cheers,
-Derek

Status: Fixed » Closed (fixed)

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