Commit 1cd42222 by Qiang Xue

Fixed test break.

parent ae13b059
...@@ -267,45 +267,29 @@ EOD; ...@@ -267,45 +267,29 @@ EOD;
$this->activeField->enableClientValidation = true; $this->activeField->enableClientValidation = true;
$actualValue = $this->activeField->getClientOptions(); $actualValue = $this->activeField->getClientOptions();
$expectedJsExpression = "function (attribute, value, messages, deferred) {return true;}"; $expectedJsExpression = "function (attribute, value, messages, deferred) {return true;}";
$expectedValidateOnChange = true; $this->assertEquals($expectedJsExpression, $actualValue['validate']);
$expectedValidateOnBlur = true;
$expectedValidateOnType = false; $this->assertTrue(!isset($actualValue['validateOnChange']));
$expectedValidationDelay = 200; $this->assertTrue(!isset($actualValue['validateOnBlur']));
$this->assertTrue(!isset($actualValue['validateOnType']));
$actualJsExpression = $actualValue['validate']; $this->assertTrue(!isset($actualValue['validationDelay']));
$this->assertEquals($expectedJsExpression, $actualJsExpression->expression); $this->assertTrue(!isset($actualValue['enableAjaxValidation']));
$this->assertTrue($expectedValidateOnChange === $actualValue['validateOnChange']);
$this->assertTrue($expectedValidateOnBlur === $actualValue['validateOnBlur']); $this->activeField->validateOnChange = $expectedValidateOnChange = false;
$this->assertTrue($expectedValidateOnType === $actualValue['validateOnType']); $this->activeField->validateOnBlur = $expectedValidateOnBlur = false;
$this->assertTrue($expectedValidationDelay === $actualValue['validationDelay']); $this->activeField->validateOnType = $expectedValidateOnType = true;
} $this->activeField->validationDelay = $expectedValidationDelay = 100;
$this->activeField->enableAjaxValidation = $expectedEnableAjaxValidation = true;
public function testGetClientOptionsEnableAjaxValidation()
{
$this->activeField->setClientOptionsEmpty(false);
// expected: enableAjaxValidation
$this->activeField->enableAjaxValidation = true;
$this->activeField->model->addRule($this->attributeName, 'yiiunit\framework\widgets\TestValidator');
$actualValue = $this->activeField->getClientOptions(); $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($expectedValidateOnChange === $actualValue['validateOnChange']);
$this->assertTrue($expectedValidateOnBlur === $actualValue['validateOnBlur']); $this->assertTrue($expectedValidateOnBlur === $actualValue['validateOnBlur']);
$this->assertTrue($expectedValidateOnType === $actualValue['validateOnType']); $this->assertTrue($expectedValidateOnType === $actualValue['validateOnType']);
$this->assertTrue($expectedValidationDelay === $actualValue['validationDelay']); $this->assertTrue($expectedValidationDelay === $actualValue['validationDelay']);
$this->assertTrue(1 === $actualValue['enableAjaxValidation']); $this->assertTrue($expectedEnableAjaxValidation === $actualValue['enableAjaxValidation']);
$this->assertEquals($expectedError, $actualValue['error']);
} }
public function testGetClientOptionsValidatorWhenClientSet() public function testGetClientOptionsValidatorWhenClientSet()
{ {
$this->activeField->setClientOptionsEmpty(false); $this->activeField->setClientOptionsEmpty(false);
...@@ -320,21 +304,8 @@ EOD; ...@@ -320,21 +304,8 @@ EOD;
$expectedJsExpression = "function (attribute, value, messages, deferred) {if (function (attribute, value) " $expectedJsExpression = "function (attribute, value, messages, deferred) {if (function (attribute, value) "
. "{ return 'yii2' == 'yii2'; }(attribute, value)) { return true; }}"; . "{ return 'yii2' == 'yii2'; }(attribute, value)) { return true; }}";
$expectedValidateOnChange = true; $this->assertEquals($expectedJsExpression, $actualValue['validate']->expression);
$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']);
}
/** /**
* Helper methods * Helper methods
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment