@@ -341,12 +341,12 @@ public function testParseHcardInCategory() {
341341 $ this ->assertArrayHasKey ('url ' , $ output ['items ' ][0 ]['properties ' ]['category ' ][0 ]['properties ' ]);
342342 $ this ->assertEquals ('http://b.example.com/ ' , $ output ['items ' ][0 ]['properties ' ]['category ' ][0 ]['properties ' ]['url ' ][0 ]);
343343 }
344-
344+
345345 public function testApplyTransformationToSrcset () {
346346 $ transformation = function ($ url ) {
347347 return 'https://example.com/ ' . ltrim ($ url , '/ ' );
348348 };
349-
349+
350350 // Example from https://developers.whatwg.org/edits.html#attr-img-srcset
351351 $ srcset = 'banner-HD.jpeg 2x, banner-phone.jpeg 100w, banner-phone-HD.jpeg 100w 2x ' ;
352352 $ result = Mf2 \applySrcsetUrlTransformation ($ srcset , $ transformation );
@@ -362,7 +362,7 @@ public function testRelativeURLResolvedWithFinalURL() {
362362
363363 $ this ->assertEquals ('https://aaronparecki.com/2014/12/23/5/photo.jpeg ' , $ mf ['items ' ][0 ]['properties ' ]['photo ' ][0 ]);
364364 }
365-
365+
366366 public function testScriptTagContentsRemovedFromTextValue () {
367367 $ input = <<<EOT
368368<div class="h-entry">
@@ -380,7 +380,7 @@ public function testScriptTagContentsRemovedFromTextValue() {
380380 $ this ->assertContains ('Hello World ' , $ output ['items ' ][0 ]['properties ' ]['content ' ][0 ]);
381381 $ this ->assertNotContains ('alert ' , $ output ['items ' ][0 ]['properties ' ]['content ' ][0 ]);
382382 }
383-
383+
384384 public function testScriptElementContentsRemovedFromAllPlaintextValues () {
385385 $ input = <<<EOT
386386<div class="h-entry">
@@ -391,7 +391,7 @@ public function testScriptElementContentsRemovedFromAllPlaintextValues() {
391391
392392 $ parser = new Parser ($ input );
393393 $ output = $ parser ->parse ();
394-
394+
395395 $ this ->assertNotContains ('not contained ' , $ output ['items ' ][0 ]['properties ' ]['published ' ][0 ]);
396396 $ this ->assertNotContains ('not contained ' , $ output ['items ' ][0 ]['properties ' ]['url ' ][0 ]);
397397 }
@@ -423,7 +423,7 @@ public function testScriptTagContentsNotRemovedFromHTMLValue() {
423423 $ this ->assertContains ('visibility ' , $ output ['items ' ][0 ]['properties ' ]['content ' ][0 ]['html ' ]);
424424 $ this ->assertNotContains ('visibility ' , $ output ['items ' ][0 ]['properties ' ]['content ' ][0 ]['value ' ]);
425425 }
426-
426+
427427 public function testWhitespaceBetweenElements () {
428428 $ input = <<<EOT
429429<div class="h-entry">
@@ -460,14 +460,14 @@ public function testCamelCaseClassNames() {
460460</span>
461461 <span class="u-hiddenInWideEnv"><a href="https://twitter.com/download" data-scribe="element:logo"><div class="Icon Icon--twitter " aria-label="Get Twitter app" title="Get Twitter app" role="img"></div></a></span>
462462 </div>
463-
463+
464464<div class="TweetAuthor" data-scribe="component:author">
465465 <a class="TweetAuthor-link Identity u-linkBlend" data-scribe="element:user_link" href="https://twitter.com/kevinmarks" aria-label="Kevin Marks (screen name: kevinmarks)">
466466 <span class="TweetAuthor-avatar Identity-avatar">
467467 <img class="Avatar" data-scribe="element:avatar" data-src-2x="https://pbs.twimg.com/profile_images/553009683087114240/tU5HkXEI_bigger.jpeg" alt="" data-src-1x="https://pbs.twimg.com/profile_images/553009683087114240/tU5HkXEI_normal.jpeg" src="https://pbs.twimg.com/profile_images/553009683087114240/tU5HkXEI_normal.jpeg">
468468 </span>
469469 <span class="TweetAuthor-name Identity-name customisable-highlight" title="Kevin Marks" data-scribe="element:name">Kevin Marks</span>
470-
470+
471471 <span class="TweetAuthor-screenName Identity-screenName" title="@kevinmarks" data-scribe="element:screen_name">@kevinmarks</span>
472472 </a>
473473</div>
@@ -479,7 +479,7 @@ public function testCamelCaseClassNames() {
479479
480480
481481 <div class="Tweet-metadata dateline">
482-
482+
483483
484484<a class="u-linkBlend u-url customisable-highlight long-permalink" data-datetime="2016-02-19T18:43:33+0000" data-scribe="element:full_timestamp" href="https://twitter.com/kevinmarks/status/700752598123433985">
485485<time class="dt-updated" datetime="2016-02-19T18:43:33+0000" pubdate="" title="Time posted: 19 Feb 2016, 18:43:33 (UTC)">10:43 AM - 19 Feb 2016</time></a>
@@ -598,5 +598,45 @@ public function testNoImpliedNameWhenNestedMicroformat()
598598 $ this ->assertArrayNotHasKey ('name ' , $ output ['items ' ][0 ]['properties ' ]);
599599 }
600600
601+ public function testChildObjects () {
602+ $ input = <<<END
603+ <html>
604+ <head>
605+ <title>Test</title>
606+ </head>
607+ <body>
608+
609+ <div class="h-feed">
610+ <a href="/author" class="p-author h-card">Author Name</a>
611+
612+ <ul>
613+ <li class="h-entry">
614+ <a href="/1" class="u-url p-name">One</a>
615+ </li>
616+ <li class="h-entry">
617+ <a href="/2" class="u-url p-name">Two</a>
618+ </li>
619+ <li class="h-entry">
620+ <a href="/3" class="u-url p-name">Three</a>
621+ </li>
622+ <li class="h-entry">
623+ <a href="/4" class="u-url p-name">Four</a>
624+ </li>
625+ </ul>
626+ </div>
627+
628+ </body>
629+ </html>
630+ END ;
631+ $ output = Mf2 \parse ($ input );
632+
633+ $ this ->assertEquals ('Author Name ' , $ output ['items ' ][0 ]['properties ' ]['author ' ][0 ]['properties ' ]['name ' ][0 ]);
634+ $ this ->assertEquals (4 , count ($ output ['items ' ][0 ]['children ' ]));
635+ $ this ->assertEquals ('One ' , count ($ output ['items ' ][0 ]['children ' ][0 ]['properties ' ]['name ' ][0 ]));
636+ $ this ->assertEquals ('Two ' , count ($ output ['items ' ][0 ]['children ' ][1 ]['properties ' ]['name ' ][0 ]));
637+ $ this ->assertEquals ('Three ' , count ($ output ['items ' ][0 ]['children ' ][2 ]['properties ' ]['name ' ][0 ]));
638+ $ this ->assertEquals ('Four ' , count ($ output ['items ' ][0 ]['children ' ][3 ]['properties ' ]['name ' ][0 ]));
639+ }
640+
601641}
602642
0 commit comments