mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
MDL-37286 improve coding style in unit tests
This commit is contained in:
parent
e7259ec998
commit
4fa7fdeada
@ -217,56 +217,46 @@ class web_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest(false);
|
||||
|
||||
$trace = new null_progress_trace();
|
||||
ob_start();
|
||||
$trace->output('do');
|
||||
$trace->output('re', 1);
|
||||
$trace->output('mi', 2);
|
||||
$trace->finished();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertSame('', $output);
|
||||
$this->expectOutputString('');
|
||||
}
|
||||
|
||||
public function test_text_progres_trace() {
|
||||
$this->resetAfterTest(false);
|
||||
|
||||
$trace = new text_progress_trace();
|
||||
ob_start();
|
||||
$trace->output('do');
|
||||
$trace->output('re', 1);
|
||||
$trace->output('mi', 2);
|
||||
$trace->finished();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertSame("do\n re\n mi\n", $output);
|
||||
$this->expectOutputString("do\n re\n mi\n");
|
||||
}
|
||||
|
||||
public function test_html_progres_trace() {
|
||||
$this->resetAfterTest(false);
|
||||
|
||||
$trace = new html_progress_trace();
|
||||
ob_start();
|
||||
$trace->output('do');
|
||||
$trace->output('re', 1);
|
||||
$trace->output('mi', 2);
|
||||
$trace->finished();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertSame("<p>do</p>\n<p>  re</p>\n<p>    mi</p>\n", $output);
|
||||
$this->expectOutputString("<p>do</p>\n<p>  re</p>\n<p>    mi</p>\n");
|
||||
}
|
||||
|
||||
public function test_html_list_progress_trace() {
|
||||
$this->resetAfterTest(false);
|
||||
|
||||
$trace = new html_list_progress_trace();
|
||||
ob_start();
|
||||
$trace->output('do');
|
||||
$trace->output('re', 1);
|
||||
$trace->output('mi', 2);
|
||||
$trace->finished();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertSame("<ul>\n<li>do<ul>\n<li>re<ul>\n<li>mi</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n", $output);
|
||||
$this->expectOutputString("<ul>\n<li>do<ul>\n<li>re<ul>\n<li>mi</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n");
|
||||
}
|
||||
|
||||
public function test_progres_trace_buffer() {
|
||||
@ -284,18 +274,15 @@ class web_testcase extends advanced_testcase {
|
||||
$this->assertSame($output, $trace->get_buffer());
|
||||
|
||||
$trace = new progress_trace_buffer(new html_progress_trace(), false);
|
||||
ob_start();
|
||||
$trace->output('do');
|
||||
$trace->output('re', 1);
|
||||
$trace->output('mi', 2);
|
||||
$trace->finished();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertSame('', $output);
|
||||
$this->assertSame("<p>do</p>\n<p>  re</p>\n<p>    mi</p>\n", $trace->get_buffer());
|
||||
$this->assertSame("<p>do</p>\n<p>  re</p>\n<p>    mi</p>\n", $trace->get_buffer());
|
||||
$trace->reset_buffer();
|
||||
$this->assertSame('', $trace->get_buffer());
|
||||
$this->expectOutputString('');
|
||||
}
|
||||
|
||||
public function test_combined_progres_trace() {
|
||||
@ -305,16 +292,12 @@ class web_testcase extends advanced_testcase {
|
||||
$trace2 = new progress_trace_buffer(new text_progress_trace(), false);
|
||||
|
||||
$trace = new combined_progress_trace(array($trace1, $trace2));
|
||||
|
||||
ob_start();
|
||||
$trace->output('do');
|
||||
$trace->output('re', 1);
|
||||
$trace->output('mi', 2);
|
||||
$trace->finished();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertSame('', $output);
|
||||
$this->assertSame("<p>do</p>\n<p>  re</p>\n<p>    mi</p>\n", $trace1->get_buffer());
|
||||
$this->assertSame("do\n re\n mi\n", $trace2->get_buffer());
|
||||
$this->expectOutputString('');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user