Problem/Motivation

because PackageManagerKernelTestBase::assertResults()

// If we did not get an exception, ensure we didn't expect any results.
      $this->assertEmpty($expected_results);

If a test fails because the results are not empty you will just see

Failed asserting that an array is not empty.

which is not very helpful

Steps to reproduce

To force a failed test like what might happen in debugging an issue

  1. add return statement to the top of \Drupal\package_manager\Validator\LockFileValidator::validateStagePreOperation so we never add an error
  2. Run \Drupal\Tests\package_manager\Kernel\LockFileValidatorTest::testLockFileChanged which expects an error
  3. get the error "Failed asserting that an array is not empty."

Proposed resolution

replace

$this->assertEmpty($expected_results);

with

$this->assertValidationResultsEqual([], $expected_results);

which will show the error we were expecting

Remaining tasks

User interface changes

API changes

Data model changes

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

tedbow created an issue. See original summary.

tedbow’s picture

Issue summary: View changes
Issue tags: +DX (Developer Experience)

tedbow’s picture

Title: PackageManagerKernelTestBase::assertResults does not give helpful error message if asserts results are empty fail » PackageManagerKernelTestBase::assertResults does not give helpful error message if asserting results are empty fails
tedbow’s picture

Status: Active » Needs review
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

  • tedbow committed 2480e149 on 8.x-2.x
    Issue #3337062 by tedbow, phenaproxima: PackageManagerKernelTestBase::...
tedbow’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @phenaproxima!

Status: Fixed » Closed (fixed)

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