public function testFindOneWithScopesByToken() { $token = 'foo'; $qbm = new QueryBuilderMocker($this); $qbm->select('token, scopes')->leftJoin('token.scopes', 'scopes')->where('token.token = :token')->setParameter('token', $token)->setMaxResults(1)->getQuery()->getSingleResult(); $this->entityManager->shouldReceive('createQueryBuilder')->andReturn($qbm->getQueryBuilderMock()); $this->repository->findOneWithScopesByToken($token); }
public function testCanMockChainedMethodCallsToQuery() { $qbm = new QueryBuilderMocker($this); $qbm->select('fieldName')->where('property = ?')->andWhere('otherProperty =:otherValue')->getQuery()->execute('it works!'); $qb = $qbm->getQueryBuilderMock(); $result = $qb->select('fieldName')->where('property = ?')->andWhere('otherProperty =:otherValue')->getQuery()->execute(); $this->assertSame('it works!', $result); }