',
html_writer::start_div('', array('id' => 'kermit')));
// No options.
$this->assertSame('
',
html_writer::start_div());
}
/**
* @covers ::end_div
*/
public function test_end_div() {
$this->assertSame('
', html_writer::end_div());
}
/**
* @covers ::span
*/
public function test_span() {
// All options.
$this->assertSame('ribbit',
html_writer::span('ribbit', 'frog', array('id' => 'kermit')));
// Combine class from attributes and $class.
$this->assertSame('ribbit',
html_writer::span('ribbit', 'frog', array('class' => 'amphibian')));
// Class only.
$this->assertSame('ribbit',
html_writer::span('ribbit', 'frog'));
// Attributes only.
$this->assertSame('ribbit',
html_writer::span('ribbit', '', array('id' => 'kermit')));
// No options.
$this->assertSame('ribbit',
html_writer::span('ribbit'));
}
/**
* @covers ::start_span
*/
public function test_start_span() {
// All options.
$this->assertSame('',
html_writer::start_span('frog', array('id' => 'kermit')));
// Combine class from attributes and $class.
$this->assertSame('',
html_writer::start_span('frog', array('class' => 'amphibian')));
// Class only.
$this->assertSame('',
html_writer::start_span('frog'));
// Attributes only.
$this->assertSame('',
html_writer::start_span('', array('id' => 'kermit')));
// No options.
$this->assertSame('',
html_writer::start_span());
}
/**
* @covers ::end_span
*/
public function test_end_span() {
$this->assertSame('', html_writer::end_span());
}
/**
* @covers ::table
* @covers \html_table_row
* @covers \html_table_cell
* @covers \html_table
*/
public function test_table() {
$row = new html_table_row();
// The attribute will get overwritten by the ID.
$row->id = 'Bob';
$row->attributes['id'] = 'will get overwritten';
// The data-name will be present in the output.
$row->attributes['data-name'] = 'Fred';
$cell = new html_table_cell();
// The attribute will get overwritten by the ID.
$cell->id = 'Jeremy';
$cell->attributes['id'] = 'will get overwritten';
// The data-name will be present in the output.
$cell->attributes['data-name'] = 'John';
$row->cells[] = $cell;
$table = new html_table();
$table->responsive = false;
// The attribute will get overwritten by the ID.
$table->id = 'Jeffrey';
$table->attributes['id'] = 'will get overwritten';
// The data-name will be present in the output.
$table->attributes['data-name'] = 'Colin';
// The attribute will get overwritten by the ID above.
$table->data[] = $row;
// Specify a caption to be output.
$table->caption = "A table of meaningless data.";
$output = html_writer::table($table);
$expected = <<