Improve assertion test failures with bad zend.assertions value

Created on 5 January 2018, almost 7 years ago
Updated 30 January 2023, almost 2 years ago

Problem/Motivation

There are now multiple tests in Drupal which use runtime assertions to aid coders during development. These tests will fail if zend.assertions is set to 0 or -1. There is no way to specify or change this value during runtime so we can't force the correct version of the value so users are left without a clear reason why they can't run the core test suite.

Proposed resolution

As of version 8.5 PHP Unit provides a @requires setting annotation that can check the value of zend.assertions and skip the test if it isn't set to 1.

Remaining tasks

Reviews

User interface changes

n/a

API changes

None.

Data model changes

n/a

Testing

Testing can be done easily with the phpunit runner. Just add the following code to your phpunit.xml.dist file in the <php> section.

    <!-- Force assertions to expected value. -->
    <ini name="zend.assertions" value="0"/>
📌 Task
Status

Needs work

Version

10.1

Component
PHPUnit 

Last updated about 16 hours ago

Created by

🇺🇸United States neclimdul Houston, TX

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Production build 0.71.5 2024