forked from FriendsOfSymfony/FOSElasticaBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 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,37 @@ | ||
<?php | ||
|
||
namespace FOQ\ElasticaBundle\Tests\Populator; | ||
|
||
use FOQ\ElasticaBundle\Populator; | ||
use FOQ\ElasticaBundle\Provider\ProviderInterface; | ||
use Closure; | ||
|
||
class PopulatorMock extends Populator | ||
{ | ||
public $providers = array(); | ||
} | ||
|
||
class PopulatorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testThatWeCanAddProvider() | ||
{ | ||
$provider = $this->getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate')); | ||
|
||
$populator = new PopulatorMock(array()); | ||
$populator->addProvider('l3l0Provider', $provider); | ||
|
||
$this->assertEquals(count($populator->providers), 1); | ||
$this->assertArrayHasKey('l3l0Provider', $populator->providers); | ||
$this->assertInstanceOf('FOQ\ElasticaBundle\Provider\ProviderInterface', $populator->providers['l3l0Provider']); | ||
} | ||
|
||
public function testThatPopulateThroughProviders() | ||
{ | ||
$provider = $this->getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate')); | ||
$provider->expects($this->once()) | ||
->method('populate'); | ||
|
||
$populator = new Populator(array('l3l0Provider' => $provider)); | ||
$populator->populate(function ($text) { return $text; }); | ||
} | ||
} |