@@ -113,10 +113,16 @@ public function testParsesFBerrimanClassicHEntry() {
113113 $ this ->assertContains ('txjs ' , $ e ['properties ' ]['category ' ]);
114114 }
115115
116- public function testParsesSnarfedOrgArticleCorrectly () {
116+ /**
117+ * This test appears to have never made assertions. When initially
118+ * added it was only printing out the parsed results, probably for
119+ * debugging. Left for reference in case assertions need to be added.
120+ * @see https://github.com/microformats/php-mf2/commit/5fd2c961447f305f50f73e17bd8decf7ec77fa1d#diff-45371c4a595b936f718ab44eb3ff35c326e00a01f2f5cb3d327f34d03750b872
121+ */
122+ /*public function testParsesSnarfedOrgArticleCorrectly() {
117123 $input = file_get_contents(__DIR__ . '/snarfed.org.html');
118124 $result = Mf2\parse($input, 'http://snarfed.org/2013-10-23_oauth-dropins');
119- }
125+ }*/
120126
121127 public function testParsesHProduct () {
122128 $ input = <<<'EOT'
@@ -761,6 +767,7 @@ public function testParsesClassicHreview() {
761767 </div>
762768 <p>Visit date: <span>April 2005</span></p>
763769 <p>Food eaten: <span>Florentine crepe</span></p>
770+ <p>Permanent link for review: <a rel="self bookmark" href="http://example.com/crepe">http://example.com/crepe</a></p>
764771</div>
765772END ;
766773 $ parser = new Parser ($ input );
@@ -946,6 +953,54 @@ public function testHReviewRelTag() {
946953 $ this ->assertContains ('Garçon ' , $ output ['items ' ][0 ]['properties ' ]['category ' ]);
947954 }
948955
956+ public function testHReviewItemVevent ()
957+ {
958+ $ input = '<div class="hreview">
959+ <span><span class="rating">5</span> out of 5 stars</span>
960+ <span class="item vevent">
961+ <span class="summary">IndieWebCamp 2014</span> -
962+ <a href="https://indieweb.org/2014" class="url">indieweb.org/2014</a>
963+ </span>
964+ </div> ' ;
965+ $ parser = new Parser ($ input );
966+ $ output = $ parser ->parse ();
967+
968+ $ this ->assertArrayHasKey ('item ' , $ output ['items ' ][0 ]['properties ' ]);
969+
970+ # assert item type is h-event
971+ $ this ->assertCount (1 , $ output ['items ' ][0 ]['properties ' ]['item ' ][0 ]['type ' ]);
972+ $ this ->assertEquals ('h-event ' , $ output ['items ' ][0 ]['properties ' ]['item ' ][0 ]['type ' ][0 ]);
973+
974+ # assert expected h-event properties
975+ $ properties = $ output ['items ' ][0 ]['properties ' ]['item ' ][0 ]['properties ' ];
976+ $ this ->assertArrayHasKey ('name ' , $ properties );
977+ $ this ->assertArrayHasKey ('url ' , $ properties );
978+ }
979+
980+ public function testHReviewItemHproduct ()
981+ {
982+ $ input = '<div class="hreview">
983+ <span><span class="rating">4</span> out of 5 stars</span>
984+ <span class="item hproduct">
985+ <span class="fn">Widget</span> -
986+ <a href="https://example.com/widget/" class="url">example.com/widget/</a>
987+ </span>
988+ </div> ' ;
989+ $ parser = new Parser ($ input );
990+ $ output = $ parser ->parse ();
991+
992+ $ this ->assertArrayHasKey ('item ' , $ output ['items ' ][0 ]['properties ' ]);
993+
994+ # assert item type is h-product
995+ $ this ->assertCount (1 , $ output ['items ' ][0 ]['properties ' ]['item ' ][0 ]['type ' ]);
996+ $ this ->assertEquals ('h-product ' , $ output ['items ' ][0 ]['properties ' ]['item ' ][0 ]['type ' ][0 ]);
997+
998+ # assert expected h-product properties
999+ $ properties = $ output ['items ' ][0 ]['properties ' ]['item ' ][0 ]['properties ' ];
1000+ $ this ->assertArrayHasKey ('name ' , $ properties );
1001+ $ this ->assertArrayHasKey ('url ' , $ properties );
1002+ }
1003+
9491004 /**
9501005 * Should return the last non-empty URL segment
9511006 * @see https://github.com/indieweb/php-mf2/issues/157
0 commit comments