4848 * * 'value_callback': callable || method name (in the TestCase class)
4949 * The return value of that callback is taken as value for the test.
5050 *
51- * * 'property': If there is no getter method, you may want to test, wether the setter has set
52- * a property on the SUT properly. This key may be
53- * - true: The name equals the property to check
54- * - string: Name of property to hold the expected value
55- * - [{PropertyName, }expected value (if differs from 'value']
56- *
57- * * 'property_assert': callback for property assertion.
58- * see 'assert'. But please note:
59- * strings are 'converted' to 'assertAttribute*' methods.
60- * The callback gets passed the expected value, the name of the
61- * property ('property') and the SUT instance.
62- * DEFAULT: 'equals' ( => static::assertAttributeEquals)
63- *
6451 * * 'getter': - Name of getter method (a '*' gets replaced by the property name)
6552 * - [GetterName, [arg, arg, ...]]
6653 * Use this format to provide arguments to the getter method.
@@ -167,17 +154,7 @@ public function testSetterAndGetter($name, $spec = null): void
167154 }
168155 }
169156
170- // Test property
171- if (null !== $ spec ['property ' ]) {
172- [$ propertyName , $ propertyValue ] = $ spec ['property ' ];
173- if ('__VALUE__ ' == $ propertyValue ) {
174- $ propertyValue = $ value ;
175- }
176-
177- $ spec ['property_assert ' ]($ propertyValue , $ propertyName , $ target );
178-
179- // Test getter
180- } elseif (false !== $ spec ['getter ' ][0 ]) {
157+ if (false !== $ spec ['getter ' ][0 ]) {
181158 $ getter = str_replace ('* ' , $ name , $ spec ['getter ' ][0 ]);
182159 $ getterValue = $ target ->$ getter (...$ spec ['getter ' ][1 ]);
183160 $ spec ['assert ' ]($ value , $ getterValue );
@@ -196,8 +173,6 @@ public function testSetterAndGetter($name, $spec = null): void
196173 private function setterAndGetterNormalizeSpec ($ spec , string $ name , object $ target ): array
197174 {
198175 $ normalized = [
199- 'property ' => null ,
200- 'property_assert ' => [static ::class, 'assertAttributeEquals ' ],
201176 'getter ' => ["get* " , []],
202177 'assert ' => [static ::class, 'assertEquals ' ],
203178 'setter ' => ["set* " , []],
@@ -215,31 +190,14 @@ private function setterAndGetterNormalizeSpec($spec, string $name, object $targe
215190 $ err = __TRAIT__ . ': ' . get_class ($ this ) . ': ' ;
216191
217192 if (!is_array ($ spec )) {
218- throw new \PHPUnit_Framework_Exception ($ err . 'Invalid specification. Must be array. ' );
193+ throw new \PHPUnit \ Framework \ Exception ($ err . 'Invalid specification. Must be array. ' );
219194 }
220195
221196 foreach ($ spec as $ key => $ value ) {
222197 switch ($ key ) {
223198 default :
224199 break ;
225200
226- case 'property ' :
227- if (true === $ value ) {
228- $ value = [$ name , '__VALUE__ ' ];
229- break ;
230- }
231-
232- if (is_array ($ value )) {
233- $ value = isset ($ value [1 ])
234- ? [true === $ value [0 ] ? $ name : $ value [0 ], $ value [1 ]]
235- : [$ name , $ value [0 ]]
236- ;
237- break ;
238- }
239-
240- $ value = [$ value , '__VALUE__ ' ];
241- break ;
242-
243201 case 'setter_value ' :
244202 if ('__SELF__ ' == $ value ) {
245203 $ value = $ target ;
@@ -286,7 +244,7 @@ private function setterAndGetterNormalizeSpec($spec, string $name, object $targe
286244 }
287245
288246 if (!is_callable ($ value )) {
289- throw new \PHPUnit_Framework_Exception ($ err . 'Invalid value callback. ' );
247+ throw new \PHPUnit \ Framework \ Exception ($ err . 'Invalid value callback. ' );
290248 }
291249
292250 $ key = substr ($ key , 0 , -9 );
@@ -295,19 +253,17 @@ private function setterAndGetterNormalizeSpec($spec, string $name, object $targe
295253
296254 case 'setter_assert ' :
297255 case 'assert ' :
298- case 'property_assert ' :
299256 if (is_string ($ value )) {
300257 if (method_exists ($ this , $ value )) {
301258 $ value = [$ this , $ value ];
302259 break ;
303260 }
304- $ attr = 'property_assert ' == $ key ? 'Attribute ' : '' ;
305- $ value = [static ::class, "assert $ attr$ value " ];
261+ $ value = [static ::class, "assert $ value " ];
306262 break ;
307263 }
308264
309265 if (!is_callable ($ value )) {
310- throw new \PHPUnit_Framework_Exception ($ err . 'Invalid assert callback. ' );
266+ throw new \PHPUnit \ Framework \ Exception ($ err . 'Invalid assert callback. ' );
311267 }
312268
313269 break ;
0 commit comments