Functions in UnitTest are deprecated

Created on 4 August 2021, over 3 years ago
Updated 14 September 2023, over 1 year ago

Problem/Motivation

The Unit test fails with PHPUnit 9 & Drupal 9, as some parts of the test are deprecated.

These are:

  • @expectedException and @expectedExceptionMessage were removed in PHPUnit 9 and must be replaced with $this->expectException(…); and $this->expectExceptionMessage("…"); in \Unit\FormatterTest::testUnparsableNumber and \Unit\FormatterTest::testInvalidNumber.
  • Declaring ::setUp without a void return typehint in \Unit\FormatterTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724 β†’

Steps to reproduce

  1. Use Drupal 9.2.3 (or a compatible version) and PHPUnit 9.5.8 (or a compatible version)
  2. Run the unit test phpunit telephone_formatter/tests/src/Unit/FormatterTest.php

Proposed resolution

  • Replace @expectedException and @expectedExceptionMessage with
    $this->expectException(Exception::class);
    $this->expectExceptionMessage("");
    
  • Add return-type void to function setUp() (public function setUp(): void {)

or apply the patch.

Remaining tasks

  • Review Patch

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany RobinCS

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.

Production build 0.71.5 2024