10
10
namespace ZendTest \Form \Annotation ;
11
11
12
12
use PHPUnit \Framework \TestCase ;
13
+ use Zend \Hydrator \ClassMethods ;
14
+ use Zend \Hydrator \ClassMethodsHydrator ;
15
+ use Zend \Hydrator \ObjectProperty ;
16
+ use Zend \Hydrator \ObjectPropertyHydrator ;
13
17
use Zend \Form \Annotation ;
14
18
use ZendTest \Form \TestAsset ;
15
19
16
20
class AnnotationBuilderTest extends TestCase
17
21
{
22
+ /** @var string */
23
+ private $ classMethodsHydratorClass ;
24
+
25
+ /** @var string */
26
+ private $ objectPropertyHydratorClass ;
27
+
18
28
public function setUp ()
19
29
{
20
30
if (! getenv ('TESTS_ZEND_FORM_ANNOTATION_SUPPORT ' )) {
21
31
$ this ->markTestSkipped ('Enable TESTS_ZEND_FORM_ANNOTATION_SUPPORT to test annotation parsing ' );
22
32
}
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;
23
41
}
24
42
25
43
public function testCanCreateFormFromStandardEntity ()
@@ -111,7 +129,7 @@ public function testComplexEntityCreationWithPriorities()
111
129
$ this ->assertSame ($ email , $ test , 'Test is element ' . $ test ->getName ());
112
130
113
131
$ hydrator = $ form ->getHydrator ();
114
- $ this ->assertInstanceOf (' Zend\Hydrator\ObjectProperty ' , $ hydrator );
132
+ $ this ->assertInstanceOf ($ this -> objectPropertyHydratorClass , $ hydrator );
115
133
}
116
134
117
135
public function testFieldsetOrder ()
@@ -292,7 +310,7 @@ public function testCanHandleHydratorArrayAnnotation()
292
310
$ form = $ builder ->createForm ($ entity );
293
311
294
312
$ hydrator = $ form ->getHydrator ();
295
- $ this ->assertInstanceOf (' Zend\Hydrator\ClassMethods ' , $ hydrator );
313
+ $ this ->assertInstanceOf ($ this -> classMethodsHydratorClass , $ hydrator );
296
314
$ this ->assertFalse ($ hydrator ->getUnderscoreSeparatedKeys ());
297
315
}
298
316
@@ -360,7 +378,7 @@ public function testObjectElementAnnotation()
360
378
361
379
$ this ->assertInstanceOf ('Zend\Form\Fieldset ' , $ fieldset );
362
380
$ this ->assertInstanceOf ('ZendTest\Form\TestAsset\Annotation\Entity ' , $ fieldset ->getObject ());
363
- $ this ->assertInstanceOf (" Zend\Hydrator\ClassMethods " , $ fieldset ->getHydrator ());
381
+ $ this ->assertInstanceOf ($ this -> classMethodsHydratorClass , $ fieldset ->getHydrator ());
364
382
$ this ->assertFalse ($ fieldset ->getHydrator ()->getUnderscoreSeparatedKeys ());
365
383
}
366
384
@@ -375,7 +393,7 @@ public function testInstanceElementAnnotation()
375
393
376
394
$ this ->assertInstanceOf ('Zend\Form\Fieldset ' , $ fieldset );
377
395
$ this ->assertInstanceOf ('ZendTest\Form\TestAsset\Annotation\Entity ' , $ fieldset ->getObject ());
378
- $ this ->assertInstanceOf (" Zend\Hydrator\ClassMethods " , $ fieldset ->getHydrator ());
396
+ $ this ->assertInstanceOf ($ this -> classMethodsHydratorClass , $ fieldset ->getHydrator ());
379
397
$ this ->assertFalse ($ fieldset ->getHydrator ()->getUnderscoreSeparatedKeys ());
380
398
}
381
399
0 commit comments