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

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.7
    • 3.8
    • Roles / Access
    • MOODLE_37_STABLE
    • MOODLE_38_STABLE
    • MDL-65782-master
    • 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

    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

              marina Marina Glancy
              marina Marina Glancy
              Damyon Wiese Damyon Wiese
              Adrian Greeve Adrian Greeve
              Janelle Barcega Janelle Barcega
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                18/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