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] [Versions 401 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   * External functions test for record_feedback_action.
  19   *
  20   * @package    core
  21   * @category   test
  22   * @copyright  2020 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\external\output\icon_system;
  27  
  28  use externallib_advanced_testcase;
  29  
  30  defined('MOODLE_INTERNAL') || die();
  31  
  32  global $CFG;
  33  
  34  require_once($CFG->dirroot . '/webservice/tests/helpers.php');
  35  
  36  /**
  37   * Class record_userfeedback_action_testcase
  38   *
  39   * @copyright  2020 Andrew Nicols <andrew@nicols.co.uk>
  40   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  41   * @coversDefaultClass \core\external\output\icon_system\load_fontawesome_map
  42   */
  43  class load_fontawesome_map_test extends externallib_advanced_testcase {
  44      /**
  45       * Ensure that a valid theme which uses fontawesome returns a map.
  46       *
  47       * @covers ::execute_parameters
  48       * @covers ::execute
  49       * @covers ::execute_returns
  50       * @dataProvider valid_fontawesome_theme_provider
  51       * @param   string $themename
  52       */
  53      public function test_execute(string $themename): void {
  54          $result = load_fontawesome_map::execute($themename);
  55          $this->assertIsArray($result);
  56  
  57          foreach ($result as $value) {
  58              $this->assertArrayHasKey('component', $value);
  59              $this->assertArrayHasKey('pix', $value);
  60              $this->assertArrayHasKey('to', $value);
  61          }
  62      }
  63  
  64      /**
  65       * Ensure that an invalid theme cannot be loaded.
  66       */
  67      public function test_execute_invalid_themename(): void {
  68          $result = load_fontawesome_map::execute('invalidtheme');
  69          $this->assertDebuggingCalled(
  70              'This page should be using theme invalidtheme which cannot be initialised. Falling back to the site theme boost'
  71          );
  72          $this->assertIsArray($result);
  73      }
  74  
  75      /**
  76       * Data provider for valid themes to use with the execute function.
  77       *
  78       * @return  array
  79       */
  80      public function valid_fontawesome_theme_provider(): array {
  81          return [
  82              'Boost theme' => ['boost'],
  83              'Classic theme (extends boost)' => ['classic'],
  84          ];
  85      }
  86  }