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
55729a4c
Commit
55729a4c
authored
May 14, 2014
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New tests added
parent
14ec7e21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
ExistValidatorTest.php
tests/unit/framework/validators/ExistValidatorTest.php
+22
-1
No files found.
tests/unit/framework/validators/ExistValidatorTest.php
View file @
55729a4c
...
@@ -89,13 +89,34 @@ class ExistValidatorTest extends DatabaseTestCase
...
@@ -89,13 +89,34 @@ class ExistValidatorTest extends DatabaseTestCase
$m
->
a_field
=
'some new value'
;
$m
->
a_field
=
'some new value'
;
$val
->
validateAttribute
(
$m
,
'a_field'
);
$val
->
validateAttribute
(
$m
,
'a_field'
);
$this
->
assertTrue
(
$m
->
hasErrors
(
'a_field'
));
$this
->
assertTrue
(
$m
->
hasErrors
(
'a_field'
));
//
check
array
//
existing
array
$val
=
new
ExistValidator
([
'targetAttribute'
=>
'ref'
]);
$val
=
new
ExistValidator
([
'targetAttribute'
=>
'ref'
]);
$val
->
allowArray
=
true
;
$val
->
allowArray
=
true
;
$m
=
new
ValidatorTestRefModel
();
$m
=
new
ValidatorTestRefModel
();
$m
->
test_val
=
[
2
,
3
,
4
,
5
];
$m
->
test_val
=
[
2
,
3
,
4
,
5
];
$val
->
validateAttribute
(
$m
,
'test_val'
);
$val
->
validateAttribute
(
$m
,
'test_val'
);
$this
->
assertFalse
(
$m
->
hasErrors
(
'test_val'
));
$this
->
assertFalse
(
$m
->
hasErrors
(
'test_val'
));
// non-existing array
$val
=
new
ExistValidator
([
'targetAttribute'
=>
'ref'
]);
$val
->
allowArray
=
true
;
$m
=
new
ValidatorTestRefModel
();
$m
->
test_val
=
[
95
,
96
,
97
,
98
];
$val
->
validateAttribute
(
$m
,
'test_val'
);
$this
->
assertTrue
(
$m
->
hasErrors
(
'test_val'
));
// existing array (allowArray = false)
$val
=
new
ExistValidator
([
'targetAttribute'
=>
'ref'
]);
$val
->
allowArray
=
false
;
$m
=
new
ValidatorTestRefModel
();
$m
->
test_val
=
[
2
,
3
,
4
,
5
];
$val
->
validateAttribute
(
$m
,
'test_val'
);
$this
->
assertTrue
(
$m
->
hasErrors
(
'test_val'
));
// non-existing array (allowArray = false)
$val
=
new
ExistValidator
([
'targetAttribute'
=>
'ref'
]);
$val
->
allowArray
=
false
;
$m
=
new
ValidatorTestRefModel
();
$m
->
test_val
=
[
95
,
96
,
97
,
98
];
$val
->
validateAttribute
(
$m
,
'test_val'
);
$this
->
assertTrue
(
$m
->
hasErrors
(
'test_val'
));
}
}
public
function
testValidateCompositeKeys
()
public
function
testValidateCompositeKeys
()
...
...
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