-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test the DoctrineObject hydrator factory
- Loading branch information
1 parent
ee19a36
commit 5cb80d1
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
tests/DoctrineMongoODMModuleTest/Doctrine/DoctrineObjectHydratorFactoryTest.php
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,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); | ||
} | ||
} |