I'm trying to mock a chain (nested) of methods to return the desired value , this is the code :
public function __construct($db)
{
$this->db = $db;
}
public function getResults()
{
return $this->db->getFinder()->find($this->DBTable);
}
I tried this mock but it does not work :
$dbMock = $this->createMock(DB::class);
$dbMock = $dbMock
->expects(self::any())
->method('getFinder')
->method('find')
->with('questions')
->will($this->returnValue('7'));
Any solutions how to solve such a problem ?
Thank you .