/** * Testcase to check onQuickformEvent */ public function test_onquickformevent() { global $USER; $testvals = $this->testvals; // Get dummy form for data. $mform = $this->mform; foreach ($testvals as $vals) { // Set user timezone to test value. $USER->timezone = $vals['usertimezone']; // Create dateselector element with different timezones. $elparams = array('optional' => false, 'timezone' => $vals['timezone']); $el = new MoodleQuickForm_date_time_selector('dateselector', null, $elparams); $el->_createElements(); $expectedvalues = array('day' => array($vals['day']), 'month' => array($vals['month']), 'year' => array($vals['year']), 'hour' => array($vals['hour']), 'minute' => array($vals['minute'])); $mform->_submitValues = array('dateselector' => $vals['timestamp']); $el->onQuickFormEvent('updateValue', null, $mform); $this->assertSame($expectedvalues, $el->getValue()); } }