public function testWithBehavior() { $form = new models\LoginForm(); $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($formRules, $behaviorRules), $form->rules()); $this->assertEquals(array_merge($formLabels, $behaviorLabels), $form->attributeLabels()); $form->detachBehavior('captcha'); $this->assertEquals($formAttributes, $form->attributes()); $this->assertEquals($formAttributes, $form->attributes()); }