Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit b43b717

Browse files
committed
Added test to demonstrate backwards compatibility
Added a test to demonstrate that the plugin manager returned is both an instance of the zend-hydrator plugin manager as well as the zend-stdlib HydratorPluginManager.
1 parent cdd53d2 commit b43b717

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/Service/HydratorManagerFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111

1212
class HydratorManagerFactory extends AbstractPluginManagerFactory
1313
{
14+
/**
15+
* @todo Switch to Zend\Hydrator\HydratorPluginManager for 3.0 (if kept)
16+
*/
1417
const PLUGIN_MANAGER_CLASS = 'Zend\Stdlib\Hydrator\HydratorPluginManager';
1518
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zf2 for the canonical source repository
6+
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
*/
9+
10+
namespace ZendTest\Mvc\Service;
11+
12+
use PHPUnit_Framework_TestCase as TestCase;
13+
use Zend\Hydrator\HydratorPluginManager as ZendHydratorManager;
14+
use Zend\Mvc\Service\HydratorManagerFactory;
15+
use Zend\ServiceManager\ServiceLocatorInterface;
16+
use Zend\Stdlib\Hydrator\HydratorPluginManager;
17+
18+
class HydratorManagerFactoryTest extends TestCase
19+
{
20+
public function setUp()
21+
{
22+
$this->factory = new HydratorManagerFactory();
23+
$this->services = $this->prophesize(ServiceLocatorInterface::class);
24+
$this->services->get('Config')->willReturn([]);
25+
}
26+
27+
public function testFactoryReturnsZendHydratorManagerInstance()
28+
{
29+
$hydrators = $this->factory->createService($this->services->reveal());
30+
$this->assertInstanceOf(ZendHydratorManager::class, $hydrators);
31+
return $hydrators;
32+
}
33+
34+
/**
35+
* @todo Remove for 3.0
36+
* @depends testFactoryReturnsZendHydratorManagerInstance
37+
*/
38+
public function testFactoryReturnsStdlibHydratorManagerInstance($hydrators)
39+
{
40+
$this->assertInstanceOf(HydratorPluginManager::class, $hydrators);
41+
}
42+
}

0 commit comments

Comments
 (0)