push(new RSSFeedTest\ItemA()); $list->push(new RSSFeedTest\ItemB()); $list->push(new RSSFeedTest\ItemC()); $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description"); $content = $rssFeed->outputToBrowser(); $this->assertContains('http://www.example.org/item-a/', $content); $this->assertContains('http://www.example.com/item-b.html', $content); $this->assertContains('http://www.example.com/item-c.html', $content); $this->assertContains('ItemA', $content); $this->assertContains('ItemB', $content); $this->assertContains('ItemC', $content); $this->assertContains('ItemA Content', $content); $this->assertContains('ItemB Content', $content); $this->assertContains('ItemC Content', $content); // Feed #2 - put Content() into and AltContent() into <description> $rssFeed = new RSSFeed( $list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description", "Content", "AltContent" ); $content = $rssFeed->outputToBrowser(); $this->assertContains('<title>ItemA Content', $content); $this->assertContains('ItemB Content', $content); $this->assertContains('ItemC Content', $content); $this->assertContains('ItemA AltContent', $content); $this->assertContains('ItemB AltContent', $content); $this->assertContains('ItemC AltContent', $content); } public function testLinkEncoding() { $list = new ArrayList(); $rssFeed = new RSSFeed($list, "http://www.example.com/?param1=true¶m2=true", "Test RSS Feed"); $content = $rssFeed->outputToBrowser(); $this->assertContains('http://www.example.com/?param1=true&param2=true', $content); } public function testRSSFeedWithShortcode() { $list = new ArrayList(); $list->push(new RSSFeedTest\ItemD()); $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description"); $content = $rssFeed->outputToBrowser(); $this->assertContains('http://www.example.org/item-d.html', $content); $this->assertContains('ItemD', $content); $this->assertContains( 'ItemD Content test shortcode output

]]>
', $content ); } /** * @skipUpgrade */ public function testRenderWithTemplate() { $rssFeed = new RSSFeed(new ArrayList(), "", "", ""); $rssFeed->setTemplate('RSSFeedTest'); $content = $rssFeed->outputToBrowser(); $this->assertContains('Test Custom Template', $content); $rssFeed->setTemplate(null); $content = $rssFeed->outputToBrowser(); $this->assertNotContains('Test Custom Template', $content); } protected function setUp() { parent::setUp(); Config::modify()->set(Director::class, 'alternate_base_url', '/'); if (!self::$original_host) { self::$original_host = $_SERVER['HTTP_HOST']; } $_SERVER['HTTP_HOST'] = 'www.example.org'; ShortcodeParser::get('default')->register( 'test_shortcode', function () { return 'test shortcode output'; } ); } protected function tearDown() { parent::tearDown(); $_SERVER['HTTP_HOST'] = self::$original_host; } }