mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-04 22:57:40 +08:00
Fixed test break and JSON MIME type. Fixes issue #2978.
This commit is contained in:
@ -71,6 +71,8 @@ return [
|
|||||||
'jpeg' => 'image/jpeg',
|
'jpeg' => 'image/jpeg',
|
||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
'js' => 'application/x-javascript',
|
'js' => 'application/x-javascript',
|
||||||
|
'json' => 'application/json',
|
||||||
|
'jsonp' => 'text/javascript',
|
||||||
'kar' => 'audio/midi',
|
'kar' => 'audio/midi',
|
||||||
'latex' => 'application/x-latex',
|
'latex' => 'application/x-latex',
|
||||||
'lha' => 'application/octet-stream',
|
'lha' => 'application/octet-stream',
|
||||||
|
|||||||
@ -349,9 +349,13 @@ class FileHelperTest extends TestCase
|
|||||||
file_put_contents($file, 'some text');
|
file_put_contents($file, 'some text');
|
||||||
$this->assertEquals('text/plain', FileHelper::getMimeType($file));
|
$this->assertEquals('text/plain', FileHelper::getMimeType($file));
|
||||||
|
|
||||||
|
// see http://stackoverflow.com/questions/477816/what-is-the-correct-json-content-type
|
||||||
|
// JSON/JSONP should not use text/plain - see http://jibbering.com/blog/?p=514
|
||||||
|
// with "fileinfo" extension enabled, returned MIME is not quite correctly "text/plain"
|
||||||
|
// without "fileinfo" it falls back to getMimeTypeByExtension() and returns application/json
|
||||||
$file = $this->testFilePath . DIRECTORY_SEPARATOR . 'mime_type_test.json';
|
$file = $this->testFilePath . DIRECTORY_SEPARATOR . 'mime_type_test.json';
|
||||||
file_put_contents($file, '{"a": "b"}');
|
file_put_contents($file, '{"a": "b"}');
|
||||||
$this->assertEquals('text/plain', FileHelper::getMimeType($file));
|
$this->assertTrue(in_array(FileHelper::getMimeType($file), array('application/json', 'text/plain')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNormalizePath()
|
public function testNormalizePath()
|
||||||
|
|||||||
Reference in New Issue
Block a user