Reputation: 700
I'm trying to fix a test but somehow my value keeps being NULL
in the next function.
I'm using the Selenium webdriver from Sebastian Bergmann.
So what I have:
protected $role;
// Setup ....
public function testRoles()
{
// Code ....
$this->role = 'hr'; // I want this value in the next function
}
public function testAcl()
{
// Login here
var_dump($this->role); // This var_dump is NULL , why?
$this->webDriver->getKeyboard()->sendKeys($this->role);
}
When I var_dump
$this->role
it gives NULL
Question: why is this? What did I forget/can do so it becomes the data I want: 'hr'
?
The error I'm getting: Invalid argument supplied for foreach()
It's because $this->role
is NULL
Upvotes: 0
Views: 45
Reputation: 41776
Call testRoles() to set $this-roles...
public function testAcl()
{
// call testRoles
$this->testRoles();
// now $this->role was set to hr by testRoles()
// work with it
var_dump($this->role);
}
Upvotes: 1
Reputation: 133
it's because you never set the role before var_dump($this->role); line. That means that you have to run the $this->testRoles() before var_dump($this->role);.
Upvotes: 1