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

Commit b3c36f5

Browse files
fixed wrong config-key
added test to cover deprecated createDelegatorWithName method
1 parent d6d0600 commit b3c36f5

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/HydratorManagerDelegatorFactoryTest.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Tobias\Expressive\Hydrator\HydratorManagerDelegatorFactory;
2929
use Zend\Hydrator\HydratorPluginManager;
3030
use Zend\ServiceManager\DelegatorFactoryInterface;
31+
use Zend\ServiceManager\ServiceLocatorInterface;
3132

3233
/**
3334
* Class HydratorManagerDelegatorFactoryTest
@@ -36,14 +37,28 @@
3637
class HydratorManagerDelegatorFactoryTest extends \PHPUnit_Framework_TestCase
3738
{
3839

39-
public function testInvoke()
40+
/**
41+
* @return array
42+
*/
43+
public function dataProvider()
44+
{
45+
return [
46+
[ContainerInterface::class, '__invoke'],
47+
[ServiceLocatorInterface::class, 'createDelegatorWithName'],
48+
];
49+
}
50+
51+
/**
52+
* @dataProvider dataProvider
53+
*/
54+
public function testInvoke($interface, $method)
4055
{
4156
$config = [
42-
'input_filters' => [],
57+
'hydrators' => [],
4358
];
4459

4560
/** @var ContainerInterface|\PHPUnit_Framework_MockObject_MockObject $container */
46-
$container = $this->getMockBuilder(ContainerInterface::class)->getMockForAbstractClass();
61+
$container = $this->getMockBuilder($interface)->getMockForAbstractClass();
4762
$container->expects($this->once())->method('has')->with('config')->will($this->returnValue(true));
4863
$container->expects($this->once())->method('get')->with('config')->will($this->returnValue($config));
4964

@@ -53,7 +68,11 @@ public function testInvoke()
5368
$subject = new HydratorManagerDelegatorFactory();
5469
$this->assertInstanceOf(DelegatorFactoryInterface::class, $subject);
5570

56-
$instance = $subject($container, 'HydratorManager', $callback);
71+
if ($container instanceof ServiceLocatorInterface) {
72+
$instance = $subject->$method($container, 'HydratorManager', 'HydratorManager', $callback);
73+
} else {
74+
$instance = $subject->$method($container, 'HydratorManager', $callback);
75+
}
5776
$this->assertInstanceOf(HydratorPluginManager::class, $instance);
5877
}
5978
}

0 commit comments

Comments
 (0)