I'd like to Mock the getReviews
method of the CommentModel
so I can test if it's called in the ApiReviewCommentsController
Method.
This is my method:
class ApiReviewCommentsController extends ApiController
{
private $commentsModel;
public function __construct(CommentsModel $commentsModel)
{
$this->commentsModel = $commentsModel;
$this->commentsModel->getReviewComment();
}
}
This is my test:
public function testThatItShouldAddGetAllCommentsForReviewId(){
$reviewId = 1;
$commentsModel = $this->getMockBuilder(CommentsModel::class)->getMock();
$controller = new ApiReviewCommentsController($commentsModel);
$commentsModel->expects($this->once())
->method('getReviewComments')
->willReturn(false);
}
This is my error:
Expectation failed for method name is equal to when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.
Please why is the method not called?