diff options
author | Brion Vibber <brion@pobox.com> | 2010-06-29 08:53:05 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-06-29 08:53:05 -0700 |
commit | c038164c0f41ba5c33f578f395c9fede80d96db8 (patch) | |
tree | 1452f6e5ae5786048a5a2835275c553e80c60462 /tests | |
parent | 7b7f09195a8082c8e26e87f7deb8b1002b852689 (diff) | |
parent | 452123916d08354d11a198517cbc91980a113fcd (diff) |
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'tests')
22 files changed, 112 insertions, 0 deletions
diff --git a/tests/MediaFileTest.php b/tests/MediaFileTest.php new file mode 100644 index 000000000..a76a4f45e --- /dev/null +++ b/tests/MediaFileTest.php @@ -0,0 +1,96 @@ +<?php + +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(); +} + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('STATUSNET', true); +define('LACONICA', true); + +require_once INSTALLDIR . '/lib/common.php'; + +class MediaFileTest extends PHPUnit_Framework_TestCase +{ + + public function setup() + { + $this->old_attachments_supported = common_config('attachments', 'supported'); + $GLOBALS['config']['attachments']['supported'] = true; + } + + public function tearDown() + { + $GLOBALS['config']['attachments']['supported'] = $this->old_attachments_supported; + } + + /** + * @dataProvider fileTypeCases + * + */ + public function testFileType($filename, $expectedType) + { + if (!file_exists($filename)) { + throw new Exception("WTF? $filename test file missing"); + } + + $type = MediaFile::getUploadedFileType($filename, basename($filename)); + $this->assertEquals($expectedType, $type); + } + + /** + * @dataProvider fileTypeCases + * + */ + public function testUploadedFileType($filename, $expectedType) + { + if (!file_exists($filename)) { + throw new Exception("WTF? $filename test file missing"); + } + $tmp = tmpfile(); + fwrite($tmp, file_get_contents($filename)); + + $type = MediaFile::getUploadedFileType($tmp, basename($filename)); + $this->assertEquals($expectedType, $type); + } + + static public function fileTypeCases() + { + $base = dirname(__FILE__); + $dir = "$base/sample-uploads"; + $files = array( + "image.png" => "image/png", + "image.gif" => "image/gif", + "image.jpg" => "image/jpeg", + "image.jpeg" => "image/jpeg", + + "office.pdf" => "application/pdf", + + "wordproc.odt" => "application/vnd.oasis.opendocument.text", + "wordproc.ott" => "application/vnd.oasis.opendocument.text-template", + "wordproc.doc" => "application/msword", + "wordproc.docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "wordproc.rtf" => "text/rtf", + + "spreadsheet.ods" => "application/vnd.oasis.opendocument.spreadsheet", + "spreadsheet.ots" => "application/vnd.oasis.opendocument.spreadsheet-template", + "spreadsheet.xls" => "application/vnd.ms-excel", + "spreadsheet.xlt" => "application/vnd.ms-excel", + "spreadsheet.xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + + "presentation.odp" => "application/vnd.oasis.opendocument.presentation", + "presentation.otp" => "application/vnd.oasis.opendocument.presentation-template", + "presentation.ppt" => "application/vnd.ms-powerpoint", + "presentation.pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", + ); + + $dataset = array(); + foreach ($files as $file => $type) { + $dataset[] = array("$dir/$file", $type); + } + return $dataset; + } + +} + diff --git a/tests/sample-uploads/image.gif b/tests/sample-uploads/image.gif Binary files differnew file mode 100644 index 000000000..b636f4b8d --- /dev/null +++ b/tests/sample-uploads/image.gif diff --git a/tests/sample-uploads/image.jpeg b/tests/sample-uploads/image.jpeg Binary files differnew file mode 100644 index 000000000..21fcb5aef --- /dev/null +++ b/tests/sample-uploads/image.jpeg diff --git a/tests/sample-uploads/image.jpg b/tests/sample-uploads/image.jpg Binary files differnew file mode 100644 index 000000000..21fcb5aef --- /dev/null +++ b/tests/sample-uploads/image.jpg diff --git a/tests/sample-uploads/image.png b/tests/sample-uploads/image.png Binary files differnew file mode 100644 index 000000000..60cbcfd17 --- /dev/null +++ b/tests/sample-uploads/image.png diff --git a/tests/sample-uploads/office.pdf b/tests/sample-uploads/office.pdf Binary files differnew file mode 100644 index 000000000..670bc2343 --- /dev/null +++ b/tests/sample-uploads/office.pdf diff --git a/tests/sample-uploads/presentation.odp b/tests/sample-uploads/presentation.odp Binary files differnew file mode 100644 index 000000000..8dd3a428b --- /dev/null +++ b/tests/sample-uploads/presentation.odp diff --git a/tests/sample-uploads/presentation.otp b/tests/sample-uploads/presentation.otp Binary files differnew file mode 100644 index 000000000..1927ee79d --- /dev/null +++ b/tests/sample-uploads/presentation.otp diff --git a/tests/sample-uploads/presentation.pot b/tests/sample-uploads/presentation.pot Binary files differnew file mode 100644 index 000000000..f5124ffa2 --- /dev/null +++ b/tests/sample-uploads/presentation.pot diff --git a/tests/sample-uploads/presentation.potm b/tests/sample-uploads/presentation.potm Binary files differnew file mode 100644 index 000000000..ade1bcb10 --- /dev/null +++ b/tests/sample-uploads/presentation.potm diff --git a/tests/sample-uploads/presentation.ppt b/tests/sample-uploads/presentation.ppt Binary files differnew file mode 100644 index 000000000..f5124ffa2 --- /dev/null +++ b/tests/sample-uploads/presentation.ppt diff --git a/tests/sample-uploads/presentation.pptx b/tests/sample-uploads/presentation.pptx Binary files differnew file mode 100644 index 000000000..21ea61a15 --- /dev/null +++ b/tests/sample-uploads/presentation.pptx diff --git a/tests/sample-uploads/spreadsheet.ods b/tests/sample-uploads/spreadsheet.ods Binary files differnew file mode 100644 index 000000000..7b43e7507 --- /dev/null +++ b/tests/sample-uploads/spreadsheet.ods diff --git a/tests/sample-uploads/spreadsheet.ots b/tests/sample-uploads/spreadsheet.ots Binary files differnew file mode 100644 index 000000000..5f830e6de --- /dev/null +++ b/tests/sample-uploads/spreadsheet.ots diff --git a/tests/sample-uploads/spreadsheet.xls b/tests/sample-uploads/spreadsheet.xls Binary files differnew file mode 100644 index 000000000..2d470e687 --- /dev/null +++ b/tests/sample-uploads/spreadsheet.xls diff --git a/tests/sample-uploads/spreadsheet.xlsx b/tests/sample-uploads/spreadsheet.xlsx Binary files differnew file mode 100644 index 000000000..b97a551f8 --- /dev/null +++ b/tests/sample-uploads/spreadsheet.xlsx diff --git a/tests/sample-uploads/spreadsheet.xlt b/tests/sample-uploads/spreadsheet.xlt Binary files differnew file mode 100644 index 000000000..980423b20 --- /dev/null +++ b/tests/sample-uploads/spreadsheet.xlt diff --git a/tests/sample-uploads/wordproc.doc b/tests/sample-uploads/wordproc.doc Binary files differnew file mode 100644 index 000000000..81c5e34c6 --- /dev/null +++ b/tests/sample-uploads/wordproc.doc diff --git a/tests/sample-uploads/wordproc.docx b/tests/sample-uploads/wordproc.docx Binary files differnew file mode 100644 index 000000000..04ea3c3ec --- /dev/null +++ b/tests/sample-uploads/wordproc.docx diff --git a/tests/sample-uploads/wordproc.odt b/tests/sample-uploads/wordproc.odt Binary files differnew file mode 100644 index 000000000..fa6fe5e9f --- /dev/null +++ b/tests/sample-uploads/wordproc.odt diff --git a/tests/sample-uploads/wordproc.ott b/tests/sample-uploads/wordproc.ott Binary files differnew file mode 100644 index 000000000..99ca8c068 --- /dev/null +++ b/tests/sample-uploads/wordproc.ott diff --git a/tests/sample-uploads/wordproc.rtf b/tests/sample-uploads/wordproc.rtf new file mode 100644 index 000000000..aad2c4605 --- /dev/null +++ b/tests/sample-uploads/wordproc.rtf @@ -0,0 +1,16 @@ +{\rtf1\ansi\deff0\adeflang1025 +{\fonttbl{\f0\froman\fprq2\fcharset128 Times New Roman;}{\f1\froman\fprq2\fcharset128 Times New Roman;}{\f2\fswiss\fprq2\fcharset128 Arial;}{\f3\fnil\fprq2\fcharset128 DejaVu Sans;}} +{\colortbl;\red0\green0\blue0;\red128\green128\blue128;} +{\stylesheet{\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\snext1 Normal;} +{\s2\sb240\sa120\keepn\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\afs28\lang1081\ltrch\dbch\langfe2052\hich\f2\fs28\lang1033\loch\f2\fs28\lang1033\sbasedon1\snext3 Heading;} +{\s3\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon1\snext3 Body Text;} +{\s4\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon3\snext4 List;} +{\s5\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ai\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\i\loch\f0\fs24\lang1033\i\sbasedon1\snext5 caption;} +{\s6\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon1\snext6 Index;} +} +{\info{\author Brion }{\creatim\yr2010\mo5\dy10\hr15\min2}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment StarWriter}{\vern3200}}\deftab709 +{\*\pgdsctbl +{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}} +\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc +\pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033 +\par }
\ No newline at end of file |