mercredi 17 janvier 2018

Laravel Dusk Testing: Class property doesn't reflect the updated value in the next 'test' function

Testing class having a variable $uid is defined. It is then modified in the function testCreateNewUser. But when I try to use the variable in the function testRetrieveUser, it still holds the value with which it was declared. Why is the new value of variable $uid not reflected in the next test function?

class Testing extends DuskTestCase{

protected $uid = 'seed';

public function testCreateNewUser()
{
    $this->browse(function (Browser $browser) use ($user) {
        $browser->visit('/')
                ->assertSee('Laravel');
    });

    $this->uid = 'my new value';  //value assigned to $this->uid

    logger($this->uid);    //this logs correctly 'my new value'
}

public function testRetrieveUser()
{
    $uid = $this->uid;
    logger($uid);        //when logged, it shows 'seed'
}
}

Aucun commentaire:

Enregistrer un commentaire