Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1494 from Labstep/testing/improve-paginator-coverage
Improve testing coverage for src/Paginator/
- Loading branch information
Showing
4 changed files
with
125 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSElasticaBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\ElasticaBundle\Tests\Unit\Event; | ||
|
||
use FOS\ElasticaBundle\Paginator\HybridPaginatorAdapter; | ||
use Elastica\Query; | ||
use Elastica\SearchableInterface; | ||
use FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface; | ||
use FOS\ElasticaBundle\Tests\Unit\UnitTestHelper; | ||
|
||
class HybridPaginatorAdapterTest extends UnitTestHelper | ||
{ | ||
protected function mockHybridPaginatorAdapter($args) | ||
{ | ||
$mock = $this | ||
->getMockBuilder(HybridPaginatorAdapter::class) | ||
->setConstructorArgs($args) | ||
->setMethods(['getElasticaResults']) | ||
->getMock(); | ||
|
||
$resultSet = $this->mockResultSet(); | ||
|
||
$mock | ||
->expects($this->exactly(1)) | ||
->method('getElasticaResults') | ||
->willReturn($resultSet); | ||
|
||
return $mock; | ||
} | ||
|
||
public function testGetResults() | ||
{ | ||
$searchable = $this->mockSearchable(); | ||
$query = new Query(); | ||
$transformer = $this->mockElasticaToModelTransformer(); | ||
|
||
$adapter = $this->mockHybridPaginatorAdapter([$searchable, $query, $transformer]); | ||
$adapter->getResults(0, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSElasticaBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\ElasticaBundle\Tests\Unit\Event; | ||
|
||
use FOS\ElasticaBundle\Paginator\HybridPartialResults; | ||
use Elastica\ResultSet; | ||
use FOS\ElasticaBundle\Tests\Unit\UnitTestHelper; | ||
|
||
class HybridPartialResultsTest extends UnitTestHelper | ||
{ | ||
protected function mockResultSet() | ||
{ | ||
$mock = $this | ||
->getMockBuilder(ResultSet::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$mock | ||
->expects($this->exactly(1)) | ||
->method('getResults') | ||
->willReturn([]); | ||
|
||
return $mock; | ||
} | ||
|
||
public function testToArray() | ||
{ | ||
$transformer = $this->mockElasticaToModelTransformer(); | ||
|
||
$resultSet = $this->mockResultSet(); | ||
|
||
$results = new HybridPartialResults($resultSet, $transformer); | ||
|
||
$results->toArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters