FOSElasticaBundle/Tests/IndexManagerTest.php
Jeremy Mikola 440c36f537 Merge remote-tracking branch 'cevou/master' into pr/245
Conflicts:
	Command/PopulateCommand.php
	Command/SearchCommand.php
	DependencyInjection/Configuration.php
	Doctrine/AbstractElasticaToModelTransformer.php
	Doctrine/AbstractListener.php
	Doctrine/MongoDB/ElasticaToModelTransformer.php
	Doctrine/ORM/ElasticaToModelTransformer.php
	Doctrine/RepositoryManager.php
	Finder/TransformedFinder.php
	Paginator/PaginatorAdapterInterface.php
	Paginator/RawPaginatorAdapter.php
	Persister/ObjectPersister.php
	Propel/ElasticaToModelTransformer.php
	Subscriber/PaginateElasticaQuerySubscriber.php
	Tests/DataCollector/ElasticaDataCollectorTest.php
	Tests/Doctrine/AbstractProviderTest.php
	Tests/Doctrine/RepositoryManagerTest.php
	Tests/Manager/RepositoryManagerTest.php
	Tests/RepositoryTest.php
	Transformer/ElasticaToModelTransformerCollection.php
	composer.json
2013-03-27 14:58:34 -04:00

59 lines
1.7 KiB
PHP

<?php
namespace FOS\ElasticaBundle\Tests\IndexManager;
use FOS\ElasticaBundle\IndexManager;
class IndexManagerTest extends \PHPUnit_Framework_TestCase
{
private $defaultIndexName;
private $indexesByName;
/** @var IndexManager */
private $indexManager;
public function setUp()
{
$this->defaultIndexName = 'index2';
$this->indexesByName = array(
'index1' => 'test1',
'index2' => 'test2',
);
/** @var $defaultIndex \PHPUnit_Framework_MockObject_MockObject|\Elastica_Index */
$defaultIndex = $this->getMockBuilder('Elastica_Index')
->disableOriginalConstructor()
->getMock();
$defaultIndex->expects($this->any())
->method('getName')
->will($this->returnValue($this->defaultIndexName));
$this->indexManager = new IndexManager($this->indexesByName, $defaultIndex);
}
public function testGetAllIndexes()
{
$this->assertEquals($this->indexesByName, $this->indexManager->getAllIndexes());
}
public function testGetIndex()
{
$this->assertEquals($this->indexesByName['index1'], $this->indexManager->getIndex('index1'));
$this->assertEquals($this->indexesByName['index2'], $this->indexManager->getIndex('index2'));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testGetIndexShouldThrowExceptionForInvalidName()
{
$this->indexManager->getIndex('index3');
}
public function testGetDefaultIndex()
{
$this->assertEquals('test2', $this->indexManager->getIndex());
$this->assertEquals('test2', $this->indexManager->getDefaultIndex());
}
}