public function testRenderWithRelatedArticles() { $footer = Footer::create()->withCopyright('2016 Facebook')->withRelatedArticles(RelatedArticles::create()->addRelated(RelatedItem::create()->withURL('http://related.com/1'))->addRelated(RelatedItem::create()->withURL('http://related.com/2'))->addRelated(RelatedItem::create()->withURL('http://sponsored.com/1')->enableSponsored())); $expected = '<footer>' . '<small>' . '2016 Facebook' . '</small>' . '<ul class="op-related-articles">' . '<li><a href="http://related.com/1"></a></li>' . '<li><a href="http://related.com/2"></a></li>' . '<li data-sponsored="true"><a href="http://sponsored.com/1"></a></li>' . '</ul>' . '</footer>'; $rendered = $footer->render(); $this->assertEquals($expected, $rendered); }
public function testInstantArticleAlmostEmpty() { $article = InstantArticle::create()->withCanonicalUrl('')->withHeader(Header::create())->addChild(Paragraph::create()->appendText('Some text to be within a paragraph for testing.'))->addChild(Paragraph::create())->addChild(Paragraph::create()->appendText(" \n \t "))->addChild(Image::create())->addChild(Image::create()->withURL(''))->addChild(SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()))->addChild(Ad::create())->addChild(Paragraph::create()->appendText('Other text to be within a second paragraph for testing.'))->addChild(Analytics::create())->withFooter(Footer::create()); $expected = '<!doctype html>' . '<html>' . '<head>' . '<link rel="canonical" href=""/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="' . InstantArticle::CURRENT_VERSION . '"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<p>Some text to be within a paragraph for testing.</p>' . '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '</figure>' . '<p>Other text to be within a second paragraph for testing.</p>' . '</article>' . '</body>' . '</html>'; $result = $article->render(); $this->assertEquals($expected, $result); }