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

Commit 8094381

Browse files
committed
Test case to enforce acceptance of deprecated HydratorInterface into methods typehinted on deprecated HydrationInterface and ExtractorInterface
1 parent 6a912d4 commit 8094381

3 files changed

+70
-0
lines changed

test/HydratorDeprecationTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,26 @@ public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWith
3434
$hydratorInjected->setHydrator($hydrator);
3535
$this->assertSame($hydrator, $hydratorInjected->hydrator);
3636
}
37+
38+
public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithDeprecatedHydrationInterface()
39+
{
40+
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedHydrationInterfaceTypehint();
41+
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
42+
set_error_handler(function ($errno, $errstr) {
43+
$this->fail('Catchable fatal error was triggered: ' . $errstr);
44+
}, E_RECOVERABLE_ERROR);
45+
$hydratorInjected->setHydrator($hydrator);
46+
$this->assertSame($hydrator, $hydratorInjected->hydrator);
47+
}
48+
49+
public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithDeprecatedExtractionInterface()
50+
{
51+
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedExtractionInterfaceTypehint();
52+
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
53+
set_error_handler(function ($errno, $errstr) {
54+
$this->fail('Catchable fatal error was triggered: ' . $errstr);
55+
}, E_RECOVERABLE_ERROR);
56+
$hydratorInjected->setExtractor($hydrator);
57+
$this->assertSame($hydrator, $hydratorInjected->extractor);
58+
}
3759
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
4+
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Stdlib\TestAsset;
9+
10+
use Zend\Stdlib\Extractor\ExtractionInterface;
11+
12+
/**
13+
* This test asset exists to see how deprecation works; it is associated with
14+
* the test ZendTest\Stdlib\HydratorDeprecationTest.
15+
*/
16+
class HydratorInjectedObjectUsingDeprecatedExtractionInterfaceTypehint
17+
{
18+
public $extractor;
19+
20+
public function setExtractor(ExtractionInterface $extractor)
21+
{
22+
$this->extractor = $extractor;
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
4+
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Stdlib\TestAsset;
9+
10+
use Zend\Stdlib\Hydrator\HydrationInterface;
11+
12+
/**
13+
* This test asset exists to see how deprecation works; it is associated with
14+
* the test ZendTest\Stdlib\HydratorDeprecationTest.
15+
*/
16+
class HydratorInjectedObjectUsingDeprecatedHydrationInterfaceTypehint
17+
{
18+
public $hydrator;
19+
20+
public function setHydrator(HydrationInterface $hydrator)
21+
{
22+
$this->hydrator = $hydrator;
23+
}
24+
}

0 commit comments

Comments
 (0)