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
0c45765e
Commit
0c45765e
authored
Aug 18, 2013
by
Suralc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for uncovered lines.
parent
5c8927af
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
1 deletion
+26
-1
DateValidatorTest.php
tests/unit/framework/validators/DateValidatorTest.php
+5
-1
ExistValidatorTest.php
tests/unit/framework/validators/ExistValidatorTest.php
+7
-0
NumberValidatorTest.php
tests/unit/framework/validators/NumberValidatorTest.php
+4
-0
StringValidatorTest.php
tests/unit/framework/validators/StringValidatorTest.php
+4
-0
UrlValidatorTest.php
tests/unit/framework/validators/UrlValidatorTest.php
+6
-0
No files found.
tests/unit/framework/validators/DateValidatorTest.php
View file @
0c45765e
...
...
@@ -55,7 +55,10 @@ class DateValidatorTest extends TestCase
DateTime
::
createFromFormat
(
$val
->
format
,
'2013-09-13'
)
->
getTimestamp
(),
$model
->
attr_timestamp
);
$val
=
new
DateValidator
();
$model
=
FakedValidationModel
::
createWithAttributes
(
array
(
'attr_date'
=>
array
()));
$val
->
validateAttribute
(
$model
,
'attr_date'
);
$this
->
assertTrue
(
$model
->
hasErrors
(
'attr_date'
));
}
}
\ No newline at end of file
tests/unit/framework/validators/ExistValidatorTest.php
View file @
0c45765e
...
...
@@ -90,5 +90,11 @@ class ExistValidatorTest extends DatabaseTestCase
$m
->
a_field
=
'some new value'
;
$val
->
validateAttribute
(
$m
,
'a_field'
);
$this
->
assertTrue
(
$m
->
hasErrors
(
'a_field'
));
// check array
$val
=
new
ExistValidator
(
array
(
'attributeName'
=>
'ref'
));
$m
=
ExistValidatorRefModel
::
find
(
array
(
'id'
=>
2
));
$m
->
test_val
=
array
(
1
,
2
,
3
);
$val
->
validateAttribute
(
$m
,
'test_val'
);
$this
->
assertTrue
(
$m
->
hasErrors
(
'test_val'
));
}
}
\ No newline at end of file
tests/unit/framework/validators/NumberValidatorTest.php
View file @
0c45765e
...
...
@@ -137,6 +137,10 @@ class NumberValidatorTest extends TestCase
$model
->
attr_number
=
3.43
;
$val
->
validateAttribute
(
$model
,
'attr_number'
);
$this
->
assertTrue
(
$model
->
hasErrors
(
'attr_number'
));
$val
=
new
NumberValidator
(
array
(
'min'
=>
1
));
$model
=
FakedValidationModel
::
createWithAttributes
(
array
(
'attr_num'
=>
array
(
1
,
2
,
3
)));
$val
->
validateAttribute
(
$model
,
'attr_num'
);
$this
->
assertTrue
(
$model
->
hasErrors
(
'attr_num'
));
}
public
function
testEnsureCustomMessageIsSetOnValidateAttribute
()
...
...
tests/unit/framework/validators/StringValidatorTest.php
View file @
0c45765e
...
...
@@ -86,6 +86,10 @@ class StringValidatorTest extends TestCase
$model
->
attr_string
=
'abc'
;
$val
->
validateAttribute
(
$model
,
'attr_string'
);
$this
->
assertTrue
(
$model
->
hasErrors
(
'attr_string'
));
$val
=
new
StringValidator
(
array
(
'max'
=>
1
));
$model
=
FakedValidationModel
::
createWithAttributes
(
array
(
'attr_str'
=>
array
(
'abc'
)));
$val
->
validateAttribute
(
$model
,
'attr_str'
);
$this
->
assertTrue
(
$model
->
hasErrors
(
'attr_str'
));
}
public
function
testEnsureMessagesOnInit
()
...
...
tests/unit/framework/validators/UrlValidatorTest.php
View file @
0c45765e
...
...
@@ -29,6 +29,12 @@ class UrlValidatorTest extends TestCase
$this
->
assertTrue
(
$val
->
validateValue
(
'yiiframework.com'
));
$this
->
assertTrue
(
$val
->
validateValue
(
'http://yiiframework.com'
));
}
public
function
testValidateValueWithoutScheme
()
{
$val
=
new
UrlValidator
(
array
(
'pattern'
=>
'/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)/i'
));
$this
->
assertTrue
(
$val
->
validateValue
(
'yiiframework.com'
));
}
public
function
testValidateWithCustomScheme
()
{
...
...
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