我正在phpunit中进行单元测试。我试图模拟实体存储库函数 getTips()。在控制器中调用此函数。
我的模拟 getTips 功能的测试代码如下:
$settingsObj = $this->createMock(\Base\Entity\Setting::class);
$settingsObj->expects($this->once())
->method('getTips')
->will($this->returnValue([]));
$settingsRepository = $this->getMockBuilder(\Base\Repository\Setting::class)->disableOriginalConstructor()->getMock();
$settingsRepository->expects($this->once())
->method('getTips')
->will($this->returnValue($settingsObj));
$entityManager = $this->getMockBuilder(EntityManager::class)->disableOriginalConstructor()->getMock();
$entityManager->expects($this->once())
->method('getRepository')
->will($this->returnValue($settingsRepository));
我收到此错误:
尝试配置方法" getTips"无法配置 因为它不存在,尚未指定,是最终的,或者是 静态