Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Fixtures for task tests.
  19   *
  20   * @package    core
  21   * @category   phpunit
  22   * @copyright  2014 Petr Skoda
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace core\task;
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * Test class.
  31   *
  32   * @copyright 2022 Catalyst IT Australia Pty Ltd
  33   * @author Cameron Ball <cameron@cameron1729.xyz>
  34   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class adhoc_test_task extends \core\task\adhoc_task {
  37  
  38      /**
  39       * Constructor.
  40       *
  41       * @param int|null $nextruntime Next run time
  42       * @param int|null $timestarted Time started
  43       */
  44      public function __construct(?int $nextruntime = null, ?int $timestarted = null) {
  45          if ($nextruntime) {
  46              $this->set_next_run_time($nextruntime);
  47          }
  48  
  49          if ($timestarted) {
  50              $this->set_timestarted($timestarted);
  51          }
  52      }
  53  
  54      /**
  55       * Get task name
  56       *
  57       * @return string
  58       */
  59      public function get_name() {
  60          return 'Test adhoc class';
  61      }
  62  
  63      /**
  64       * Execute.
  65       */
  66      public function execute() {
  67      }
  68  }
  69  
  70  /**
  71   * Test class.
  72   *
  73   * @copyright 2022 Catalyst IT Australia Pty Ltd
  74   * @author Cameron Ball <cameron@cameron1729.xyz>
  75   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  76   */
  77  class adhoc_test2_task extends adhoc_test_task {
  78  }
  79  
  80  /**
  81   * Test class.
  82   *
  83   * @copyright 2022 Catalyst IT Australia Pty Ltd
  84   * @author Cameron Ball <cameron@cameron1729.xyz>
  85   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  86   */
  87  class adhoc_test3_task extends adhoc_test_task {
  88  }
  89  
  90  /**
  91   * Test class.
  92   *
  93   * @copyright 2022 Catalyst IT Australia Pty Ltd
  94   * @author Cameron Ball <cameron@cameron1729.xyz>
  95   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  96   */
  97  class adhoc_test4_task extends adhoc_test_task {
  98  }
  99  
 100  /**
 101   * Test class.
 102   *
 103   * @copyright 2022 Catalyst IT Australia Pty Ltd
 104   * @author Cameron Ball <cameron@cameron1729.xyz>
 105   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 106   */
 107  class adhoc_test5_task extends adhoc_test_task {
 108  }
 109  
 110  class scheduled_test_task extends \core\task\scheduled_task {
 111      public function get_name() {
 112          return "Test task";
 113      }
 114  
 115      public function execute() {
 116      }
 117  }
 118  
 119  class scheduled_test2_task extends \core\task\scheduled_task {
 120      public function get_name() {
 121          return "Test task 2";
 122      }
 123  
 124      public function execute() {
 125      }
 126  }
 127  
 128  class scheduled_test3_task extends \core\task\scheduled_task {
 129      public function get_name() {
 130          return "Test task 3";
 131      }
 132  
 133      public function execute() {
 134      }
 135  }
 136  
 137  namespace mod_fake\task;
 138  
 139  class adhoc_component_task extends \core\task\adhoc_task {
 140      public function execute() {
 141  
 142      }
 143  }