@@ -45,6 +45,7 @@ public function testLoadClassMetadata()
45
45
'alreadyMappedNotNull ' ,
46
46
'alreadyMappedNotBlank ' ,
47
47
'alreadyPartiallyMappedCollection ' ,
48
+ 'readOnly ' ,
48
49
])
49
50
;
50
51
$ propertyInfoStub
@@ -58,11 +59,27 @@ public function testLoadClassMetadata()
58
59
[new Type (Type::BUILTIN_TYPE_FLOAT , true )], // The existing constraint is float
59
60
[new Type (Type::BUILTIN_TYPE_STRING , true )],
60
61
[new Type (Type::BUILTIN_TYPE_STRING , true )],
61
- [new Type (Type::BUILTIN_TYPE_ARRAY , true , null , true , null , new Type (Type::BUILTIN_TYPE_FLOAT ))]
62
+ [new Type (Type::BUILTIN_TYPE_ARRAY , true , null , true , null , new Type (Type::BUILTIN_TYPE_FLOAT ))],
63
+ [new Type (Type::BUILTIN_TYPE_STRING )]
64
+ ))
65
+ ;
66
+ $ propertyInfoStub
67
+ ->method ('isWritable ' )
68
+ ->will ($ this ->onConsecutiveCalls (
69
+ true ,
70
+ true ,
71
+ true ,
72
+ true ,
73
+ true ,
74
+ true ,
75
+ true ,
76
+ true ,
77
+ true ,
78
+ false
62
79
))
63
80
;
64
81
65
- $ propertyInfoLoader = new PropertyInfoLoader ($ propertyInfoStub , $ propertyInfoStub );
82
+ $ propertyInfoLoader = new PropertyInfoLoader ($ propertyInfoStub , $ propertyInfoStub, $ propertyInfoStub );
66
83
67
84
$ validator = Validation::createValidatorBuilder ()
68
85
->enableAnnotationMapping ()
@@ -137,6 +154,9 @@ public function testLoadClassMetadata()
137
154
$ this ->assertSame ('string ' , $ alreadyPartiallyMappedCollectionConstraints [0 ]->constraints [0 ]->type );
138
155
$ this ->assertInstanceOf (Iban::class, $ alreadyPartiallyMappedCollectionConstraints [0 ]->constraints [1 ]);
139
156
$ this ->assertInstanceOf (NotNull::class, $ alreadyPartiallyMappedCollectionConstraints [0 ]->constraints [2 ]);
157
+
158
+ $ readOnlyMetadata = $ classMetadata ->getPropertyMetadata ('readOnly ' );
159
+ $ this ->assertEmpty ($ readOnlyMetadata );
140
160
}
141
161
142
162
/**
@@ -154,7 +174,7 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp
154
174
->willReturn ([new Type (Type::BUILTIN_TYPE_STRING )])
155
175
;
156
176
157
- $ propertyInfoLoader = new PropertyInfoLoader ($ propertyInfoStub , $ propertyInfoStub , $ classValidatorRegexp );
177
+ $ propertyInfoLoader = new PropertyInfoLoader ($ propertyInfoStub , $ propertyInfoStub , $ propertyInfoStub , $ classValidatorRegexp );
158
178
159
179
$ classMetadata = new ClassMetadata (PropertyInfoLoaderEntity::class);
160
180
$ this ->assertSame ($ expected , $ propertyInfoLoader ->loadClassMetadata ($ classMetadata ));
0 commit comments