Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.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 core;
  18  
  19  /**
  20   * Unit tests for lib/outputrenderers.
  21   *
  22   * @package   core
  23   * @category  test
  24   * @copyright 2023 Rodrigo Mady
  25   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   * @coversDefaultClass \core_renderer
  27   */
  28  class outputrenderers_test extends \advanced_testcase {
  29      /**
  30       * Test generated url from course image.
  31       *
  32       * @covers ::get_generated_url_for_course
  33       */
  34      public function test_get_generated_url_for_course_image() {
  35          global $OUTPUT;
  36  
  37          $this->resetAfterTest();
  38  
  39          $course = self::getDataGenerator()->create_course();
  40          $context = \context_course::instance($course->id, IGNORE_MISSING);
  41  
  42          // Get the image with correct course context.
  43          $courseimage = $OUTPUT->get_generated_url_for_course($context);
  44          $url = "https://www.example.com/moodle/pluginfile.php/{$context->id}/course/generated/course.svg";
  45          $this->assertEquals($url, $courseimage);
  46      }
  47  }