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

Commit e683f03

Browse files
committed
Fixes deprecation notices in AnnotationBuilderTest
- due to zend-hydrator v3/v2 differences
1 parent 66319ff commit e683f03

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

test/Annotation/AnnotationBuilderTest.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,34 @@
1010
namespace ZendTest\Form\Annotation;
1111

1212
use PHPUnit\Framework\TestCase;
13+
use Zend\Hydrator\ClassMethods;
14+
use Zend\Hydrator\ClassMethodsHydrator;
15+
use Zend\Hydrator\ObjectProperty;
16+
use Zend\Hydrator\ObjectPropertyHydrator;
1317
use Zend\Form\Annotation;
1418
use ZendTest\Form\TestAsset;
1519

1620
class AnnotationBuilderTest extends TestCase
1721
{
22+
/** @var string */
23+
private $classMethodsHydratorClass;
24+
25+
/** @var string */
26+
private $objectPropertyHydratorClass;
27+
1828
public function setUp()
1929
{
2030
if (! getenv('TESTS_ZEND_FORM_ANNOTATION_SUPPORT')) {
2131
$this->markTestSkipped('Enable TESTS_ZEND_FORM_ANNOTATION_SUPPORT to test annotation parsing');
2232
}
33+
34+
$this->classMethodsHydratorClass = class_exists(ClassMethodsHydrator::class)
35+
? ClassMethodsHydrator::class
36+
: ClassMethods::class;
37+
38+
$this->objectPropertyHydratorClass = class_exists(ObjectPropertyHydrator::class)
39+
? ObjectPropertyHydrator::class
40+
: ObjectProperty::class;
2341
}
2442

2543
public function testCanCreateFormFromStandardEntity()
@@ -111,7 +129,7 @@ public function testComplexEntityCreationWithPriorities()
111129
$this->assertSame($email, $test, 'Test is element ' . $test->getName());
112130

113131
$hydrator = $form->getHydrator();
114-
$this->assertInstanceOf('Zend\Hydrator\ObjectProperty', $hydrator);
132+
$this->assertInstanceOf($this->objectPropertyHydratorClass, $hydrator);
115133
}
116134

117135
public function testFieldsetOrder()
@@ -292,7 +310,7 @@ public function testCanHandleHydratorArrayAnnotation()
292310
$form = $builder->createForm($entity);
293311

294312
$hydrator = $form->getHydrator();
295-
$this->assertInstanceOf('Zend\Hydrator\ClassMethods', $hydrator);
313+
$this->assertInstanceOf($this->classMethodsHydratorClass, $hydrator);
296314
$this->assertFalse($hydrator->getUnderscoreSeparatedKeys());
297315
}
298316

@@ -360,7 +378,7 @@ public function testObjectElementAnnotation()
360378

361379
$this->assertInstanceOf('Zend\Form\Fieldset', $fieldset);
362380
$this->assertInstanceOf('ZendTest\Form\TestAsset\Annotation\Entity', $fieldset->getObject());
363-
$this->assertInstanceOf("Zend\Hydrator\ClassMethods", $fieldset->getHydrator());
381+
$this->assertInstanceOf($this->classMethodsHydratorClass, $fieldset->getHydrator());
364382
$this->assertFalse($fieldset->getHydrator()->getUnderscoreSeparatedKeys());
365383
}
366384

@@ -375,7 +393,7 @@ public function testInstanceElementAnnotation()
375393

376394
$this->assertInstanceOf('Zend\Form\Fieldset', $fieldset);
377395
$this->assertInstanceOf('ZendTest\Form\TestAsset\Annotation\Entity', $fieldset->getObject());
378-
$this->assertInstanceOf("Zend\Hydrator\ClassMethods", $fieldset->getHydrator());
396+
$this->assertInstanceOf($this->classMethodsHydratorClass, $fieldset->getHydrator());
379397
$this->assertFalse($fieldset->getHydrator()->getUnderscoreSeparatedKeys());
380398
}
381399

0 commit comments

Comments
 (0)