I'm learning phpspec and can't figure out why a test is not passing.
Here is my function:
public function isTaskForChange($task)
{
$supportedTasks = array_keys($this->availableTasks());
$isTaskForChange = in_array($task, $supportedTasks);
return $isTaskForChange;
}
And here is the test in phpspec:
public function it_validates_if_task_should_be_changed()
{
$this->isTaskForChange('write')->shouldReturn(true);
}
However, when I run this code I get back:
warning: array_keys() expects parameter 1 to be array, null given
My question is: How to mock $this->availableTasks() to return values?