Skip to content

Commit e5ec9c3

Browse files
committed
tests: added tableTest coverage
1 parent b65156e commit e5ec9c3

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

tests/system/View/TableTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,54 @@ public function testGenerate()
429429
$this->assertStringContainsString('<td>12345</td>', $table);
430430
}
431431

432+
public function testGenerateOther()
433+
{
434+
// Prepare the data
435+
$data = [
436+
[
437+
['data' => 'Fred', 'style' => 'cssFred'],
438+
['data' => 'Blue', 'style' => 'cssBlue'],
439+
['data' => 'Small', 'style' => 'cssSmall'],
440+
],
441+
[
442+
'Mary',
443+
'Red',
444+
'Large',
445+
],
446+
[
447+
'John',
448+
'Green',
449+
'Medium',
450+
],
451+
];
452+
453+
$this->table->setCaption('Awesome table');
454+
$this->table->setHeading(['Name', 'Color', 'Size']);
455+
456+
$subtotal = 12345;
457+
458+
$this->table->setFooting('Subtotal', $subtotal);
459+
460+
$table = $this->table->generate($data);
461+
462+
// Test the table header
463+
$this->assertStringContainsString('<th>Name</th>', $table);
464+
$this->assertStringContainsString('<th>Color</th>', $table);
465+
$this->assertStringContainsString('<th>Size</th>', $table);
466+
467+
// Test the first entry
468+
$this->assertStringContainsString('<td style="cssFred">Fred</td>', $table);
469+
$this->assertStringContainsString('<td style="cssBlue">Blue</td>', $table);
470+
$this->assertStringContainsString('<td style="cssSmall">Small</td>', $table);
471+
472+
// Check for the caption
473+
$this->assertStringContainsString('<caption>Awesome table</caption>', $table);
474+
475+
// Test the table footing
476+
$this->assertStringContainsString('<td>Subtotal</td>', $table);
477+
$this->assertStringContainsString('<td>12345</td>', $table);
478+
}
479+
432480
public function testGenerateTdWithClassStyle()
433481
{
434482
$template = [

0 commit comments

Comments
 (0)