Functional Tests: Declaration of Declaration of Drupal\Tests\recaptcha\Functional\RecaptchaJavascriptTest::setUp()

Created on 8 May 2024, 10 months ago

Problem/Motivation

When running PHPUnit tests, I get this error that stops any other tests from running:

PHP Fatal error: Declaration of Drupal\Tests\recaptcha\Functional\RecaptchaJavascriptTest::setUp() must be compatible with Drupal\Tests\BrowserTestBase::setUp(): void in /opt/drupal/web/modules/contrib/recaptcha/tests/src/Functional/RecaptchaJavascriptTest.php on line 38

Steps to reproduce

PHP 8.2.

Drupal core 10.2.6.

Run phpunit, or more specifically phpunit --testsuite="functional", from the command line.

Proposed resolution

As recommended by the error text, change the declaration of setUp to specify a void return.

Replace:

protected function setUp() {

With:

protected function setUp(): void {

As a side note, my VS Code Drupal formatter is identifying several other issues with that file: comments not ending with periods, a function not in camelCase, too many arguments to a couple of functions, etc.

πŸ› Bug report
Status

Closed: duplicate

Version

3.2

Component

General

Created by

πŸ‡¨πŸ‡¦Canada ryanrobinson_wlu

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

Comments & Activities

Production build 0.71.5 2024