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

Cannot create question category with specified parent category in behat tests

    XMLWordPrintable

    Details

      Description

      In behat tests (perhaps, and in phpunit tests too) there is no way to create question category with specified parent, like SubCategory category in the following example:

      And the following "question categories" exist:
        | contextlevel | reference | name            | parent       |
        | Course       | C1        | Category        | 0            |
        | Course       | C1        | SubCategory     | Category     |
      

      It is because there is bug in lib/tests/behat/behat_data_generators
      https://github.com/moodle/moodle/blob/0fbe41f4cda13cb2a205aaa4eaeeec45e595e3b6/lib/tests/behat/behat_data_generators.php#L163

      The following code

      'question categories' => array(
          'datagenerator' => 'question_category',
          'required' => array('name', 'contextlevel', 'reference'),
          'switchids' => array('questioncategory' => 'category')
      ),
      

      should be

      'question categories' => array(
          'datagenerator' => 'question_category',
          'required' => array('name', 'contextlevel', 'reference'),
          'switchids' => array('questioncategory' => 'parent')
      ),
      

      The field "category" doesn't exist in question_category table, that is why it should be replaced with "parent".

      Thread on general developer forum: https://moodle.org/mod/forum/discuss.php?d=343438.

        Attachments

          Activity

            People

            • Assignee:
              melihovv Alexander Melihov
              Reporter:
              melihovv Alexander Melihov
              Peer reviewer:
              Tim Hunt
              Integrator:
              Andrew Nicols
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze, Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

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