Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

HTML Lorem #971

Merged
merged 26 commits into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Faker/Provider/HtmlLorem.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ private static function addRandomTable(\DOMElement $element, $maxRows = 10, $max
$tr = $element->ownerDocument->createElement(HtmlLorem::TR_TAG);
$thead->appendChild($tr);
for ($i = 0; $i < $cols; $i++) {
$th = $element->ownerDocument->createElement(HtmlLorem::TR_TAG);
$th = $element->ownerDocument->createElement(HtmlLorem::TH_TAG);
$th->textContent = Lorem::sentence(mt_rand(1, $maxTitle));
$tr->appendChild($th);
}
for ($i = 0; $i < $rows; $i++) {
$tr = $element->ownerDocument->createElement("tr");
$tr = $element->ownerDocument->createElement(HtmlLorem::TR_TAG);
$tbody->appendChild($tr);
for ($j = 0; $j < $cols; $j++) {
$th = $element->ownerDocument->createElement("td");
$th = $element->ownerDocument->createElement(HtmlLorem::TD_TAG);
$th->textContent = Lorem::sentence(mt_rand(1, $maxLength));
$tr->appendChild($th);
}
Expand Down
10 changes: 10 additions & 0 deletions test/Faker/Provider/HtmlLoremTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@ public function testProvider()
$this->assertStringEndsWith("</html>\n", $node);
}

public function testRandomHtmlReturnsValidHTMLString(){
$faker = new Generator();
$faker->addProvider(new HtmlLorem($faker));
$node = $faker->randomHtml(6, 10);
$dom = new \DOMDocument();
$error = $dom->loadHTML($node);
$this->assertTrue($error);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line feed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

}

}