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

CLI Script to enable or disable the emailstop flag

XMLWordPrintable

    • MOODLE_401_STABLE
    • MOODLE_402_STABLE
    • MDL-77385-master
    • Easy
    • Hide

      Setup

      1. Check that there are any users on your site (other than the admin user).
      2. Access to the console of the webserver (locally, in the docker container etc.).
      3. Get the username and the email of at least two users.
        (For convenience in the test description I will use username: student1, email: student1@example.org and username: student2, email: student2@example.org, in addition we expect student1 to have id 3 and student2 to have the id 4).
      4. Access to the database to run arbitrary queries.

      Testing enable and disable emailstop

      1. Check that in DB user.emailstop equals 0 for the user with email student1@example.org
      2. On the console run: php admin/cli/emailstop.php -u=student1
        Expected output: user=student1 - emailstop=0
      3. On the console run: php admin/cli/emailstop.php -e=student1@example.org
        Expected output: user=student1@example.org - emailstop=0
      4. On the console run: php admin/cli/emailstop.php -e=student1@example.org -s=1
        Expected output: Update user student1@example.org (3) - ok
      5. On the console run: php admin/cli/emailstop.php --email=student1@example.org
        Expected output: user=student1@example.org - emailstop=1
      6. Check that in DB user.emailstop equals 1 for this user
      7. On the console run: php admin/cli/emailstop.php --email=student1@example.org --stop=off -q
        No output expected.
      8. On the console run: php admin/cli/emailstop.php --id=3
        Expected output: user=3 - emailstop=0
      9. Check that in DB user.emailstop equals 0 for this user
      10. On the console run: php admin/cli/emailstop.php -i=3 -s=on -q
        No output expected.
      11. On the console run: php admin/cli/emailstop.php --username=student1,student2 -s=on
        Expected output:
        Update user student1 (3) - already done
        Update user student2 (4) - ok
      12. On the console run: php admin/cli/emailstop.php -u=student1
        Expected output: emailstop=1
      13. Check that in DB user.emailstop equals 1 for user student1 and student2
      14. On the console run: php admin/cli/emailstop.php --help
        Expected output: Helpscreen with insctructions

      Testing with inapropriate args

      1. On the console run: php admin/cli/emailstop.php
        Expected output: Either username or email must be set.
      2. On the console run: php admin/cli/emailstop.php foo
        Expected output: Unrecognised options:
          foo
        Please use --help option.
      3. On the console run: php admin/cli/emailstop.php -u=student1 -e=student1@example.org
        Expected output: Only one of email, username, or id can be set to identify user.
      4. On the console run: php admin/cli/emailstop.php -u=student1234
        Expected output: Can not find any user by username: 'student1234'.
      5. On the console run: php admin/cli/emailstop.php --email=student1234@example.org
        Expected output: Can not find any user by email: 'student1234@example.org'.
      6. On the console run: php admin/cli/emailstop.php -u=student1 -s=yes
        Expected output: Value for the emailstop flag must be one of: 0, 1, off, on.
      Show
      Setup Check that there are any users on your site (other than the admin user). Access to the console of the webserver (locally, in the docker container etc.). Get the username and the email of at least two users. (For convenience in the test description I will use username: student1, email: student1@example.org and username: student2, email: student2@example.org, in addition we expect student1 to have id 3 and student2 to have the id 4). Access to the database to run arbitrary queries. Testing enable and disable emailstop Check that in DB user.emailstop equals 0 for the user with email student1@example.org On the console run: php admin/cli/emailstop.php -u=student1 Expected output: user=student1 - emailstop=0 On the console run: php admin/cli/emailstop.php -e=student1@example.org Expected output: user= student1@example.org - emailstop=0 On the console run: php admin/cli/emailstop.php -e=student1@example.org -s=1 Expected output: Update user student1@example.org (3) - ok On the console run: php admin/cli/emailstop.php --email=student1@example.org Expected output: user= student1@example.org - emailstop=1 Check that in DB user.emailstop equals 1 for this user On the console run: php admin/cli/emailstop.php --email=student1@example.org --stop=off -q No output expected. On the console run: php admin/cli/emailstop.php --id=3 Expected output: user=3 - emailstop=0 Check that in DB user.emailstop equals 0 for this user On the console run: php admin/cli/emailstop.php -i=3 -s=on -q No output expected. On the console run: php admin/cli/emailstop.php --username=student1,student2 -s=on Expected output: Update user student1 (3) - already done Update user student2 (4) - ok On the console run: php admin/cli/emailstop.php -u=student1 Expected output: emailstop=1 Check that in DB user.emailstop equals 1 for user student1 and student2 On the console run: php admin/cli/emailstop.php --help Expected output: Helpscreen with insctructions Testing with inapropriate args On the console run: php admin/cli/emailstop.php Expected output: Either username or email must be set. On the console run: php admin/cli/emailstop.php foo Expected output: Unrecognised options:   foo Please use --help option. On the console run: php admin/cli/emailstop.php -u=student1 -e=student1@example.org Expected output: Only one of email, username, or id can be set to identify user. On the console run: php admin/cli/emailstop.php -u=student1234 Expected output: Can not find any user by username: 'student1234'. On the console run: php admin/cli/emailstop.php --email=student1234@example.org Expected output: Can not find any user by email: 'student1234@example.org'. On the console run: php admin/cli/emailstop.php -u=student1 -s=yes Expected output: Value for the emailstop flag must be one of: 0, 1, off, on.

      Due to expired email addresses that we find in the mail logs, we need to enable in this case the emailstop flag for that user so that no more additional emails are sent to that address.

      The whole process should be automated, therefore a human interaction is not wanted, that does these changes manually when they are reported.

        1. enable and disable.png
          enable and disable.png
          567 kB
        2. inapropriate args.png
          inapropriate args.png
          103 kB
        3. result_1.png
          result_1.png
          48 kB
        4. result_2.png
          result_2.png
          45 kB
        5. result_3.png
          result_3.png
          43 kB
        6. result_4.png
          result_4.png
          55 kB

            strobotta Stephan Robotta
            strobotta Stephan Robotta
            Luca Bösch Luca Bösch
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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