/usr/share/php/tests/MIME_Type/tests/MIME_Type_ExtensionTest.php is in php-mime-type 1.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | <?php
require_once 'MIME/Type/Extension.php';
/**
* Test class for MIME_Type_Extension.
*
* @author Christian Weiske <cweiske@php.net
*/
class MIME_Type_ExtensionTest extends PHPUnit_Framework_TestCase
{
/**
* @var MIME_Type_Extension
* @access protected
*/
protected $mte;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->mte = new MIME_Type_Extension;
}
public function testGetMIMEType()
{
$this->assertEquals('text/plain',
$this->mte->getMIMEType('a.txt'));
$this->assertEquals('text/plain',
$this->mte->getMIMEType('/path/to/a.txt'));
$this->assertEquals('image/png',
$this->mte->getMIMEType('a.png'));
$this->assertEquals('application/vnd.oasis.opendocument.text',
$this->mte->getMIMEType('a.odt'));
}
public function testGetMIMETypeFullPath()
{
$this->assertEquals('text/plain',
$this->mte->getMIMEType('/path/to/a.txt'));
$this->assertEquals('text/plain',
$this->mte->getMIMEType('C:\\Programs\\blubbr.txt'));
}
public function testGetMIMETypeNoExtension()
{
$this->assertInstanceOf('PEAR_Error',
$this->mte->getMIMEType('file'));
$this->assertInstanceOf('PEAR_Error',
$this->mte->getMIMEType('blubbr'));
}
public function testGetMIMETypeFullPathNoExtension()
{
$this->assertInstanceOf('PEAR_Error',
$this->mte->getMIMEType('/path/to/file'));
$this->assertInstanceOf('PEAR_Error',
$this->mte->getMIMEType('C:\\Programs\\blubbr'));
}
public function testGetMIMETypeUnknownExtension()
{
$this->assertInstanceOf('PEAR_Error',
$this->mte->getMIMEType('file.ohmygodthatisnoextension'));
}
public function testGetExtension()
{
$this->assertEquals('txt',
$this->mte->getExtension('text/plain'));
$this->assertEquals('csv',
$this->mte->getExtension('text/csv'));
}
public function testGetExtensionFail()
{
$this->assertInstanceOf('PEAR_Error', $this->mte->getExtension(null));
$this->assertInstanceOf('PEAR_Error', $this->mte->getExtension(''));
$this->assertInstanceOf('PEAR_Error', $this->mte->getExtension('n'));
$this->assertInstanceOf('PEAR_Error', $this->mte->getExtension('n/n'));
}
}
?>
|