Skip to content

Commit

Permalink
test the DoctrineObject hydrator factory
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocarneiro authored and Gianluca Arbezzano committed Mar 31, 2015
1 parent ee19a36 commit 5cb80d1
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace DoctrineMongoODMModuleTest\Doctrine;

use Doctrine\ODM\MongoDB\DocumentManager;
use DoctrineModule\Stdlib\Hydrator\DoctrineObject;
use PHPUnit_Framework_TestCase as TestCase;
use DoctrineMongoODMModule\Service\DoctrineObjectHydratorFactory;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Stdlib\Hydrator\HydratorPluginManager;

class DoctrineObjectHydratorFactoryTest extends TestCase
{
public function testReturnsHydratorInstance()
{
$serviceLocatorInterface = $this->getMock(ServiceLocatorInterface::class);

$serviceLocatorInterface
->expects($this->once())
->method('get')
->with('doctrine.documentmanager.odm_default')
->willReturn(
$this->getMockBuilder(DocumentManager::class)
->disableOriginalConstructor()
->getMock()
);

/** @var HydratorPluginManager $hydratorPluginManager */
$hydratorPluginManager = $this->getMock(HydratorPluginManager::class);

$hydratorPluginManager
->expects($this->once())
->method('getServiceLocator')
->willReturn(
$serviceLocatorInterface
);


$factory = new DoctrineObjectHydratorFactory();
$hydrator = $factory($hydratorPluginManager);

$this->assertInstanceOf(DoctrineObject::class, $hydrator);
}
}

0 comments on commit 5cb80d1

Please sign in to comment.