Added findHybrid to Repository
This commit is contained in:
parent
43e6e84c5b
commit
a14d56720f
2 changed files with 37 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue