Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

   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 mod_forum;
  18  
  19  use mod_forum\local\entities\author as author_entity;
  20  
  21  /**
  22   * The author entity tests.
  23   *
  24   * @package    mod_forum
  25   * @copyright  2019 Ryan Wyllie <ryan@moodle.com>
  26   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27   */
  28  class entities_author_test extends \advanced_testcase {
  29      /**
  30       * Test the entity returns expected values.
  31       */
  32      public function test_entity() {
  33          $this->resetAfterTest();
  34  
  35          $author = new author_entity(
  36              1,
  37              2,
  38              'test',
  39              'person',
  40              'test person',
  41              'test@example.com',
  42              false,
  43              'middle',
  44              'tteeeeest',
  45              'ppppeeerssson',
  46              'maverick',
  47              'image alt'
  48          );
  49  
  50          $this->assertEquals(1, $author->get_id());
  51          $this->assertEquals(2, $author->get_picture_item_id());
  52          $this->assertEquals('test', $author->get_first_name());
  53          $this->assertEquals('person', $author->get_last_name());
  54          $this->assertEquals('test person', $author->get_full_name());
  55          $this->assertEquals('test@example.com', $author->get_email());
  56          $this->assertEquals(false, $author->is_deleted());
  57          $this->assertEquals('middle', $author->get_middle_name());
  58          $this->assertEquals('tteeeeest', $author->get_first_name_phonetic());
  59          $this->assertEquals('ppppeeerssson', $author->get_last_name_phonetic());
  60          $this->assertEquals('maverick', $author->get_alternate_name());
  61          $this->assertEquals('image alt', $author->get_image_alt());
  62      }
  63  }