Skip to content

Commit

Permalink
PHPCR support
Browse files Browse the repository at this point in the history
  • Loading branch information
webda2l committed Mar 4, 2015
1 parent 4a02c3c commit e10c37b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Doctrine/PHPCR/ElasticaToModelTransformer.php
Expand Up @@ -21,8 +21,7 @@ class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
protected function findByIdentifiers(array $identifierValues, $hydrate)
{
// Special case where model is interface
$reflectionClass = new \ReflectionClass($this->objectClass);
if ($reflectionClass->isInterface()) {
if (interface_exists($this->objectClass, false)) {
return $this->registry
->getManager()
->findMany(null, $identifierValues)
Expand Down
23 changes: 22 additions & 1 deletion Tests/Doctrine/PHPCR/ElasticaToModelTransformerTest.php
Expand Up @@ -26,13 +26,34 @@ class ElasticaToModelTransformerTest extends \PHPUnit_Framework_TestCase
*/
protected $objectClass = 'stdClass';

/**
*
*/
public function testTransformUsesFindByIdentifier()
{
$this->registry->expects($this->any())
->method('getManager')
->will($this->returnValue($this->manager));

$transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass);

$class = new \ReflectionClass('FOS\ElasticaBundle\Doctrine\PHPCR\ElasticaToModelTransformer');
$method = $class->getMethod('findByIdentifiers');
$method->setAccessible(true);

$method->invokeArgs($transformer, array(
array('c8f23994-d897-4c77-bcc3-bc6910e52a34', 'f1083287-a67e-480e-a426-e8427d00eae4'),
$this->objectClass
));
}

protected function setUp()
{
if (!interface_exists('Doctrine\Common\Persistence\ManagerRegistry')) {
$this->markTestSkipped('Doctrine Common is not present');
}
if (!class_exists('Doctrine\ODM\PHPCR\DocumentManager')) {
$this->markTestSkipped('Doctrine Common is not present');
$this->markTestSkipped('Doctrine PHPCR is not present');
}

$this->registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
Expand Down

0 comments on commit e10c37b

Please sign in to comment.