11
11
12
12
declare (strict_types=1 );
13
13
14
- namespace ApiPlatform \Core \Tests \Doctrine \Util ;
14
+ namespace ApiPlatform \Core \Tests \Bridge \ Doctrine \Util ;
15
15
16
16
use ApiPlatform \Core \Bridge \Doctrine \Orm \Util \IdentifierManagerTrait ;
17
17
use ApiPlatform \Core \Metadata \Property \Factory \PropertyMetadataFactoryInterface ;
26
26
use Doctrine \DBAL \Types \Type as DBALType ;
27
27
use Doctrine \ORM \EntityManagerInterface ;
28
28
29
- class IdentifierManagerTraitImpl
29
+ class IdentifierManagerTraitTest extends \PHPUnit_Framework_TestCase
30
30
{
31
- use IdentifierManagerTrait {
32
- IdentifierManagerTrait::normalizeIdentifiers as public ;
33
- }
34
-
35
- public function __construct (PropertyNameCollectionFactoryInterface $ propertyNameCollectionFactory , PropertyMetadataFactoryInterface $ propertyMetadataFactory )
31
+ private function getIdentifierManagerTraitImpl (PropertyNameCollectionFactoryInterface $ propertyNameCollectionFactory , PropertyMetadataFactoryInterface $ propertyMetadataFactory )
36
32
{
37
- $ this ->propertyNameCollectionFactory = $ propertyNameCollectionFactory ;
38
- $ this ->propertyMetadataFactory = $ propertyMetadataFactory ;
33
+ return new class ($ propertyNameCollectionFactory , $ propertyMetadataFactory ) {
34
+ use IdentifierManagerTrait {
35
+ IdentifierManagerTrait::normalizeIdentifiers as public ;
36
+ }
37
+
38
+ public function __construct (PropertyNameCollectionFactoryInterface $ propertyNameCollectionFactory , PropertyMetadataFactoryInterface $ propertyMetadataFactory )
39
+ {
40
+ $ this ->propertyNameCollectionFactory = $ propertyNameCollectionFactory ;
41
+ $ this ->propertyMetadataFactory = $ propertyMetadataFactory ;
42
+ }
43
+ };
39
44
}
40
- }
41
45
42
- class IdentifierManagerTraitTest extends \PHPUnit_Framework_TestCase
43
- {
44
46
public function testSingleIdentifier ()
45
47
{
46
48
list ($ propertyNameCollectionFactory , $ propertyMetadataFactory ) = $ this ->getMetadataFactories (Dummy::class, [
@@ -52,7 +54,7 @@ public function testSingleIdentifier()
52
54
],
53
55
]);
54
56
55
- $ identifierManager = new IdentifierManagerTraitImpl ($ propertyNameCollectionFactory , $ propertyMetadataFactory );
57
+ $ identifierManager = $ this -> getIdentifierManagerTraitImpl ($ propertyNameCollectionFactory , $ propertyMetadataFactory );
56
58
57
59
$ this ->assertEquals ($ identifierManager ->normalizeIdentifiers (1 , $ objectManager , Dummy::class), ['id ' => 1 ]);
58
60
}
@@ -72,7 +74,7 @@ public function testCompositeIdentifier()
72
74
],
73
75
]);
74
76
75
- $ identifierManager = new IdentifierManagerTraitImpl ($ propertyNameCollectionFactory , $ propertyMetadataFactory );
77
+ $ identifierManager = $ this -> getIdentifierManagerTraitImpl ($ propertyNameCollectionFactory , $ propertyMetadataFactory );
76
78
77
79
$ this ->assertEquals ($ identifierManager ->normalizeIdentifiers ('ida=1;idb=2 ' , $ objectManager , Dummy::class), ['ida ' => 1 , 'idb ' => 2 ]);
78
80
}
@@ -96,7 +98,7 @@ public function testInvalidIdentifier()
96
98
],
97
99
]);
98
100
99
- $ identifierManager = new IdentifierManagerTraitImpl ($ propertyNameCollectionFactory , $ propertyMetadataFactory );
101
+ $ identifierManager = $ this -> getIdentifierManagerTraitImpl ($ propertyNameCollectionFactory , $ propertyMetadataFactory );
100
102
101
103
$ identifierManager ->normalizeIdentifiers ('idbad=1;idb=2 ' , $ objectManager , Dummy::class);
102
104
}
0 commit comments