Skip to content

Commit

Permalink
HtmlDocumentTest: Add nested array tests for add(), prepend() and…
Browse files Browse the repository at this point in the history
… `setContent()`
  • Loading branch information
nilmerg committed Jun 21, 2021
1 parent 8e7e659 commit fddcdde
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tests/HtmlDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,70 @@ public function testAcceptsObjectsWhichCanBeCastedToString()
$this->assertEquals('Some String <:-)', $a->render());
}

public function testSetContentFlattensNestedArrays()
{
$doc = new HtmlDocument();
$doc->setSeparator(';');
$doc->setContent([
h::tag('span'),
[
'foo',
'bar',
[
h::tag('p', 'test'),
h::tag('strong', 'bla')
]
]
]);
$this->assertHtml(
'<span></span>;foo;bar;<p>test</p>;<strong>bla</strong>',
$doc
);
}


public function testAddFlattensNestedArrays()
{
$doc = new HtmlDocument();
$doc->setSeparator(';');
$doc->add([
h::tag('span'),
[
'foo',
'bar',
[
h::tag('p', 'test'),
h::tag('strong', 'bla')
]
]
]);
$this->assertHtml(
'<span></span>;foo;bar;<p>test</p>;<strong>bla</strong>',
$doc
);
}

public function testPrependFlattensNestedArrays()
{
$doc = new HtmlDocument();
$doc->setSeparator(';');
$doc->prepend([
h::tag('span'),
[
'foo',
'bar',
[
h::tag('p', 'test'),
h::tag('strong', 'bla')
]
]
]);
$this->assertHtml(
'<span></span>;foo;bar;<p>test</p>;<strong>bla</strong>',
$doc
);
}

public function testSkipsNullValues()
{
$a = new HtmlDocument();
Expand Down

0 comments on commit fddcdde

Please sign in to comment.