Renamed and moved repository manager
This commit is contained in:
parent
68a2fbca67
commit
98536d3f29
3 changed files with 13 additions and 12 deletions
74
Tests/Manager/RepositoryManagerTest.php
Normal file
74
Tests/Manager/RepositoryManagerTest.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Tests\Manager;
|
||||
|
||||
use FOQ\ElasticaBundle\Manager\RepositoryManager;
|
||||
|
||||
class CustomRepository{}
|
||||
|
||||
/**
|
||||
* @author Richard Miller <info@limethinking.co.uk>
|
||||
*/
|
||||
class RepositoryManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testThatGetRepositoryReturnsDefaultRepository()
|
||||
{
|
||||
$finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entityName = 'Test Entity';
|
||||
|
||||
$manager = new RepositoryManager($finderMock);
|
||||
$manager->addEntity($entityName, $finderMock);
|
||||
$repository = $manager->getRepository($entityName);
|
||||
$this->assertInstanceOf('FOQ\ElasticaBundle\Repository', $repository);
|
||||
}
|
||||
|
||||
public function testThatGetRepositoryReturnsCustomRepository()
|
||||
{
|
||||
$finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entityName = 'Test Entity';
|
||||
|
||||
$manager = new RepositoryManager($finderMock);
|
||||
$manager->addEntity($entityName, $finderMock, 'FOQ\ElasticaBundle\Tests\Manager\CustomRepository');
|
||||
$repository = $manager->getRepository($entityName);
|
||||
$this->assertInstanceOf('FOQ\ElasticaBundle\Tests\Manager\CustomRepository', $repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testThatGetRepositoryThrowsExceptionIfEntityNotConfigured()
|
||||
{
|
||||
$finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entityName = 'Test Entity';
|
||||
|
||||
$manager = new RepositoryManager($finderMock);
|
||||
$manager->addEntity($entityName, $finderMock);
|
||||
$manager->getRepository('Missing Entity');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testThatGetRepositoryThrowsExceptionIfCustomRepositoryNotFound()
|
||||
{
|
||||
$finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entityName = 'Test Entity';
|
||||
|
||||
$manager = new RepositoryManager($finderMock);
|
||||
$manager->addEntity($entityName, $finderMock, 'FOQ\ElasticaBundle\Tests\MissingRepository');
|
||||
$manager->getRepository('Missing Entity');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue