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

Cannot create question category with specified parent category in behat tests

XMLWordPrintable

      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.

            melihovv Alexander Melihov
            melihovv Alexander Melihov
            Tim Hunt Tim Hunt
            Andrew Lyons Andrew Lyons
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.