PHPUnit: Fix Functional Tests 'HoneypotFormCacheTest'

Created on 29 May 2024, 6 months ago
Updated 19 July 2024, 4 months ago

Problem/Motivation

PHPUnit tests seem to be currently failing for the main 2.1.x development branch, in particular blocking merge requests and failing builds in issue forks, see for example:

The problem seems to be the same as the one described in 📌 TypeError: Argument #2 passed to Behat\Mink\WebAssert::responseHeaderEquals() must be of type string, null given Needs review :

1) Drupal\Tests\honeypot\Functional\HoneypotFormCacheTest::testCacheContactForm
TypeError: Behat\Mink\WebAssert::responseHeaderEquals(): Argument #2 ($value) must be of type string, null given, called in /builds/issue/honeypot-2342473/tests/src/Functional/HoneypotFormCacheTest.php on line 97
/builds/issue/honeypot-2342473/vendor/behat/mink/src/WebAssert.php:175
/builds/issue/honeypot-2342473/tests/src/Functional/HoneypotFormCacheTest.php:97
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
2) Drupal\Tests\honeypot\Functional\HoneypotFormCacheTest::testCacheCommentForm
TypeError: Behat\Mink\WebAssert::responseHeaderEquals(): Argument #2 ($value) must be of type string, null given, called in /builds/issue/honeypot-2342473/tests/src/Functional/HoneypotFormCacheTest.php on line 138
/builds/issue/honeypot-2342473/vendor/behat/mink/src/WebAssert.php:175
/builds/issue/honeypot-2342473/tests/src/Functional/HoneypotFormCacheTest.php:138
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/Framework/TestResult.php:729

The other issue is due to the rules module, see 🐛 [10.2] PHPUnit errors: non-existent service plugin.manager.field.field_type_category Needs review :

3) Drupal\Tests\honeypot\Unit\Integration\Event\HoneypotRejectEventTest::testHoneypotRejectEvent
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "plugin.manager.field.field_type_category".
/builds/issue/honeypot-2342473/vendor/symfony/dependency-injection/ContainerBuilder.php:992
/builds/issue/honeypot-2342473/vendor/symfony/dependency-injection/ContainerBuilder.php:568
/builds/issue/honeypot-2342473/vendor/symfony/dependency-injection/ContainerBuilder.php:531
/builds/issue/honeypot-2342473/web/core/lib/Drupal.php:197
/builds/issue/honeypot-2342473/web/core/lib/Drupal/Core/Field/FieldTypePluginManager.php:54
/builds/issue/honeypot-2342473/web/modules/contrib/rules/tests/src/Unit/Integration/RulesEntityIntegrationTestBase.php:131
/builds/issue/honeypot-2342473/web/modules/contrib/rules/tests/src/Unit/Integration/Event/EventTestBase.php:26
/builds/issue/honeypot-2342473/tests/src/Unit/Integration/Event/EventTestBase.php:21
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/Framework/TestSuite.php:685
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/Framework/TestSuite.php:685
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:651
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/TextUI/Command.php:146
/builds/issue/honeypot-2342473/vendor/phpunit/phpunit/src/TextUI/Command.php:99
/builds/issue/honeypot-2342473/vendor/bin/phpunit:122

 

Steps to reproduce

Run PHPUnit tests:

/vendor/bin/phpunit /web/modules/contrib/honeypot/

Proposed resolution

Mostly, apply the same fix as for related issue 📌 TypeError: Argument #2 passed to Behat\Mink\WebAssert::responseHeaderEquals() must be of type string, null given Needs review .

The other issue is addressed in the Rules module in 🐛 [10.2] PHPUnit errors: non-existent service plugin.manager.field.field_type_category Needs review with merge request:
https://git.drupalcode.org/project/rules/-/merge_requests/26

📌 Task
Status

Fixed

Version

2.1

Component

Code

Created by

🇫🇷France dydave

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024