Skip to content

Commit

Permalink
Add MP3_RSS_Item test
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-xo committed Feb 14, 2021
1 parent 4dcd121 commit b54028b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
15 changes: 9 additions & 6 deletions dir2cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/MP3_RSS_ItemTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

use PHPUnit\Framework\TestCase;

class MP3_RSS_ItemTest extends Media_RSS_ItemTest
{
public function getDefaultType()
{
return 'audio/mpeg';
}

protected $media_rss_item_class = 'MP3_RSS_Item';
}
5 changes: 4 additions & 1 deletion test/Media_RSS_ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function getID3Comment()
return '';
}

protected $media_rss_item_class = 'Media_RSS_Item';

public function newRSSItem()
{
// default tests are conducted with an empty file (which, therefore, has no ID3 tags to read)
Expand All @@ -59,7 +61,8 @@ public function newRSSItem()
$this->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());
Expand Down
8 changes: 7 additions & 1 deletion test/RSS_File_ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b54028b

Please sign in to comment.