createMock(EntityManager::class); $qb = $this->createMock(QueryBuilder::class); $query = $this->createMock(AbstractQuery::class); $expr = $this->createMock(Expr::class); if ($resultMock !== null) { $query->expects($this->any())->method('execute')->willReturn($resultMock); } $expr->expects($this->any())->method('isNotNull')->willReturn(''); $expr->expects($this->any())->method('in')->willReturn(''); $qb->expects($this->any())->method('andWhere')->willReturnSelf(); $qb->expects($this->any())->method('from')->willReturnSelf(); $qb->expects($this->any())->method('expr')->willReturn($expr); $qb->expects($this->any())->method('from')->willReturnSelf(); $qb->expects($this->any())->method('select')->willReturnSelf(); $qb->expects($this->any())->method('leftJoin')->willReturnSelf(); $qb->expects($this->any())->method('getQuery')->willReturn($query); $query->expects($this->any())->method('execute')->willReturn(null); $em->expects($this->exactly($createQueryBuilderCount))->method('createQueryBuilder')->willReturn($qb); return $em; } }