【发布时间】:2022-01-16 01:36:04
【问题描述】:
我很难理解如何为这段代码编写单元测试
$qb = $documentManager->getRepository('Document:Account')->createQueryBuilder();
$qb->remove(\project\Document\Account::class)->field('username')
->equals($userAccount->getUsername())->getQuery()->execute();
这是我模拟这部分的尝试
$account = new account();
$documentAccount = $this->createMock(documentAccount::class);
$this->dm->expects($this->any())->method('getRepository')
->with($documentAccount)
->willReturn($account);
提前谢谢你。
PHP 单元:PHPUnit 8.5.21
PHP:PHP 7.2.34
Symfony:Symfony 4.4.18
【问题讨论】: