I'm having a problem. I have a unit test that is trying to access methods from a class. My unit test is as follows
public function testReverseArraySuccess()
{
$data = "This is a test.";
$output = (new Reverse)
->setInput($data)
->get();
$this->assertEquals(['test', 'a', 'is', 'This'], $output);
}
My class is a follows
class Reverse
{
public $input;
/**
*
* @param $data
*/
public function setInput($data) {
$this->input = $data;
}
/**
*
*@return void
*/
public function get()
{
return $this->input;
}
}
How can I setup my class so that my Test will pass? The error I get when I run the test is.
Error : Call to a member function get() on null