Exemplo n.º 1
0
 public function testGetClientOptionsValidatorWhenClientSet()
 {
     $this->activeField->setClientOptionsEmpty(false);
     $this->activeField->enableAjaxValidation = true;
     $this->activeField->model->addRule($this->attributeName, 'yiiunit\\framework\\widgets\\TestValidator');
     foreach ($this->activeField->model->validators as $validator) {
         $validator->whenClient = "function (attribute, value) { return 'yii2' == 'yii2'; }";
         // js
     }
     $actualValue = $this->activeField->getClientOptions();
     $expectedJsExpression = "function (attribute, value, messages, deferred, \$form) {if ((function (attribute, value) " . "{ return 'yii2' == 'yii2'; })(attribute, value)) { return true; }}";
     $this->assertEquals($expectedJsExpression, $actualValue['validate']->expression);
 }