Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 125... Línea 125...
125
 
125
 
126
        $table->setup();
126
        $table->setup();
127
        return $table;
127
        return $table;
Línea 128... Línea 128...
128
    }
128
    }
129
 
129
 
130
    public function test_empty_table() {
130
    public function test_empty_table(): void {
131
        $this->expectOutputRegex('/' . get_string('nothingtodisplay') . '/');
131
        $this->expectOutputRegex('/' . get_string('nothingtodisplay') . '/');
132
        $this->run_table_test(
132
        $this->run_table_test(
133
            array('column1', 'column2'),       // Columns.
133
            array('column1', 'column2'),       // Columns.
Línea 139... Línea 139...
139
            array(),                           // Data.
139
            array(),                           // Data.
140
            10                                 // Page size.
140
            10                                 // Page size.
141
        );
141
        );
142
    }
142
    }
Línea 143... Línea 143...
143
 
143
 
Línea 144... Línea 144...
144
    public function test_has_next_pagination() {
144
    public function test_has_next_pagination(): void {
145
 
145
 
146
        $data = $this->generate_data(11, 2);
146
        $data = $this->generate_data(11, 2);
Línea 160... Línea 160...
160
            $data,
160
            $data,
161
            10
161
            10
162
        );
162
        );
163
    }
163
    }
Línea 164... Línea 164...
164
 
164
 
Línea 165... Línea 165...
165
    public function test_has_hide() {
165
    public function test_has_hide(): void {
166
 
166
 
167
        $data = $this->generate_data(11, 2);
167
        $data = $this->generate_data(11, 2);
Línea 181... Línea 181...
181
            $data,
181
            $data,
182
            10
182
            10
183
        );
183
        );
184
    }
184
    }
Línea 185... Línea 185...
185
 
185
 
Línea 186... Línea 186...
186
    public function test_has_not_hide() {
186
    public function test_has_not_hide(): void {
187
 
187
 
188
        $data = $this->generate_data(11, 2);
188
        $data = $this->generate_data(11, 2);
Línea 205... Línea 205...
205
        $output = ob_get_contents();
205
        $output = ob_get_contents();
206
        ob_end_clean();
206
        ob_end_clean();
207
        $this->assertStringNotContainsString(get_string('hide'), $output);
207
        $this->assertStringNotContainsString(get_string('hide'), $output);
208
    }
208
    }
Línea 209... Línea 209...
209
 
209
 
Línea 210... Línea 210...
210
    public function test_has_sort() {
210
    public function test_has_sort(): void {
211
 
211
 
212
        $data = $this->generate_data(11, 2);
212
        $data = $this->generate_data(11, 2);
Línea 226... Línea 226...
226
            $data,
226
            $data,
227
            10
227
            10
228
        );
228
        );
229
    }
229
    }
Línea 230... Línea 230...
230
 
230
 
Línea 231... Línea 231...
231
    public function test_has_not_sort() {
231
    public function test_has_not_sort(): void {
232
 
232
 
233
        $data = $this->generate_data(11, 2);
233
        $data = $this->generate_data(11, 2);
Línea 250... Línea 250...
250
        $output = ob_get_contents();
250
        $output = ob_get_contents();
251
        ob_end_clean();
251
        ob_end_clean();
252
        $this->assertStringNotContainsString(get_string('sortby'), $output);
252
        $this->assertStringNotContainsString(get_string('sortby'), $output);
253
    }
253
    }
Línea 254... Línea 254...
254
 
254
 
Línea 255... Línea 255...
255
    public function test_has_not_next_pagination() {
255
    public function test_has_not_next_pagination(): void {
256
 
256
 
257
        $data = $this->generate_data(10, 2);
257
        $data = $this->generate_data(10, 2);
Línea 275... Línea 275...
275
        $output = ob_get_contents();
275
        $output = ob_get_contents();
276
        ob_end_clean();
276
        ob_end_clean();
277
        $this->assertStringNotContainsString(get_string('next'), $output);
277
        $this->assertStringNotContainsString(get_string('next'), $output);
278
    }
278
    }
Línea 279... Línea 279...
279
 
279
 
Línea 280... Línea 280...
280
    public function test_1_col() {
280
    public function test_1_col(): void {
281
 
281
 
282
        $data = $this->generate_data(100, 1);
282
        $data = $this->generate_data(100, 1);
Línea 295... Línea 295...
295
            $data,
295
            $data,
296
            10
296
            10
297
        );
297
        );
298
    }
298
    }
Línea 299... Línea 299...
299
 
299
 
Línea 300... Línea 300...
300
    public function test_empty_rows() {
300
    public function test_empty_rows(): void {
301
 
301
 
302
        $data = $this->generate_data(1, 5);
302
        $data = $this->generate_data(1, 5);
Línea 316... Línea 316...
316
            $data,
316
            $data,
317
            10
317
            10
318
        );
318
        );
319
    }
319
    }
Línea 320... Línea 320...
320
 
320
 
Línea 321... Línea 321...
321
    public function test_5_cols() {
321
    public function test_5_cols(): void {
322
 
322
 
323
        $data = $this->generate_data(100, 5);
323
        $data = $this->generate_data(100, 5);
Línea 336... Línea 336...
336
            $data,
336
            $data,
337
            10
337
            10
338
        );
338
        );
339
    }
339
    }
Línea 340... Línea 340...
340
 
340
 
Línea 341... Línea 341...
341
    public function test_50_cols() {
341
    public function test_50_cols(): void {
342
 
342
 
343
        $data = $this->generate_data(100, 50);
343
        $data = $this->generate_data(100, 50);
Línea 377... Línea 377...
377
     * @param string $format
377
     * @param string $format
378
     * @return void
378
     * @return void
379
     *
379
     *
380
     * @dataProvider fullname_column_provider
380
     * @dataProvider fullname_column_provider
381
     */
381
     */
382
    public function test_fullname_column(string $format) {
382
    public function test_fullname_column(string $format): void {
383
        $this->resetAfterTest();
383
        $this->resetAfterTest();
384
        $this->setAdminUser();
384
        $this->setAdminUser();
Línea 385... Línea 385...
385
 
385
 
Línea 397... Línea 397...
397
     * @param string $format
397
     * @param string $format
398
     * @return void
398
     * @return void
399
     *
399
     *
400
     * @dataProvider fullname_column_provider
400
     * @dataProvider fullname_column_provider
401
     */
401
     */
402
    public function test_fullname_column_prohibit_viewfullnames(string $format) {
402
    public function test_fullname_column_prohibit_viewfullnames(string $format): void {
403
        global $DB, $CFG;
403
        global $DB, $CFG;
Línea 404... Línea 404...
404
 
404
 
Línea 405... Línea 405...
405
        $this->resetAfterTest();
405
        $this->resetAfterTest();
Línea 417... Línea 417...
417
 
417
 
418
        $table = $this->create_and_setup_table(['fullname'], [], true, false, [], []);
418
        $table = $this->create_and_setup_table(['fullname'], [], true, false, [], []);
419
        $this->assertStringContainsString(fullname($user, false), $table->format_row($user)['fullname']);
419
        $this->assertStringContainsString(fullname($user, false), $table->format_row($user)['fullname']);
Línea 420... Línea 420...
420
    }
420
    }
421
 
421
 
422
    public function test_get_row_html() {
422
    public function test_get_row_html(): void {
423
        $data = $this->generate_data(1, 5);
423
        $data = $this->generate_data(1, 5);
424
        $columns = $this->generate_columns(5);
424
        $columns = $this->generate_columns(5);
Línea 434... Línea 434...
434
        $this->assertMatchesRegularExpression('/row 0 col 0/', $row);
434
        $this->assertMatchesRegularExpression('/row 0 col 0/', $row);
435
        $this->assertMatchesRegularExpression('/<tr class=""/', $row);
435
        $this->assertMatchesRegularExpression('/<tr class=""/', $row);
436
        $this->assertMatchesRegularExpression('/<td class="cell c0"/', $row);
436
        $this->assertMatchesRegularExpression('/<td class="cell c0"/', $row);
437
    }
437
    }
Línea 438... Línea 438...
438
 
438
 
439
    public function test_persistent_table() {
439
    public function test_persistent_table(): void {
Línea 440... Línea 440...
440
        global $SESSION;
440
        global $SESSION;
441
 
441
 
442
        $data = $this->generate_data(5, 5);
442
        $data = $this->generate_data(5, 5);
Línea 590... Línea 590...
590
        $table->is_persistent(false);
590
        $table->is_persistent(false);
Línea 591... Línea 591...
591
 
591
 
592
        return $table;
592
        return $table;
Línea 593... Línea 593...
593
    }
593
    }
594
 
594
 
595
    public function test_can_be_reset() {
595
    public function test_can_be_reset(): void {
596
        // Table in its default state (as if seen for the first time), nothing to reset.
596
        // Table in its default state (as if seen for the first time), nothing to reset.
597
        $table = $this->prepare_table_for_reset_test(uniqid('tablelib_test_'));
597
        $table = $this->prepare_table_for_reset_test(uniqid('tablelib_test_'));
Línea 687... Línea 687...
687
    }
687
    }
Línea 688... Línea 688...
688
 
688
 
689
    /**
689
    /**
690
     * Test export in CSV format
690
     * Test export in CSV format
691
     */
691
     */
692
    public function test_table_export() {
692
    public function test_table_export(): void {
693
        $table = new flexible_table('tablelib_test_export');
693
        $table = new flexible_table('tablelib_test_export');
694
        $table->define_baseurl('/invalid.php');
694
        $table->define_baseurl('/invalid.php');
695
        $table->define_columns(['c1', 'c2', 'c3']);
695
        $table->define_columns(['c1', 'c2', 'c3']);