Yii2 captcha unit test


(Smarcin777) #1

Hello,

Should i make unit test with validate my RegisterForm with some difference data? I can’t make it work beacuse captcha throw exception about action ID.


   

$this->model = new RegisterForm([

               UserFormsEnums::FIELD_CAPTCHA => 'testme',

        ]);


        $this->model->validate();


  codecept_debug($this->model->errors);

        expect($this->model->errors)->isEmpty();



Thank you for any advice.


(Alirz23) #2

activerecord has support for scenarios basically you can skip validation rules based on scenarios here is a link to the docs

http://www.yiiframework.com/doc-2.0/guide-structure-models.html#scenarios