Problem/Motivation

PHPUnit 12.5.0+ is changing the way that mock objects work:

  • Mock objects that do not configure expectations should be converted to stubs. Otherwise, they throw a notice: No expectations were configured for the mock object for \Drupal\comment\CommentManagerInterface. You should refactor your test code and use a test stub instead.
  • $this->any() is deprecated. It was equivalent to having no expectation, in which case the object should be a stub (see the previous bullet) or a more exact number of expectations should be added.
  • with() is deprecated for stubs because it was deemed to be equally pointless.

Steps to reproduce

  1. Require PHPUnit 12 with Composer.
  2. Fix compatibility issues with PHPUnit 12 by applying this patch.
  3. Run the Unit tests for a library with --display-phpunit-notices --display-phpunit-deprecations.
  4. Observe the PHPUnit notices that occur.

Proposed resolution

Fix notices in the tests in the Config library's tests.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3579906

Command icon 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

dcam created an issue. See original summary.

dcam’s picture

Status: Active » Needs review

This was the second of "three final bosses" of this project. But while it took me a little while to figure out ConfigEntityBaseUnitTest ultimately this ended up being easier than expected. Sometimes you just need to sit down with a fresh perspective.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

OK (206 tests, 1279 assertions)

Random failure

    CKEditor5Markup (Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Markup)
     ✔ Attribute encoding
     ✔ Filter html allowed global attributes
     ✔ Comments
     ✘ Styles and scripts
       ┐
       ├ Behat\Mink\Exception\ExpectationException: The string "const example = 'Consider this string:
---- Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest ----
Status      Duration Info                                                                               
--------------------------------------------------------------------------------------------------------
Pass         17.134s testReloadWithNoSections                                                        

Conversions look good.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to main, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • catch committed ef88d596 on main
    task: #3579906 Convert expectation-less test mocks to stubs - Config...
catch’s picture

Committed/pushed to main, thanks!

(edit: double post / so good I committed it twice, you decide).

Status: Fixed » Closed (fixed)

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