Skip to content

PHPUnit tests failing in Moodle 5.1 #151

@dcmexy

Description

@dcmexy

Description

When running the PHPUnit test suite on Moodle 5.1+ with PHP 8.4 and PHPUnit 11.5, multiple errors and one failure occur in the search_elastic engine tests.

This appears to be caused by PHPUnit 11 API removals and stricter named parameter handling in PHP 8.4.

Stack Trace

Moodle 5.1+ (Build: 20251127)
Php: 8.4.16, mysqli: 8.4.8, OS: Linux 6.8.0-101-generic x86_64
PHPUnit 11.5.12 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.16
Configuration: /var/www/moodle-upgrade/phpunit.xml

...EESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.....F..........SS...  63 / 155 ( 40%)
............................................................... 126 / 155 ( 81%)
.........................EEE.                                   155 / 155 (100%)

Time: 00:23.424, Memory: 107.00 MB

There were 5 errors:

1) search_elastic\document_test::test_export_file_for_engine
Error: Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::setMethods()

/var/www/moodle-upgrade/public/search/engine/elastic/tests/document_test.php:150

2) search_elastic\document_test::test_export_text_file_for_engine
Error: Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::setMethods()

/var/www/moodle-upgrade/public/search/engine/elastic/tests/document_test.php:200

3) search_elastic\server_ready_check_test::test_check with data set "not set" ('', 'na')
Error: Unknown named parameter $status

4) search_elastic\server_ready_check_test::test_check with data set "invalid hostname" ('invalid.com', 'error')
Error: Unknown named parameter $status

5) search_elastic\server_ready_check_test::test_check with data set "valid hostname" ('valid.com', 'ok')
Error: Unknown named parameter $status

--

There was 1 failure:

1) search_elastic\esrequest_test::test_get_unreachable_host
Failed asserting that exception of type "GuzzleHttp\Exception\ConnectException" is thrown.

ERRORS!
Tests: 155, Assertions: 308, Errors: 5, Failures: 1, PHPUnit Deprecations: 17, Skipped: 39.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions