PackageManagerKernelTestBase::assertResults does not show actual results if none were expected.

Created on 27 January 2023, over 1 year ago

Problem/Motivation

follow-up πŸ“Œ PackageManagerKernelTestBase::assertResults does not give helpful error message if asserting results are empty fails Fixed

We have

catch (TestStageValidationException $e) {
      $this->assertNotEmpty($expected_results);
      $this->assertValidationResultsEqual($expected_results, $e->getResults());

If we get an exception but expected_results was empty, meaning we did not expect an error , you will get the message "Failed asserting that an array is not empty." which is not helpful because it does not tell you what the actual error was

Steps to reproduce

  1. at the top of \Drupal\package_manager\Validator\LockFileValidator::validateStagePreOperation unconditionally add $event->addError([t('you will never fix this.')]);
  2. run \Drupal\Tests\package_manager\Kernel\LockFileValidatorTest::testCreateWithLock which expects now error
  3. see "Failed asserting that an array is not empty."

Proposed resolution

switch the order of the calls in the summary

which will show "Failed asserting that two arrays are identical." with the difference including the actual error

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Package Manager

Created by

πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024