mirror of
https://github.com/moodle/moodle.git
synced 2025-05-03 14:58:42 +02:00
MDL-65919 core: add test for table download
This commit is contained in:
parent
40a6b502ae
commit
b51bfaf594
@ -618,4 +618,26 @@ class core_tablelib_testcase extends basic_testcase {
|
||||
unset($_GET['tifirst']);
|
||||
$this->assertTrue($table->can_be_reset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test export in CSV format
|
||||
*/
|
||||
public function test_table_export() {
|
||||
$table = new flexible_table('tablelib_test_export');
|
||||
$table->define_baseurl('/invalid.php');
|
||||
$table->define_columns(['c1', 'c2', 'c3']);
|
||||
$table->define_headers(['Col1', 'Col2', 'Col3']);
|
||||
|
||||
ob_start();
|
||||
$table->is_downloadable(true);
|
||||
$table->is_downloading('csv');
|
||||
|
||||
$table->setup();
|
||||
$table->add_data(['column0' => 'a', 'column1' => 'b', 'column2' => 'c']);
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertEquals("Col1,Col2,Col3\na,b,c\n", substr($output, 3));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user