Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in file_is_text, removes mime_content_type compatibility func…
…tion and add file_mime_content_type() [#15 state:resolved]
- Loading branch information
Fabrice Luraine
committed
Jul 31, 2009
1 parent
59062eb
commit c6714c0
Showing
5 changed files
with
71 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
if(!defined('LIMONADE')){$h="HTTP/1.0 401 Unauthorized";header($h);die($h);}// Security check | ||
|
||
test_case("File"); | ||
test_case_describe("Testing limonade file functions."); | ||
|
||
function before_each_test_in_file() | ||
{ | ||
|
||
} | ||
|
||
function test_file_mime_type() | ||
{ | ||
$mimes = mime_type(); | ||
assert_true(is_array($mimes)); | ||
assert_not_empty($mimes); | ||
assert_empty(mime_type('')); | ||
assert_equal(mime_type('txt'), 'text/plain'); | ||
assert_equal(mime_type('TXT'), 'text/plain'); | ||
assert_equal(mime_type('jpg'), 'image/jpeg'); | ||
assert_equal(mime_type('JPG'), 'image/jpeg'); | ||
} | ||
|
||
function test_file_extension() | ||
{ | ||
assert_equal(file_extension('my_file'), ''); | ||
assert_equal(file_extension('my_file.txt'), 'txt'); | ||
assert_equal(file_extension('my_file.html.php'), 'php'); | ||
assert_equal(file_extension('my_file.JPG'), 'JPG'); | ||
} | ||
|
||
function test_file_mime_content_type() | ||
{ | ||
assert_not_empty(file_mime_content_type('')); | ||
assert_not_empty(file_mime_content_type('my_file')); | ||
assert_equal(file_mime_content_type('my_file'), 'application/octet-stream'); | ||
assert_equal(file_mime_content_type('my_file.txt'), 'text/plain'); | ||
assert_equal(file_mime_content_type('my_file.TXT'), 'text/plain'); | ||
assert_equal(file_mime_content_type('my_file.jpg'), 'image/jpeg'); | ||
assert_equal(file_mime_content_type('my_file.JPG'), 'image/jpeg'); | ||
} | ||
|
||
function test_file_is_text() | ||
{ | ||
assert_true(file_is_text('my_file.txt')); | ||
assert_true(file_is_text('my_file.TXT')); | ||
assert_true(file_is_text('my_file.css')); | ||
assert_true(file_is_text('my_file.csv')); | ||
assert_false(file_is_text('my_file.jpg')); | ||
} | ||
|
||
end_test_case(); |