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

Fake html body #1237

Closed
wants to merge 9 commits into from
Closed

Conversation

rudkjobing
Copy link
Contributor

No description provided.

@WillGibson
Copy link

@rudkjobing Very odd, all the other PRs are doing Travis builds, why not this one? I don't think it's anything to do with this PR or the code in it.

slyngel@gmail.com and others added 2 commits June 20, 2017 16:34
…ument.

-Changes from code review.

-Rename randomBody method to randomHTMLBody

Fix indenting
Copy link

@WillGibson WillGibson left a comment

Choose a reason for hiding this comment

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

I have just noticed whilst using it for real, that it seems to sometimes return "textless" HTML, e.g.

<div id="36115"></div><div id="21890"><div class="nam"></div><div id="80145"></div><div class="ut"></div></div><div class="qui"></div>

I suspect this is not what we want, so I'm going to have a poke around and maybe submit a PR to your branch if I solve it.

I'll be playing around here...

https://github.com/BiffBangPow/Faker/tree/fake_html_body

Update: I think I've done it, but I need to dash off and be a drummer now, so will review it in the morning.

*
* @return string
*/
public function randomBodyFragments($maxDepth = 4, $maxWidth = 4)

Choose a reason for hiding this comment

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

Could this be randomHTMLFragments?

Choose a reason for hiding this comment

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

I have done this in my fork

@@ -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);

Choose a reason for hiding this comment

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

I think $error should be $isValidHtml like in the test below.

Choose a reason for hiding this comment

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

Done in my fork.

Copy link

@WillGibson WillGibson left a comment

Choose a reason for hiding this comment

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

@rudkjobing I've almost got it never making HTML without any actual text in it. Still something in there does no text sometimes. I'm working on that.

Because the builds aren't playing ball with this PR, once I get that last bit sorted, I'll maybe try doing a PR back to fzaninotto/Faker and see if it does builds.

@@ -129,7 +159,8 @@ private function addRandomAttribute(\DOMElement $node)
$node->setAttribute("class", $this->generator->word);
break;
case 2:
$node->setAttribute("id", (string)$this->idGenerator->randomNumber(5));
$randomNumber = $this->generator->randomNumber(5);

Choose a reason for hiding this comment

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

This line want another space, or it the builds will fail on the code sniffing stage.

Choose a reason for hiding this comment

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

It was tabs not spaces. Done in my fork.

*
* @return string
*/
public function randomBodyFragments($maxDepth = 4, $maxWidth = 4)

Choose a reason for hiding this comment

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

I have done this in my fork

@@ -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);

Choose a reason for hiding this comment

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

Done in my fork.

@WillGibson
Copy link

@rudkjobing Latest update is, that I think I'm on top of it, but the builds are only working PHP 5.6+. I've just installed 5.3.29 with PHPBrew to see what that's about.

@WillGibson
Copy link

WillGibson commented Jun 21, 2017

Hi @rudkjobing I have a PR with passing builds here #1238.

If you're happy to roll with that, please could you kill this PR to avoid confusion.

Thanks,

Will

@rudkjobing rudkjobing closed this Jun 21, 2017
@rudkjobing rudkjobing deleted the fake_html_body branch June 21, 2017 13:23
@WillGibson
Copy link

Thanks @rudkjobing I just corrected the link above to my PR.

@rudkjobing
Copy link
Contributor Author

@WillGibson you are very welcome. Thanks for picking up my slack :-)

@fzaninotto fzaninotto mentioned this pull request Dec 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants