MDL-72744 table: Improve PHPUnit test
This commit is contained in:
+11
-11
@@ -835,7 +835,7 @@ final class tablelib_test extends \advanced_testcase {
|
||||
public function test_table_exports_escaped_formulas(): void {
|
||||
$table = new flexible_table('tablelib_test_export');
|
||||
$table->define_baseurl('/invalid.php');
|
||||
$table->define_columns(['c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8']);
|
||||
$table->define_columns(['c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6']);
|
||||
|
||||
ob_start();
|
||||
$table->is_downloadable(true);
|
||||
@@ -843,19 +843,19 @@ final class tablelib_test extends \advanced_testcase {
|
||||
|
||||
$table->setup();
|
||||
$table->add_data([
|
||||
'column0' => "\t=SUM(1+1)", // With tab.
|
||||
'column1' => "\r=SUM(1+1)", // With carriage return.
|
||||
'column2' => "\n=SUM(1+1)", // With new line.
|
||||
'column3' => "=SUM(1+1)",
|
||||
'column4' => "=1+1",
|
||||
'column5' => "+1+1",
|
||||
'column6' => "-1+1",
|
||||
'column7' => "@A1",
|
||||
'column8' => "-", // Single dash (should not be escaped).
|
||||
'column0' => " =SUM(1+1)", // With spaces.
|
||||
'column1' => "=SUM(1+1)",
|
||||
'column2' => "=1+1",
|
||||
'column3' => "+1+1",
|
||||
'column4' => "-1+1",
|
||||
'column5' => "@A1",
|
||||
'column6' => "-", // Single dash (should not be escaped).
|
||||
]);
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertEquals("\n'=SUM(1+1),'=SUM(1+1),'=SUM(1+1),'=SUM(1+1),'=1+1,'+1+1,'-1+1,'@A1,-\n", substr($output, 3));
|
||||
$matchregex = "/\"?' =SUM\(1\+1\)\"?,'=SUM\(1\+1\),'=1\+1,'\+1\+1,'-1\+1,'@A1,-/";
|
||||
$this->assertMatchesRegularExpression($matchregex, $output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user