Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
0040633f
Commit
0040633f
authored
Apr 04, 2014
by
lubosdz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test break and JSON MIME type. Fixes issue #2978.
parent
a97a35ba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
mimeTypes.php
framework/helpers/mimeTypes.php
+2
-0
FileHelperTest.php
tests/unit/framework/helpers/FileHelperTest.php
+5
-1
No files found.
framework/helpers/mimeTypes.php
View file @
0040633f
...
@@ -71,6 +71,8 @@ return [
...
@@ -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'
,
...
...
tests/unit/framework/helpers/FileHelperTest.php
View file @
0040633f
...
@@ -349,9 +349,13 @@ class FileHelperTest extends TestCase
...
@@ -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
->
assert
Equals
(
'text/plain'
,
FileHelper
::
getMimeType
(
$file
));
$this
->
assert
True
(
in_array
(
FileHelper
::
getMimeType
(
$file
),
array
(
'application/json'
,
'text/plain'
)
));
}
}
public
function
testNormalizePath
()
public
function
testNormalizePath
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment