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

Commit

Permalink
fixed wrong config-key
Browse files Browse the repository at this point in the history
added test to cover deprecated createDelegatorWithName method
  • Loading branch information
tobias-trozowski committed Dec 28, 2016
1 parent d6d0600 commit b3c36f5
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/HydratorManagerDelegatorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Tobias\Expressive\Hydrator\HydratorManagerDelegatorFactory;
use Zend\Hydrator\HydratorPluginManager;
use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Class HydratorManagerDelegatorFactoryTest
Expand All @@ -36,14 +37,28 @@
class HydratorManagerDelegatorFactoryTest extends \PHPUnit_Framework_TestCase
{

public function testInvoke()
/**
* @return array
*/
public function dataProvider()
{
return [
[ContainerInterface::class, '__invoke'],
[ServiceLocatorInterface::class, 'createDelegatorWithName'],
];
}

/**
* @dataProvider dataProvider
*/
public function testInvoke($interface, $method)
{
$config = [
'input_filters' => [],
'hydrators' => [],
];

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

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

$instance = $subject($container, 'HydratorManager', $callback);
if ($container instanceof ServiceLocatorInterface) {
$instance = $subject->$method($container, 'HydratorManager', 'HydratorManager', $callback);
} else {
$instance = $subject->$method($container, 'HydratorManager', $callback);
}
$this->assertInstanceOf(HydratorPluginManager::class, $instance);
}
}

0 comments on commit b3c36f5

Please sign in to comment.