summaryrefslogtreecommitdiff
path: root/modules/gallery/tests
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-01-19 21:34:39 -0800
committerBharat Mediratta <bharat@menalto.com>2013-01-19 21:34:39 -0800
commit35bb5c4a1ca89fc4cc64555df47294caa64e3839 (patch)
tree53a6c5b1f456304ec3124c90f80b1af75a966f5c /modules/gallery/tests
parent9359e75ca3e54e0a88ef2e5c82592406952d71fa (diff)
parente2a2a5ce812c249b46d56ed2f738162e3f4cd09b (diff)
Merge pull request #93 from shadlaws/fix_1944
#1944 - Fix possible warnings in legal_file::get_photo_types_by_extension and legal_file::get_movie_types_by_extension.
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r--modules/gallery/tests/Legal_File_Helper_Test.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php
index d2813633..66a5cc68 100644
--- a/modules/gallery/tests/Legal_File_Helper_Test.php
+++ b/modules/gallery/tests/Legal_File_Helper_Test.php
@@ -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"));
}