public function testHFeed()
 {
     $html = file_get_contents($this->dir . '/HTML/h-feed.html');
     $parser = new Parser();
     $auth = new Authorship();
     $microformats = $parser->getMicroformats($html, null);
     $expected = ['type' => ['h-card'], 'properties' => ['name' => ['Joe Bloggs']]];
     $this->assertEquals($expected, $auth->findAuthor($microformats));
 }
예제 #2
0
 /**
  * Parse the mf2 for desired repost content.
  *
  * @param  array  The microformats
  * @param  string The source domain
  *
  * @return array The repost content
  */
 public function repostContent(array $microformats, $domain = null)
 {
     $url = isset($microformats['items'][0]['properties']['repost-of'][0]) ? $microformats['items'][0]['properties']['repost-of'][0] : null;
     $date = isset($microformats['items'][0]['properties']['published'][0]) ? $microformats['items'][0]['properties']['published'][0] : date('Y-m-d H:i:s \\U\\T\\CO');
     $authorship = new Authorship();
     try {
         $author = $authorship->findAuthor($microformats);
     } catch (AuthorshipParserException $e) {
         $author = null;
     }
     $authorNorm = $this->normaliseAuthor($author, $domain);
     return ['name' => $authorNorm['name'], 'url' => $authorNorm['url'], 'photo' => $authorNorm['photo'], 'repost' => $url, 'date' => $date];
 }