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
460b5fab
Commit
460b5fab
authored
May 22, 2014
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests added
parent
d479f317
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
RangeValidatorTest.php
tests/unit/framework/validators/RangeValidatorTest.php
+19
-0
No files found.
tests/unit/framework/validators/RangeValidatorTest.php
View file @
460b5fab
...
@@ -41,6 +41,17 @@ class RangeValidatorTest extends TestCase
...
@@ -41,6 +41,17 @@ class RangeValidatorTest extends TestCase
$this
->
assertTrue
(
$val
->
validate
(
"5"
));
$this
->
assertTrue
(
$val
->
validate
(
"5"
));
}
}
public
function
testValidateArrayValue
()
{
$val
=
new
RangeValidator
([
'range'
=>
range
(
1
,
10
,
1
)]);
$val
->
allowArray
=
true
;
$this
->
assertTrue
(
$val
->
validate
([
1
,
2
,
3
,
4
,
5
]));
$this
->
assertTrue
(
$val
->
validate
([
6
,
7
,
8
,
9
,
10
]));
$this
->
assertFalse
(
$val
->
validate
([
0
,
1
,
2
]));
$this
->
assertFalse
(
$val
->
validate
([
10
,
11
,
12
]));
$this
->
assertTrue
(
$val
->
validate
([
"1"
,
"2"
,
"3"
,
4
,
5
,
6
]));
}
public
function
testValidateValueStrict
()
public
function
testValidateValueStrict
()
{
{
$val
=
new
RangeValidator
([
'range'
=>
range
(
1
,
10
,
1
),
'strict'
=>
true
]);
$val
=
new
RangeValidator
([
'range'
=>
range
(
1
,
10
,
1
),
'strict'
=>
true
]);
...
@@ -52,6 +63,14 @@ class RangeValidatorTest extends TestCase
...
@@ -52,6 +63,14 @@ class RangeValidatorTest extends TestCase
$this
->
assertFalse
(
$val
->
validate
(
"5.5"
));
$this
->
assertFalse
(
$val
->
validate
(
"5.5"
));
}
}
public
function
testValidateArrayValueStrict
()
{
$val
=
new
RangeValidator
([
'range'
=>
range
(
1
,
10
,
1
),
'strict'
=>
true
]);
$val
->
allowArray
=
true
;
$this
->
assertFalse
(
$val
->
validate
([
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
]));
$this
->
assertFalse
(
$val
->
validate
([
"1"
,
"2"
,
"3"
,
4
,
5
,
6
]));
}
public
function
testValidateValueNot
()
public
function
testValidateValueNot
()
{
{
$val
=
new
RangeValidator
([
'range'
=>
range
(
1
,
10
,
1
),
'not'
=>
true
]);
$val
=
new
RangeValidator
([
'range'
=>
range
(
1
,
10
,
1
),
'not'
=>
true
]);
...
...
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