2023-04-05 14:44:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Shikiryu\SRSS\SRSS;
|
|
|
|
|
|
|
|
class MediaTest extends TestCase
|
|
|
|
{
|
2023-04-12 15:28:38 +02:00
|
|
|
public function testImages(): void
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
2023-04-07 17:57:35 +02:00
|
|
|
$rss = SRSS::read(__DIR__.'/resources/media/cnn.xml');
|
2023-04-17 14:28:01 +02:00
|
|
|
self::assertEquals('<![CDATA[ CNN.com - RSS Channel - Entertainment ]]>', $rss->title);
|
2023-04-05 14:44:57 +02:00
|
|
|
|
|
|
|
$first_item = $rss->getFirst();
|
2023-04-17 14:28:01 +02:00
|
|
|
self::assertEquals('<![CDATA[ Kirstie Alley, \'Cheers\' and \'Veronica\'s Closet\' star, dead at 71 ]]>', $first_item->title);
|
2023-04-05 14:44:57 +02:00
|
|
|
|
2023-04-06 11:07:06 +02:00
|
|
|
self::assertEquals('https://cdn.cnn.com/cnnnext/dam/assets/221205172141-kirstie-alley-2005-super-169.jpg', $first_item->medias[0]->url);
|
2023-04-07 17:57:35 +02:00
|
|
|
self::assertTrue($rss->isValid(), var_export($rss->channel->validated, true));
|
2023-04-06 11:07:06 +02:00
|
|
|
}
|
|
|
|
|
2023-04-12 15:28:38 +02:00
|
|
|
public function testMusicVideo(): void
|
2023-04-06 11:07:06 +02:00
|
|
|
{
|
2023-04-07 17:57:35 +02:00
|
|
|
$rss = SRSS::read(__DIR__.'/resources/media/music-video.xml');
|
2023-04-17 14:28:01 +02:00
|
|
|
self::assertEquals('<![CDATA[ Music Videos 101 ]]>', $rss->title);
|
2023-04-06 11:07:06 +02:00
|
|
|
|
|
|
|
self::assertCount(1, $rss->items);
|
|
|
|
|
|
|
|
$first_item = $rss->getFirst();
|
|
|
|
self::assertEquals('http://www.foo.com/movie.mov', $first_item->medias[0]->url);
|
2023-04-07 17:57:35 +02:00
|
|
|
self::assertTrue($rss->isValid());
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
}
|