diff --git a/dir2cast.php b/dir2cast.php index de25320..be899f9 100644 --- a/dir2cast.php +++ b/dir2cast.php @@ -895,25 +895,28 @@ public function unserialize($serialized) class MP3_RSS_Item extends Media_RSS_Item { - public function getType() + public function __construct($filename) { - return 'audio/mpeg'; + parent::__construct($filename); + $this->setType('audio/mpeg'); } } class M4A_RSS_Item extends Media_RSS_Item { - public function getType() + public function __construct($filename) { - return 'audio/mp4'; + parent::__construct($filename); + $this->setType('audio/mp4'); } } class MP4_RSS_Item extends Media_RSS_Item { - public function getType() + public function __construct($filename) { - return 'video/mp4'; + parent::__construct($filename); + $this->setType('video/mp4'); } } diff --git a/test/MP3_RSS_ItemTest.php b/test/MP3_RSS_ItemTest.php new file mode 100644 index 0000000..83ffcac --- /dev/null +++ b/test/MP3_RSS_ItemTest.php @@ -0,0 +1,13 @@ +mtime = time(); touch($this->filename, $this->mtime); - $item = new Media_RSS_Item($this->filename); + $class = $this->media_rss_item_class; + $item = new $class($this->filename); $item->setID3Album($this->getID3Album()); $item->setID3Title($this->getID3Title()); $item->setID3Artist($this->getID3Artist()); diff --git a/test/RSS_File_ItemTest.php b/test/RSS_File_ItemTest.php index 8ae9e83..f57fb9c 100644 --- a/test/RSS_File_ItemTest.php +++ b/test/RSS_File_ItemTest.php @@ -10,6 +10,12 @@ public static function setUpBeforeClass(): void RSS_File_Item::$FILES_DIR = getcwd(); } + + public function getDefaultType() + { + return 'application/octet-stream'; + } + protected $filename; protected $filename_base; protected $default_title_from_file; @@ -44,7 +50,7 @@ public function test_constructor_sets_default_properties_from_filename() $this->assertEquals('example.mp3', $item->getFilename()); $this->assertEquals($this->getDefaultTitle(), $item->getTitle()); $this->assertEquals('http://www.example.com/mp3/example.mp3', $item->getLink()); - $this->assertEquals('application/octet-stream', $item->getType()); + $this->assertEquals($this->getDefaultType(), $item->getType()); } public function test_filename_with_full_path()