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
1cd42222
Commit
1cd42222
authored
Sep 05, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test break.
parent
ae13b059
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
49 deletions
+20
-49
ActiveFieldTest.php
tests/unit/framework/widgets/ActiveFieldTest.php
+20
-49
No files found.
tests/unit/framework/widgets/ActiveFieldTest.php
View file @
1cd42222
...
...
@@ -267,45 +267,29 @@ EOD;
$this
->
activeField
->
enableClientValidation
=
true
;
$actualValue
=
$this
->
activeField
->
getClientOptions
();
$expectedJsExpression
=
"function (attribute, value, messages, deferred) {return true;}"
;
$expectedValidateOnChange
=
true
;
$expectedValidateOnBlur
=
true
;
$expectedValidateOnType
=
false
;
$expectedValidationDelay
=
200
;
$actualJsExpression
=
$actualValue
[
'validate'
];
$this
->
assertEquals
(
$expectedJsExpression
,
$actualJsExpression
->
expression
);
$this
->
assertTrue
(
$expectedValidateOnChange
===
$actualValue
[
'validateOnChange'
]);
$this
->
assertTrue
(
$expectedValidateOnBlur
===
$actualValue
[
'validateOnBlur'
]);
$this
->
assertTrue
(
$expectedValidateOnType
===
$actualValue
[
'validateOnType'
]);
$this
->
assertTrue
(
$expectedValidationDelay
===
$actualValue
[
'validationDelay'
]);
}
public
function
testGetClientOptionsEnableAjaxValidation
()
{
$this
->
activeField
->
setClientOptionsEmpty
(
false
);
// expected: enableAjaxValidation
$this
->
activeField
->
enableAjaxValidation
=
true
;
$this
->
activeField
->
model
->
addRule
(
$this
->
attributeName
,
'yiiunit\framework\widgets\TestValidator'
);
$this
->
assertEquals
(
$expectedJsExpression
,
$actualValue
[
'validate'
]);
$this
->
assertTrue
(
!
isset
(
$actualValue
[
'validateOnChange'
]));
$this
->
assertTrue
(
!
isset
(
$actualValue
[
'validateOnBlur'
]));
$this
->
assertTrue
(
!
isset
(
$actualValue
[
'validateOnType'
]));
$this
->
assertTrue
(
!
isset
(
$actualValue
[
'validationDelay'
]));
$this
->
assertTrue
(
!
isset
(
$actualValue
[
'enableAjaxValidation'
]));
$this
->
activeField
->
validateOnChange
=
$expectedValidateOnChange
=
false
;
$this
->
activeField
->
validateOnBlur
=
$expectedValidateOnBlur
=
false
;
$this
->
activeField
->
validateOnType
=
$expectedValidateOnType
=
true
;
$this
->
activeField
->
validationDelay
=
$expectedValidationDelay
=
100
;
$this
->
activeField
->
enableAjaxValidation
=
$expectedEnableAjaxValidation
=
true
;
$actualValue
=
$this
->
activeField
->
getClientOptions
();
$expectedJsExpression
=
"function (attribute, value, messages, deferred) {return true;}"
;
$expectedValidateOnChange
=
true
;
$expectedValidateOnBlur
=
true
;
$expectedValidateOnType
=
false
;
$expectedValidationDelay
=
200
;
$expectedError
=
".help-block"
;
$actualJsExpression
=
$actualValue
[
'validate'
];
$this
->
assertEquals
(
$expectedJsExpression
,
$actualJsExpression
->
expression
);
$this
->
assertTrue
(
$expectedValidateOnChange
===
$actualValue
[
'validateOnChange'
]);
$this
->
assertTrue
(
$expectedValidateOnBlur
===
$actualValue
[
'validateOnBlur'
]);
$this
->
assertTrue
(
$expectedValidateOnType
===
$actualValue
[
'validateOnType'
]);
$this
->
assertTrue
(
$expectedValidationDelay
===
$actualValue
[
'validationDelay'
]);
$this
->
assertTrue
(
1
===
$actualValue
[
'enableAjaxValidation'
]);
$this
->
assertEquals
(
$expectedError
,
$actualValue
[
'error'
]);
$this
->
assertTrue
(
$expectedValidationDelay
===
$actualValue
[
'validationDelay'
]);
$this
->
assertTrue
(
$expectedEnableAjaxValidation
===
$actualValue
[
'enableAjaxValidation'
]);
}
public
function
testGetClientOptionsValidatorWhenClientSet
()
{
$this
->
activeField
->
setClientOptionsEmpty
(
false
);
...
...
@@ -320,21 +304,8 @@ EOD;
$expectedJsExpression
=
"function (attribute, value, messages, deferred) {if (function (attribute, value) "
.
"{ return 'yii2' == 'yii2'; }(attribute, value)) { return true; }}"
;
$expectedValidateOnChange
=
true
;
$expectedValidateOnBlur
=
true
;
$expectedValidateOnType
=
false
;
$expectedValidationDelay
=
200
;
$expectedError
=
".help-block"
;
$actualJsExpression
=
$actualValue
[
'validate'
];
$this
->
assertEquals
(
$expectedJsExpression
,
$actualJsExpression
->
expression
);
$this
->
assertTrue
(
$expectedValidateOnChange
===
$actualValue
[
'validateOnChange'
]);
$this
->
assertTrue
(
$expectedValidateOnBlur
===
$actualValue
[
'validateOnBlur'
]);
$this
->
assertTrue
(
$expectedValidateOnType
===
$actualValue
[
'validateOnType'
]);
$this
->
assertTrue
(
$expectedValidationDelay
===
$actualValue
[
'validationDelay'
]);
$this
->
assertTrue
(
1
===
$actualValue
[
'enableAjaxValidation'
]);
$this
->
assertEquals
(
$expectedError
,
$actualValue
[
'error'
]);
}
$this
->
assertEquals
(
$expectedJsExpression
,
$actualValue
[
'validate'
]
->
expression
);
}
/**
* Helper methods
...
...
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