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.
   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  namespace tool_brickfield\local\tool;
  18  
  19  /**
  20   * Unit tests for {@errors tool_brickfield\local\tool\errors\tool}.
  21   *
  22   * @package   tool_brickfield
  23   * @copyright  2020 onward: Brickfield Education Labs, www.brickfield.ie
  24   * @author     Jay Churchward (jay.churchward@poetopensource.org)
  25   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  class errors_test extends \advanced_testcase {
  28  
  29      public function test_toolname() {
  30          $this->resetAfterTest();
  31  
  32          $object = new errors();
  33          $output = $object->toolname();
  34          $this->assertEquals($output, 'Error list summary');
  35      }
  36  
  37      public function test_toolshortname() {
  38          $this->resetAfterTest();
  39  
  40          $object = new errors();
  41          $output = $object->toolshortname();
  42          $this->assertEquals($output, 'Error list');
  43      }
  44  
  45      public function test_pluginname() {
  46          $this->resetAfterTest();
  47  
  48          $object = new errors();
  49          $output = $object->pluginname();
  50          $this->assertEquals($output, 'errors');
  51      }
  52  
  53      public function test_get_output() {
  54          $this->resetAfterTest();
  55          $category = $this->getDataGenerator()->create_category();
  56  
  57          $filter = new filter(1, $category->id, 'errors', 3, 4);
  58          $filter->courseids = [];
  59  
  60          $object = new errors();
  61          $object->set_filter($filter);
  62          $output = $object->get_output();
  63          $this->assertIsString($output);
  64          $this->assertStringContainsString('Error details:', $output);
  65      }
  66  }