forked from ben-xo/dir2cast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSS_Item_iTunes_Podcast_HelperTest.php
70 lines (52 loc) · 2.15 KB
/
RSS_Item_iTunes_Podcast_HelperTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class RSS_Item_iTunes_Podcast_HelperTest extends TestCase
{
public static function setUpBeforeClass(): void
{
}
public function test_rss_item_added_to_podcast_channel_has_itunes_properties()
{
$mp = new MyPodcast();
$helper = new iTunes_Podcast_Helper();
$mp->addHelper($helper);
$item = new RSS_Item();
$item->setSummary("whaddya wanna know?");
$item->setSubtitle("");
$item->setDuration('1:23');
$item->setID3Artist('Ben XO');
$item->setImage('cover.jpg');
$mp->addRssItem($item);
$content = $mp->generate();
$data = simplexml_load_string($content, 'SimpleXMLElement');
$item = $data->channel->item[0];
$itunes_item = $item->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
$this->assertEquals('1:23', $itunes_item->duration);
$this->assertEquals('Ben XO', $itunes_item->author);
$this->assertEquals('whaddya wanna know?', $itunes_item->summary);
$this->assertEquals('cover.jpg', $itunes_item->image->attributes()->href);
}
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function test_rss_item_itunes_subtitle_suffix()
{
iTunes_Podcast_Helper::$ITUNES_SUBTITLE_SUFFIX = ' Click here for more…';
$mp = new MyPodcast();
$helper = new iTunes_Podcast_Helper();
$mp->addHelper($helper);
$item0 = new RSS_Item();
$item0->setSubtitle("testing");
$item1 = new RSS_Item();
$mp->addRssItem($item0);
$mp->addRssItem($item1);
$content = $mp->generate();
$data = simplexml_load_string($content, 'SimpleXMLElement');
$item = $data->channel->item;
$itunes_item0 = $item[0]->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
$itunes_item1 = $item[1]->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
$this->assertEquals('testing Click here for more…', $itunes_item0->subtitle);
$this->assertEquals(' Click here for more…', $itunes_item1->subtitle);
}
}