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 core_calendar; 18 19 use core_calendar\local\event\proxies\coursecat_proxy; 20 21 /** 22 * coursecat_proxy testcase. 23 * 24 * @package core_calendar 25 * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk> 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 class coursecat_proxy_test extends \advanced_testcase { 29 30 public function test_valid_coursecat() { 31 global $DB; 32 $this->resetAfterTest(); 33 34 $name = '2027-2028 Academic Year'; 35 $generator = $this->getDataGenerator(); 36 $category = $generator->create_category([ 37 'name' => $name, 38 ]); 39 \cache_helper::purge_by_event('changesincoursecat'); 40 41 // Fetch the proxy. 42 $startreads = $DB->perf_get_reads(); 43 $proxy = new coursecat_proxy($category->id); 44 $this->assertInstanceOf(coursecat_proxy::class, $proxy); 45 $this->assertEquals(0, $DB->perf_get_reads() - $startreads); 46 47 // Fetch the ID - this is known and doesn't require a cache read. 48 $this->assertEquals($category->id, $proxy->get('id')); 49 $this->assertEquals(0, $DB->perf_get_reads() - $startreads); 50 51 // Fetch the name - not known, and requires a read. 52 $this->assertEquals($name, $proxy->get('name')); 53 $this->assertEquals(1, $DB->perf_get_reads() - $startreads); 54 55 $this->assertInstanceOf('core_course_category', $proxy->get_proxied_instance()); 56 } 57 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body