This is a follow-on from #3109923: Deprecation: add $defaultTheme - create FormWidgetBrowserTestBase class which adds a new FormWidgetBrowserTestBase class.
In that base class we can define protected functions assertIsApplicable($widget, $type) and assertIsNotApplicable($widget, $type) to simplify the testIsApplicable function then the subclasses don't need to deal with DataDefinition at all.
Instead of the subclasses having to do $this->assertFalse($this->widget->isApplicable(DataDefinition::create('boolean'))); etc, this will now be in the helper function, and the subclasses just substitute $this->assertIsApplicable($this->widget, 'boolean'); etc.
Credit to TR for this idea
Issue fork typed_data-3110036
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jonathan1055 commentedActually I don't think we need to pass $this->widget as the first parameter, as that is consistent for all calls and can be accessed directly from the base class. We only need to pass the datatype that is being checked.
Comment #3
tr commentedYes, once
$widgetIdis straightened out and available in the base class(#3109923-7: Deprecation: add $defaultTheme - create FormWidgetBrowserTestBase class), there will be no need to pass$this->widgetsince that will be assigned in the base class.Comment #4
jonathan1055 commentedPostponed, needs to wait for #3110650: Move creation of $widget into WidgetBrowserTestBase
Comment #5
tr commentedComment #6
jonathan1055 commentedUnpostponing now that #3110650: Move creation of $widget into WidgetBrowserTestBase is committed.
Comment #7
tr commented