Skip to content

Make Test_Widget compatible with WP_Widget - #34355

Merged
adamziel merged 3 commits into
trunkfrom
fix/test-widget-class
Aug 30, 2021
Merged

adamziel merged 3 commits into
trunkfrom
fix/test-widget-class

Conversation

@adamziel

Copy link
Copy Markdown
Contributor

Today I noticed that running certains e2e tests locally logs the following errors:

  ● Widgets Customizer › should handle the inserter outer section

    Unexpected error in page content: Warning: Declaration of Test_Widget::update($new_instance) should be compatible with WP_Widget::update($new_instance, $old_instance) in /var/www/html/wp-content/plugins/gutenberg-test-plugins/class-test-widget.php on line 65

      at visitAdminPage (../e2e-test-utils/build/@wordpress/e2e-test-utils/src/visit-admin-page.js:38:9)
          at runMicrotasks (<anonymous>)
      at Object.<anonymous> (specs/widgets/customizing-widgets.test.js:28:3
  ● Widgets Customizer › should move (inner) blocks to another sidebar

    Unexpected error in page content: Notice: Undefined index: title in /var/www/html/wp-content/plugins/gutenberg-test-plugins/class-test-widget.php on line 51

      at visitAdminPage (../e2e-test-utils/build/@wordpress/e2e-test-utils/src/visit-admin-page.js:38:9)
          at runMicrotasks (<anonymous>)
      at Object.<anonymous> (specs/widgets/customizing-widgets.test.js:28:3)

Turns out that the signature of Test_Widget::update is indeed incompatible with WP_Widget::update. This PR adjusts class Test_Widget to fix these two problems.

@gziolo gziolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and CI is green 👍🏻

@adamziel
adamziel merged commit b2c4a00 into trunk Aug 30, 2021
@adamziel
adamziel deleted the fix/test-widget-class branch August 30, 2021 10:24
@github-actions github-actions Bot added this to the Gutenberg 11.5 milestone Aug 30, 2021
@getsource getsource added the [Type] Bug An existing feature does not function as intended label Sep 7, 2021
desrosj added a commit to desrosj/gutenberg that referenced this pull request Sep 28, 2026
`Test_Widget::update()` in the e2e test plugin declares a single
`$new_instance` parameter, while the parent `WP_Widget::update()` takes
`$new_instance` and `$old_instance`. On PHP 8 this incompatible method
signature is a fatal error, so WordPress refuses to activate the
`gutenberg-test-widgets` plugin and `customizing-widgets.test.js` times
out waiting for the plugin's Deactivate link on every run.

Ports b2c4a00 (WordPress#34355) from `trunk`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtSAAJkQ9P6vPtDumqStg8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] E2E Tests /packages/e2e-tests [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants