Skip to content

Problem with phpunit test - string object #33

@TheBryanOpen228

Description

@TheBryanOpen228

Describe the bug
After https://moodle.atlassian.net/browse/MDL-85666, several checks and validations were added as part of the automated tests, in particular lib/tests/event/plugin_checks_test.php is failing on Moodle 4.5.6, see the error log:

core\event\plugin_checks_test::test_event_classes with data set "local_webhooks" ('local_webhooks', 'local', 'webhooks', '/builds/open-lms/product/edu/...bhooks')
Failed asserting that core\lang_string Object &00000000000342250000000000000000 (
'component' => 'moodle'
'a' => null
'string' => null
'forcedstring' => false
'identifier' => 'create'
'lang' => null
) is of type "string".
/builds/open-lms/product/edu/moodle/lib/tests/event/plugin_checks_test.php:57
/builds/open-lms/product/edu/moodle/lib/phpunit/classes/basic_testcase.php:64

since local_webhooks does not return a string, instead it returns a lang object for the following events:

  • local/webhooks/classes/event/backup_performed.php
  • local/webhooks/classes/event/backup_restored.php
  • local/webhooks/classes/event/response_answer.php
  • local/webhooks/classes/event/service_added.php
  • local/webhooks/classes/event/service_deleted.php
  • local/webhooks/classes/event/service_updated.php

Change return new lang_string('create', 'moodle'); to return get_string('create', 'moodle'); for every string used for events methods.

To Reproduce
Steps to reproduce the behavior:

  1. Set environment for PhpUnit testing, with Moodle 4.5.6 or new
  2. Run lib/tests/event/plugin_checks_test.php automated test
  3. See error

Expected behavior
No error is shown

Additional context
Review Moodle core ticket MDL-85666

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions