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 dateselector_test extends \advanced_testcase {
49
final class dateselector_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 145... Línea 145...
145
 
145
 
146
    /**
146
    /**
147
     * Testcase to check onQuickformEvent
147
     * Testcase to check onQuickformEvent
148
     */
148
     */
149
    public function test_onquickformevent(): void {
149
    public function test_onquickformevent(): void {
150
        global $USER;
150
        global $OUTPUT, $USER;
151
        $testvals = $this->testvals;
151
        $testvals = $this->testvals;
152
        // Get dummy form for data.
152
        // Get dummy form for data.
Línea 153... Línea 153...
153
        $mform = $this->mform;
153
        $mform = $this->mform;
Línea 158... Línea 158...
158
 
158
 
159
            // Create dateselector element with different timezones.
159
            // Create dateselector element with different timezones.
160
            $elparams = array('optional'=>false, 'timezone' => $vals['timezone']);
160
            $elparams = array('optional'=>false, 'timezone' => $vals['timezone']);
161
            $el = $this->mform->addElement('date_selector', 'dateselector', null, $elparams);
161
            $el = $this->mform->addElement('date_selector', 'dateselector', null, $elparams);
162
            $this->assertTrue($el instanceof MoodleQuickForm_date_selector);
162
            $this->assertTrue($el instanceof MoodleQuickForm_date_selector);
163
            $expectedvalues = array(
163
            $expectedvalues = [
164
                'day' => array($vals['day']),
164
                'day' => [$vals['day']],
165
                'month' => array($vals['month']),
165
                'month' => [$vals['month']],
-
 
166
                'year' => [$vals['year']],
166
                'year' => array($vals['year'])
167
                'calendar' => $OUTPUT->pix_icon('i/calendar', ''),
167
                );
168
            ];
168
            $mform->_submitValues = array('dateselector' => $vals['timestamp']);
169
            $mform->_submitValues = array('dateselector' => $vals['timestamp']);
169
            $el->onQuickFormEvent('updateValue', null, $mform);
170
            $el->onQuickFormEvent('updateValue', null, $mform);
170
            $this->assertSame($expectedvalues, $el->getValue());
171
            $this->assertSame($expectedvalues, $el->getValue());
171
        }
172
        }