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

Unittests fail if a plugin creates roles with archetypes user/frontpage in install.php

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.7
    • Fix Version/s: 3.8
    • Component/s: Roles / Access
    • Labels:
    • Testing Instructions:
      Hide

      Requires code modifications

      1. Locate any standard plugin in moodle that has db/install.php (for example, auth/cas/db/install.php )
      2. Add the following code to the _install() function:

            $roleid = create_role('Dummy role', 'mydummyrole', '', '');
            assign_capability('moodle/user:editownprofile', CAP_ALLOW, $roleid, context_system::instance()->id);
         
            foreach (get_role_archetypes() as $archetype) {
                    $roleid = create_role($archetype . ' Copy', $archetype . 'copy', '', $archetype);
                    assign_capability('moodle/user:editownprofile', CAP_ALLOW, $roleid, context_system::instance()->id);
            }
        

      3. Initialise and run unittests and make sure they pass:

        php admin/tool/phpunit/cli/util.php --drop
        php admin/tool/phpunit/cli/init.php
        ./vendor/bin/phpunit 
        

      Show
      Requires code modifications Locate any standard plugin in moodle that has db/install.php (for example, auth/cas/db/install.php ) Add the following code to the _install() function: $roleid = create_role('Dummy role', 'mydummyrole', '', ''); assign_capability('moodle/user:editownprofile', CAP_ALLOW, $roleid, context_system::instance()->id);   foreach (get_role_archetypes() as $archetype) { $roleid = create_role($archetype . ' Copy', $archetype . 'copy', '', $archetype); assign_capability('moodle/user:editownprofile', CAP_ALLOW, $roleid, context_system::instance()->id); } Initialise and run unittests and make sure they pass: php admin/tool/phpunit/cli/util.php --drop php admin/tool/phpunit/cli/init.php ./vendor/bin/phpunit
    • Affected Branches:
      MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull Master Branch:
      MDL-65782-master

      Description

      This is a follow up for MDL-65726
      Even though it's not really much point in creating roles with archetypes 'user' or 'frontpage' in the plugins install script, I thought it will be nice to fix this problem till the end.
      This can be a master-only improvement.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                marina Marina Glancy
                Reporter:
                marina Marina Glancy
                Peer reviewer:
                Damyon Wiese
                Integrator:
                Adrian Greeve
                Tester:
                Janelle Barcega
                Participants:
                Component watchers:
                Amaia Anabitarte, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Nov/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 45 minutes
                  3h 45m