Example #1
0
 public function testWriteChannel()
 {
     $rssWriter = new RssWriter();
     $rssWriter->getXmlWriter()->setIndent(false);
     $writer = new ItunesWriter();
     $channel = new ItunesChannel();
     $channel->setAuthor('John Doe')->setBlock(true)->setImage('https://link.to/my_image.jpg')->setExplicit(true)->setSubtitle('The Subtitle')->setSummary('The Summary')->setComplete(true)->setOwner((new ItunesOwner())->setEmail('*****@*****.**')->setName('John Doe'))->addCategory('Comedy')->addCategory('Management & Marketing');
     $writer->writeChannel($rssWriter, $channel);
     $xml = $rssWriter->getXmlWriter()->flush();
     $expected = '<itunes:author><![CDATA[John Doe]]></itunes:author><itunes:summary><![CDATA[The Summary]]></itunes:summary><itunes:block>Yes</itunes:block><itunes:image href="https://link.to/my_image.jpg"/><itunes:explicit>Yes</itunes:explicit><itunes:subtitle><![CDATA[The Subtitle]]></itunes:subtitle><itunes:complete>Yes</itunes:complete><itunes:owner><itunes:name><![CDATA[John Doe]]></itunes:name><itunes:email>john.doe@example.com</itunes:email></itunes:owner><itunes:category text="Comedy"/><itunes:category text="Business"><itunes:category text="Management &amp; Marketing"/></itunes:category>';
     $this->assertEquals($expected, $xml);
 }
Example #2
0
 public function testAccessors()
 {
     $channel = new ItunesChannel();
     $channel->setAuthor('Jane Doe')->setBlock(true)->setImage('https://link.to/my_image.jpg')->setExplicit(true)->setSubtitle('The Subtitle')->setComplete(true)->setOwner((new ItunesOwner())->setName('John Doe')->setEmail('*****@*****.**'))->setCategories(['cat1', 'cat2'])->addCategory('cat3')->setAuthor('John Doe');
     $this->assertSame('John Doe', $channel->getAuthor());
     $this->assertTrue($channel->getBlock());
     $this->assertSame('https://link.to/my_image.jpg', $channel->getImage());
     $this->assertTrue($channel->getExplicit());
     $this->assertSame('The Subtitle', $channel->getSubtitle());
     $this->assertTrue($channel->getComplete());
     $this->assertSame('John Doe', $channel->getOwner()->getName());
     $this->assertSame('*****@*****.**', $channel->getOwner()->getEmail());
     $this->assertSame(['cat1', 'cat2', 'cat3'], $channel->getCategories());
 }