-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add the option to generate HTML fragments and the body of an HTML doc… #1159
Conversation
@fzaninotto Hmm is master broken? Tests wont run for me after I merged master into my fork.
|
Sorry to be that guy, but any update on this? |
$faker = new Generator(); | ||
$faker->addProvider(new HtmlLorem($faker)); | ||
$node = $faker->randomBody(5, 5); | ||
echo $node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want the echo $node;
line?
$node = $faker->randomHtml(6, 10); | ||
$node = $faker->randomHtml(5, 5); | ||
$dom = new \DOMDocument(); | ||
$error = $dom->loadHTML($node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $isValidHTML
would make more sense than $error
as a variable name here and below.
Are, I was about to start making a a very similar PR. If you want any help getting this through the pip @Zhastreaus , give me a shout. |
@WillGibson nope this is not my PR, I think it's @rudkjobing 's |
@rudkjobing I'm going to fork from your fork and see if I can get the builds passing as I'd like to use this feature. |
I must be blind |
@@ -20,10 +20,27 @@ public function testProvider() | |||
public function testRandomHtmlReturnsValidHTMLString(){ | |||
$faker = new Generator(); | |||
$faker->addProvider(new HtmlLorem($faker)); | |||
$node = $faker->randomHtml(6, 10); | |||
$node = $faker->randomHtml(5, 5); | |||
$dom = new \DOMDocument(); | |||
$error = $dom->loadHTML($node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe $isValidHtml
instead of $error
here too?
Looking good now @rudkjobing. Can't see any build info here now. Are they passing now you fixed the fatal error? |
@rudkjobing I have a passing build here https://travis-ci.org/BiffBangPow/Faker/jobs/244895238. I'll try to submit a PR to your branch your with the fix. |
Awesome, thanks! |
Fix indenting to make builds pass
Travis doesn't seem to run automatically? |
It should run automatically because this is a PR I think, but you might need to log into Travis and add you repo/branch maybe? |
I havn't had issues with travis before. Don't really know what the problem is. |
Me neither, and I can't play with your Travis builds directly I guess. It should build automatically under fzaninotto/Faker as it's a PR, at least that what I thought. @fzaninotto Can you help here? I had a passing build here (https://travis-ci.org/BiffBangPow/Faker/builds/244900976) if that's any use. |
src/Faker/Provider/HtmlLorem.php
Outdated
* | ||
* @return string | ||
*/ | ||
public function randomBody($maxDepth = 4, $maxWidth = 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I'm using this in my actual developing code, I think this would be better called randomHTMLBody
.
Going to open a new pull request, to see if that helps. |
Hi @rudkjobing Fingers crossed re the new PR. Please forgive my amatuerish approach to commenting on PRs in GitHub, I'm just getting used to how it all works (we use BitBucket here at work so the UI is different) and trying to get a bit more involved, help out with open source stuff. There's a couple more comments in there from me that I would like addressed unless you disagree with them, then I'm totally going to approve this PR which has saved me doing the same thing over here. https://github.com/fzaninotto/Faker/pull/1159/files#diff-ecbf0f117b3c8b63635081589370cce6R91 https://github.com/fzaninotto/Faker/pull/1159/files#diff-b3f77ef5414bc4a1b3641d7567ae3998R25 Will |
Hi Will. Don't worry! I did change the code based on your change requests. I made a new PR here: #1237 but travis still ignores it. |
Implement feature requested here: #971 (comment)