Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-56233

The function moodleform::mock_submit() in formslib.php does not work if form uses namespace.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.4
    • Fix Version/s: 3.1.4, 3.2.1
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      Run the testcase: lib/tests/formslib_test.php

      Show
      Run the testcase: lib/tests/formslib_test.php
    • Workaround:
      Hide

      A) Provide the $formidentifier instead of auto-detecting it.

      B) Not using mock_submit and creating $_POST data in your code.

      Show
      A) Provide the $formidentifier instead of auto-detecting it. B) Not using mock_submit and creating $_POST data in your code.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-56233-32-mocksubmit

      Description

      In formslib.php , the function moodleform::mock_submit() uses a $formidentifier that can be auto-detected.

      If the plugin is using namespaces instead of frankenstyle class name, get_called_class() will return 'type\name' instead of 'type_name'. The mocking does not work properly when it auto-detects the name.

      Please check my proposed solution branch for a unit test isolating the issue.

        Attachments

          Activity

            People

            Assignee:
            roperto Daniel Thee Roperto
            Reporter:
            roperto Daniel Thee Roperto
            Peer reviewer:
            Frédéric Massart
            Integrator:
            Dan Poltawski
            Tester:
            Ankit Agarwal
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              9/Jan/17