1616use ScaleUpStack \EasyObject \Tests \Resources \Magic \ClassForAbstractCallHandlerTesting ;
1717use ScaleUpStack \EasyObject \Tests \Resources \TestCase ;
1818use ScaleUpStack \Metadata \Factory ;
19+ use ScaleUpStack \Metadata \Metadata \ClassMetadata ;
1920use ScaleUpStack \Reflection \Reflection ;
2021
2122/**
@@ -28,6 +29,9 @@ final class AbstractCallHandlerTest extends TestCase
2829 */
2930 private $ callHandler ;
3031
32+ /**
33+ * @var ClassMetadata
34+ */
3135 private $ classMetadata ;
3236
3337 protected function setUp ()
@@ -51,9 +55,10 @@ public function provides_virtual_method_names_with_parameter_count() : array
5155 /**
5256 * @test
5357 * @dataProvider provides_virtual_method_names_with_parameter_count
54- * @covers ::checkForMethod()
58+ * @covers ::checkMethodsArgumentsCount()
59+ * @covers ::getMethodMetadata()
5560 */
56- public function it_checks_if_virtual_method_matches (
61+ public function it_checks_if_argument_count_of_virtual_method_matches (
5762 string $ methodName ,
5863 int $ expectedParameterCount ,
5964 bool $ expectedResult
@@ -63,7 +68,7 @@ public function it_checks_if_virtual_method_matches(
6368 // and a method name, and expected number of parameters both as provided via test parameters
6469
6570 // when checking for the method
66- $ result = Reflection::methodOfClass (AbstractCallHandler::class, 'checkForMethod ' )
71+ $ result = Reflection::methodOfClass (AbstractCallHandler::class, 'checkMethodsArgumentsCount ' )
6772 ->invoke (
6873 $ this ->callHandler ,
6974 $ methodName ,
@@ -100,7 +105,7 @@ public function it_returns_the_corresponding_property_name_to_a_method_name(
100105 )
101106 {
102107 // given a mocked AbstractCallHandler, and ClassMetadata of some object as provided in setUp()
103- // and a method name, a method prefix, and if the prefix is required
108+ // and a method name, a method prefix, and if the prefix is required as provided by the test's parameters
104109
105110 // when requesting the property name
106111 $ result = Reflection::methodOfClass (AbstractCallHandler::class, 'propertyName ' )
@@ -115,4 +120,34 @@ public function it_returns_the_corresponding_property_name_to_a_method_name(
115120 // then the result is as expected
116121 $ this ->assertSame ($ expectedPropertyResult , $ result );
117122 }
123+
124+ /**
125+ * @test
126+ * @covers ::setProperty()
127+ */
128+ public function it_sets_the_value_of_an_object_when_type_matches ()
129+ {
130+ // given a mocked AbstractCallHandler, and ClassMetadata of some object as provided in setUp(),
131+ // and some object, a property name, and a new value
132+ $ object = new ClassForAbstractCallHandlerTesting ();
133+ $ propertyName = 'someProperty ' ;
134+ $ newValue = 'newValue ' ;
135+ // and a method name, a method prefix, and if the prefix is required as provided by the test's parameters
136+
137+ // when requesting the property name
138+ Reflection::methodOfClass (AbstractCallHandler::class, 'setProperty ' )
139+ ->invoke (
140+ $ this ->callHandler ,
141+ $ object ,
142+ $ propertyName ,
143+ $ newValue ,
144+ $ this ->classMetadata ->propertyMetadata [$ propertyName ]
145+ );
146+
147+ // then the property of the object is set
148+ $ this ->assertSame (
149+ $ newValue ,
150+ Reflection::getPropertyValue ($ object , 'someProperty ' )
151+ );
152+ }
118153}
0 commit comments