Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 44... Línea 44...
44
 * @package    core_form
44
 * @package    core_form
45
 * @category   test
45
 * @category   test
46
 * @copyright  2012 Rajesh Taneja
46
 * @copyright  2012 Rajesh Taneja
47
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
47
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
48
 */
48
 */
49
class datetimeselector_test extends \advanced_testcase {
49
final class datetimeselector_test extends \advanced_testcase {
50
    /** @var \MoodleQuickForm Keeps reference of dummy form object */
50
    /** @var \MoodleQuickForm Keeps reference of dummy form object */
51
    private $mform;
51
    private $mform;
52
    /** @var array test fixtures */
52
    /** @var array test fixtures */
53
    private $testvals;
53
    private $testvals;
Línea 157... Línea 157...
157
 
157
 
158
    /**
158
    /**
159
     * Testcase to check onQuickformEvent
159
     * Testcase to check onQuickformEvent
160
     */
160
     */
161
    public function test_onquickformevent(): void {
161
    public function test_onquickformevent(): void {
162
        global $USER;
162
        global $OUTPUT, $USER;
163
        $testvals = $this->testvals;
163
        $testvals = $this->testvals;
164
        // Get dummy form for data.
164
        // Get dummy form for data.
Línea 165... Línea 165...
165
        $mform = $this->mform;
165
        $mform = $this->mform;
Línea 170... Línea 170...
170
 
170
 
171
            // Create dateselector element with different timezones.
171
            // Create dateselector element with different timezones.
172
            $elparams = array('optional'=>false, 'timezone' => $vals['timezone']);
172
            $elparams = array('optional'=>false, 'timezone' => $vals['timezone']);
173
            $el = $this->mform->addElement('date_time_selector', 'dateselector', null, $elparams);
173
            $el = $this->mform->addElement('date_time_selector', 'dateselector', null, $elparams);
174
            $this->assertTrue($el instanceof MoodleQuickForm_date_time_selector);
174
            $this->assertTrue($el instanceof MoodleQuickForm_date_time_selector);
175
            $expectedvalues = array(
175
            $expectedvalues = [
176
                'day' => array($vals['day']),
176
                'day' => [$vals['day']],
177
                'month' => array($vals['month']),
177
                'month' => [$vals['month']],
178
                'year' => array($vals['year']),
178
                'year' => [$vals['year']],
179
                'hour' => array($vals['hour']),
179
                'hour' => [$vals['hour']],
-
 
180
                'minute' => [$vals['minute']],
180
                'minute' => array($vals['minute'])
181
                'calendar' => $OUTPUT->pix_icon('i/calendar', ''),
181
                );
182
            ];
182
            $mform->_submitValues = array('dateselector' => $vals['timestamp']);
183
            $mform->_submitValues = array('dateselector' => $vals['timestamp']);
183
            $el->onQuickFormEvent('updateValue', null, $mform);
184
            $el->onQuickFormEvent('updateValue', null, $mform);
184
            $this->assertSame($expectedvalues, $el->getValue());
185
            $this->assertSame($expectedvalues, $el->getValue());
185
        }
186
        }