Problem/Motivation

PHPUnit 9 deprecated ::expectError*() and ::expectWarning*()methods. They're removed from PHPUnit 10.

Proposed resolution

Issue fork drupal-3427174

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

mondrake created an issue. See original summary.

dineshkumarbollu made their first commit to this issue’s fork.

quietone made their first commit to this issue’s fork.

quietone’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Checked ConfigTest and this was the only instance of expectError().

mondrake’s picture

Status: Reviewed & tested by the community » Needs work

This is not enough for PHPUnit 10, since PHPUnit's error handler is no longer converting the trigger_error into an exception.

longwave made their first commit to this issue’s fork.

longwave’s picture

Status: Needs work » Needs review

NestedArray::setValue() already has some support for this but allowed the error to happen; we can catch it before it happens and throw an exception instead.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now, thanks

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Given this is a component I think we should update \Drupal\Tests\Component\Utility\NestedArrayTest to test for this too.

longwave’s picture

Status: Needs work » Needs review

Added test coverage to the component, also uncovered an existing bug where $force was not required if you were replacing a scalar directly with an array - this now triggers a LogicException without $force, which I think is the correct behaviour.

smustgrave’s picture

Status: Needs review » Needs work

Appears to have caused large number of test failures.

quietone’s picture

This is changing the behavior of NestedArray so I think another solution is needed. And it also prevents installing Drupal thus the many failed tests.

longwave’s picture

Yeah maybe the behaviour is intended although it seemed wrong when I wrote the test, I will just write another test instead and not change the behaviour I think...

longwave’s picture

Status: Needs work » Needs review

Reverted behaviour change, fixed the test. I guess it's by design that you can overwrite a scalar with an array, just you can't try to make further children under the scalar that previously didn't exist.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback and tests appear to be added.

alexpott’s picture

Title: Replace calls to ::expectError*() from Drupal\Tests\Core\Config\ConfigTest » Throw exception when calling NestedArray::setValue() when parents reference a non-array value
alexpott’s picture

Title: Throw exception when calling NestedArray::setValue() when parents reference a non-array value » Throw exception when calling NestedArray::setValue() when parents reference a non-array value instead of causing a PHP error
alexpott’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 1c017c0 and pushed to 11.x. Thanks!
Committed e8ac11d and pushed to 10.3.x. Thanks!

  • alexpott committed e8ac11da on 10.3.x
    Issue #3427174 by longwave, quietone, dineshkumarbollu, mondrake,...
longwave’s picture

Status: Fixed » Reviewed & tested by the community

11.x commit didn't make it to the repo.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

  • alexpott committed 1c017c0e on 11.x
    Issue #3427174 by longwave, quietone, dineshkumarbollu, mondrake,...

Status: Fixed » Closed (fixed)

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