|
9 | 9 |
|
10 | 10 | namespace ZendTest\Stdlib\Hydrator;
|
11 | 11 |
|
12 |
| -use Zend\Stdlib\Hydrator\DelegatingHydrator; |
13 | 12 | use ArrayObject;
|
| 13 | +use Interop\Container\ContainerInterface; |
| 14 | +use Prophecy\Argument; |
| 15 | +use Zend\ServiceManager\ServiceLocatorInterface; |
| 16 | +use Zend\Stdlib\Hydrator\DelegatingHydrator; |
| 17 | +use Zend\Stdlib\Hydrator\HydratorInterface; |
14 | 18 |
|
15 | 19 | /**
|
16 | 20 | * Unit tests for {@see \Zend\Stdlib\Hydrator\DelegatingHydrator}
|
@@ -39,51 +43,31 @@ class DelegatingHydratorTest extends \PHPUnit_Framework_TestCase
|
39 | 43 | */
|
40 | 44 | public function setUp()
|
41 | 45 | {
|
42 |
| - $this->hydrators = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); |
43 |
| - $this->hydrator = new DelegatingHydrator($this->hydrators); |
| 46 | + $this->hydrators = $this->prophesize(ServiceLocatorInterface::class); |
| 47 | + $this->hydrators->willImplement(ContainerInterface::class); |
| 48 | + $this->hydrator = new DelegatingHydrator($this->hydrators->reveal()); |
44 | 49 | $this->object = new ArrayObject;
|
45 | 50 | }
|
46 | 51 |
|
47 | 52 | public function testExtract()
|
48 | 53 | {
|
49 |
| - $this->hydrators->expects($this->any()) |
50 |
| - ->method('has') |
51 |
| - ->with('ArrayObject') |
52 |
| - ->will($this->returnValue(true)); |
53 |
| - |
54 |
| - $hydrator = $this->getMock('Zend\Stdlib\Hydrator\HydratorInterface'); |
| 54 | + $hydrator = $this->prophesize(HydratorInterface::class); |
| 55 | + $hydrator->extract($this->object)->willReturn(['foo' => 'bar']); |
55 | 56 |
|
56 |
| - $this->hydrators->expects($this->any()) |
57 |
| - ->method('get') |
58 |
| - ->with('ArrayObject') |
59 |
| - ->will($this->returnValue($hydrator)); |
| 57 | + $this->hydrators->has(ArrayObject::class)->willReturn(true); |
| 58 | + $this->hydrators->get(ArrayObject::class)->willReturn($hydrator->reveal()); |
60 | 59 |
|
61 |
| - $hydrator->expects($this->any()) |
62 |
| - ->method('extract') |
63 |
| - ->with($this->object) |
64 |
| - ->will($this->returnValue(['foo' => 'bar'])); |
65 |
| - |
66 |
| - $this->assertEquals(['foo' => 'bar'], $hydrator->extract($this->object)); |
| 60 | + $this->assertEquals(['foo' => 'bar'], $this->hydrator->extract($this->object)); |
67 | 61 | }
|
68 | 62 |
|
69 | 63 | public function testHydrate()
|
70 | 64 | {
|
71 |
| - $this->hydrators->expects($this->any()) |
72 |
| - ->method('has') |
73 |
| - ->with('ArrayObject') |
74 |
| - ->will($this->returnValue(true)); |
75 |
| - |
76 |
| - $hydrator = $this->getMock('Zend\Stdlib\Hydrator\HydratorInterface'); |
| 65 | + $hydrator = $this->prophesize(HydratorInterface::class); |
| 66 | + $hydrator->hydrate(['foo' => 'bar'], $this->object)->willReturn($this->object); |
77 | 67 |
|
78 |
| - $this->hydrators->expects($this->any()) |
79 |
| - ->method('get') |
80 |
| - ->with('ArrayObject') |
81 |
| - ->will($this->returnValue($hydrator)); |
| 68 | + $this->hydrators->has(ArrayObject::class)->willReturn(true); |
| 69 | + $this->hydrators->get(ArrayObject::class)->willReturn($hydrator->reveal()); |
82 | 70 |
|
83 |
| - $hydrator->expects($this->any()) |
84 |
| - ->method('hydrate') |
85 |
| - ->with(['foo' => 'bar'], $this->object) |
86 |
| - ->will($this->returnValue($this->object)); |
87 |
| - $this->assertEquals($this->object, $hydrator->hydrate(['foo' => 'bar'], $this->object)); |
| 71 | + $this->assertEquals($this->object, $this->hydrator->hydrate(['foo' => 'bar'], $this->object)); |
88 | 72 | }
|
89 | 73 | }
|
0 commit comments