Yii2 & Codeception - Enabling tester module in unit testing -


i use yii2 , build-in codeception , want write unit tests. in documentation of codeception i´ve found example test:

function testusercanbeactivatedwithvalidkey() {     // lookup user eloquent api     $user = user::find($this->user_id);     // executing action     $isactivated = $user->activate('123456'));     // performing assertion     $this->asserttrue($isactivated);     // checking data saved database     $this->tester->seerecord('users', [         'id' => $this->user_id,         'is_active' => 1      ]); } 

but when i´m trying write test myself, there no $this->tester object. how can benefit methods seeindatabase()?

try this:

function testusercanbeactivatedwithvalidkey(webguy $i) {     // lookup user eloquent api     $user = user::find($this->user_id);     // executing action     $isactivated = $user->activate('123456'));     // performing assertion     $this->asserttrue($isactivated);     // checking data saved database     $i->seerecord('users', [         'id' => $this->user_id,         'is_active' => 1      ]); } 

you tester object param test function. if it's testguy, webguy or else, have in codeception.yml configuration.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -