Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

   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   * Generator testcase for the gradingforum_rubric generator.
  19   *
  20   * @package    core_grading
  21   * @category   test
  22   * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace core_grading;
  27  
  28  use advanced_testcase;
  29  use context_module;
  30  use gradingform_controller;
  31  use gradingform_rubric_controller;
  32  
  33  /**
  34   * Generator testcase for the core_grading generator.
  35   *
  36   * @package    core_grading
  37   * @category   test
  38   * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
  39   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  40   */
  41  class generator_test extends advanced_testcase {
  42  
  43      /**
  44       * Test gradingform controller creation.
  45       */
  46      public function test_create_instance(): void {
  47          $this->resetAfterTest(true);
  48  
  49          // Fetch generators.
  50          $generator = \testing_util::get_data_generator();
  51          $gradinggenerator = $generator->get_plugin_generator('core_grading');
  52  
  53          // Create items required for testing.
  54          $course = $generator->create_course();
  55          $module = $generator->create_module('assign', ['course' => $course]);
  56          $user = $generator->create_user();
  57          $context = context_module::instance($module->cmid);
  58  
  59          // The assignment module has an itemumber 0 which is an advanced grading area called 'submissions'.
  60          $component = 'mod_assign';
  61          $area = 'submissions';
  62          $controller = $gradinggenerator->create_instance($context, $component, $area, 'rubric');
  63  
  64          // This should be a rubric.
  65          $this->assertInstanceOf(gradingform_controller::class, $controller);
  66          $this->assertInstanceOf(gradingform_rubric_controller::class, $controller);
  67  
  68          $this->assertEquals($context, $controller->get_context());
  69          $this->assertEquals($component, $controller->get_component());
  70          $this->assertEquals($area, $controller->get_area());
  71      }
  72  }