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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
0206e917
Commit
0206e917
authored
Jun 10, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file validator tests added
parent
c52c063c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
FileValidatorTest.php
tests/unit/framework/validators/FileValidatorTest.php
+27
-1
No files found.
tests/unit/framework/validators/FileValidatorTest.php
View file @
0206e917
...
...
@@ -21,7 +21,7 @@ class FileValidatorTest extends TestCase
public
function
testAssureMessagesSetOnInit
()
{
$val
=
new
FileValidator
();
foreach
([
'message'
,
'uploadRequired'
,
'tooMany'
,
'wrongType'
,
'tooBig'
,
'tooSmall'
]
as
$attr
)
{
foreach
([
'message'
,
'uploadRequired'
,
'tooMany'
,
'wrongType'
,
'tooBig'
,
'tooSmall'
,
'wrongMimeType'
]
as
$attr
)
{
$this
->
assertTrue
(
is_string
(
$val
->
$attr
));
}
}
...
...
@@ -30,18 +30,44 @@ class FileValidatorTest extends TestCase
{
$val
=
new
FileValidator
([
'types'
=>
'jpeg, jpg, gif'
]);
$this
->
assertEquals
([
'jpeg'
,
'jpg'
,
'gif'
],
$val
->
types
);
$val
=
new
FileValidator
([
'types'
=>
'jpeg'
]);
$this
->
assertEquals
([
'jpeg'
],
$val
->
types
);
$val
=
new
FileValidator
([
'types'
=>
''
]);
$this
->
assertEquals
([],
$val
->
types
);
$val
=
new
FileValidator
([
'types'
=>
[]]);
$this
->
assertEquals
([],
$val
->
types
);
$val
=
new
FileValidator
();
$this
->
assertEquals
([],
$val
->
types
);
$val
=
new
FileValidator
([
'types'
=>
[
'jpeg'
,
'exe'
]]);
$this
->
assertEquals
([
'jpeg'
,
'exe'
],
$val
->
types
);
}
public
function
testMimeTypeSplitOnInit
()
{
$val
=
new
FileValidator
([
'mimeTypes'
=>
'text/plain, image/png'
]);
$this
->
assertEquals
([
'text/plain'
,
'image/png'
],
$val
->
mimeTypes
);
$val
=
new
FileValidator
([
'mimeTypes'
=>
'text/plain'
]);
$this
->
assertEquals
([
'text/plain'
],
$val
->
mimeTypes
);
$val
=
new
FileValidator
([
'mimeTypes'
=>
''
]);
$this
->
assertEquals
([],
$val
->
mimeTypes
);
$val
=
new
FileValidator
([
'mimeTypes'
=>
[]]);
$this
->
assertEquals
([],
$val
->
mimeTypes
);
$val
=
new
FileValidator
();
$this
->
assertEquals
([],
$val
->
mimeTypes
);
$val
=
new
FileValidator
([
'mimeTypes'
=>
[
'text/plain'
,
'image/png'
]]);
$this
->
assertEquals
([
'text/plain'
,
'image/png'
],
$val
->
mimeTypes
);
}
public
function
testGetSizeLimit
()
{
$size
=
$this
->
sizeToBytes
(
ini_get
(
'upload_max_filesize'
));
...
...
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