summaryrefslogtreecommitdiff
path: root/modules/gallery/tests
diff options
context:
space:
mode:
authorshadlaws <shad@shadlaws.com>2013-01-19 00:52:13 +0100
committershadlaws <shad@shadlaws.com>2013-01-19 00:52:13 +0100
commite2a2a5ce812c249b46d56ed2f738162e3f4cd09b (patch)
tree72ed023404c7e7217c99e29ea6e64165848cfcb5 /modules/gallery/tests
parent93afe52ae16b5f01a1bd9966af061ea0d6224370 (diff)
#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.
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"));
}