Ejemplo n.º 1
0
 public function testWithBehavior()
 {
     $form = new models\ProfileForm();
     $form->webUser = \Yii::$app->user;
     $formAttributes = $form->attributes();
     $formRules = $form->rules();
     $formLabels = $form->attributeLabels();
     $form->attachBehavior('captcha', ['class' => '\\nineinchnick\\usr\\components\\CaptchaFormBehavior']);
     $behaviorAttributes = $form->getBehavior('captcha')->attributes();
     $behaviorRules = $form->getBehavior('captcha')->filterRules();
     $behaviorLabels = $form->getBehavior('captcha')->attributeLabels();
     $this->assertEquals(array_merge($formAttributes, $behaviorAttributes), $form->attributes());
     $this->assertEquals(array_merge($behaviorRules, $formRules), $form->rules());
     $this->assertEquals(array_merge($formLabels, $behaviorLabels), $form->attributeLabels());
     $form->detachBehavior('captcha');
     $this->assertEquals($formAttributes, $form->attributes());
     $this->assertEquals($formAttributes, $form->attributes());
 }