#1944 - Fix possible warnings in legal_file::get_photo_types_by_extension and legal_file::get_movie_types_by_extension.

Added unit tests for these two functions, too.
This commit is contained in:
shadlaws
2013-01-19 00:52:13 +01:00
parent 93afe52ae1
commit e2a2a5ce81
2 changed files with 41 additions and 2 deletions

View File

@@ -18,6 +18,43 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Legal_File_Helper_Test extends Gallery_Unit_Test_Case {
public function get_photo_types_by_extension_test() {
// Valid extensions return their corresponding mimes, invalid extensions return null
$tests = array("jpg" => "image/jpeg",
"JPG" => "image/jpeg",
"jpeg" => "image/jpeg",
"png" => "image/png",
"Png" => "image/png",
"gif" => "image/gif",
"tif" => null,
"mp4" => null,
"php" => null,
"php.jpg" => null);
foreach ($tests as $extension => $mime_type) {
$this->assert_equal($mime_type, legal_file::get_photo_types_by_extension($extension));
}
// No extension returns full array
$this->assert_equal(4, count(legal_file::get_photo_types_by_extension()));
}
public function get_movie_types_by_extension_test() {
// Valid extensions return their corresponding mimes, invalid extensions return null
$tests = array("flv" => "video/x-flv",
"FLV" => "video/x-flv",
"mp4" => "video/mp4",
"Mp4" => "video/mp4",
"m4v" => "video/x-m4v",
"avi" => null,
"jpg" => null,
"php" => null,
"php.flv" => null);
foreach ($tests as $extension => $mime_type) {
$this->assert_equal($mime_type, legal_file::get_movie_types_by_extension($extension));
}
// No extension returns full array
$this->assert_equal(3, count(legal_file::get_movie_types_by_extension()));
}
public function change_extension_test() {
$this->assert_equal("foo.jpg", legal_file::change_extension("foo.png", "jpg"));
}