From a14d56720f5d4280f6293532095b2cc0a3481a02 Mon Sep 17 00:00:00 2001 From: Richard Miller Date: Tue, 7 Aug 2012 19:25:43 +0100 Subject: [PATCH] Added findHybrid to Repository --- Repository.php | 7 +++++-- Tests/RepositoryTest.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Repository.php b/Repository.php index b70166f..63eea71 100644 --- a/Repository.php +++ b/Repository.php @@ -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); } - } diff --git a/Tests/RepositoryTest.php b/Tests/RepositoryTest.php index 1b44543..6d51f29 100644 --- a/Tests/RepositoryTest.php +++ b/Tests/RepositoryTest.php @@ -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); + } + }