Added findHybrid to Repository

This commit is contained in:
Richard Miller 2012-08-07 19:25:43 +01:00
commit a14d56720f
2 changed files with 37 additions and 2 deletions

View file

@ -17,15 +17,18 @@ class Repository
$this->finder = $finder;
}
public function find($query, $limit=null)
{
return $this->finder->find($query, $limit);
}
public function findHybrid($query, $limit=null)
{
return $this->finder->findHybrid($query, $limit);
}
public function findPaginated($query)
{
return $this->finder->findPaginated($query);
}
}

View file

@ -25,6 +25,22 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
$repository->find($testQuery);
}
public function testThatFindCallsFindOnFinderWithLimit()
{
$testQuery = 'Test Query';
$testLimit = 20;
$finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder')
->disableOriginalConstructor()
->getMock();
$finderMock->expects($this->once())
->method('find')
->with($this->equalTo($testQuery), $this->equalTo($testLimit));
$repository = new Repository($finderMock);
$repository->find($testQuery, $testLimit);
}
public function testThatFindPaginatedCallsFindPaginatedOnFinder()
{
$testQuery = 'Test Query';
@ -40,4 +56,20 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
$repository->findPaginated($testQuery);
}
public function testThatFindHybridCallsFindHybridOnFinder()
{
$testQuery = 'Test Query';
$testLimit = 20;
$finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder')
->disableOriginalConstructor()
->getMock();
$finderMock->expects($this->once())
->method('findHybrid')
->with($this->equalTo($testQuery), $this->equalTo($testLimit));
$repository = new Repository($finderMock);
$repository->findHybrid($testQuery, $testLimit);
}
}