Example #1
0
 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);
 }
 /**
  * @expectedException \BadMethodCallException
  * @expectedExceptionMessage Mocking "expr" is not supported.
  */
 public function testBadMethodCallExceptionIsThrownIfAttemptingToMockUnsupportedMethod()
 {
     $qbm = new QueryBuilderMocker($this);
     $qbm->expr();
 }
 /**
  * @author Lauri Orgla <*****@*****.**>
  * @covers \MMoussa\Doctrine\Test\ORM\QueryBuilderMocker::getQueryMock
  */
 public function testGetQueryMockReturnsMockObject()
 {
     $qbm = new QueryBuilderMocker($this);
     $qbm->getQuery()->execute();
     $queryMock = $qbm->getQueryMock();
     $queryBuilderMock = $qbm->getQueryBuilderMock();
     $this->assertInstanceOf('\\PHPUnit_Framework_MockObject_MockObject', $queryMock);
     $this->assertNull($queryBuilderMock->getQuery()->execute());
 }