55namespace Doctrine \Tests \Persistence ;
66
77use Closure ;
8- use Doctrine \Common \Proxy \Proxy as CommonProxy ;
98use Doctrine \Persistence \Proxy ;
109use Doctrine \Persistence \Reflection \RuntimeReflectionProperty ;
11- use LogicException ;
1210use PHPUnit \Framework \TestCase ;
1311
1412class DummyMock
@@ -46,7 +44,6 @@ public function testGetSetValue(string $name, string $value): void
4644 * @param class-string<RuntimeReflectionPropertyTestProxyMock> $proxyClass
4745 *
4846 * @testWith ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
49- * ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestCommonProxyMock"]
5047 * ["\\Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
5148 */
5249 public function testGetValueOnProxyProperty (string $ proxyClass ): void
@@ -66,47 +63,23 @@ public function testGetValueOnProxyProperty(string $proxyClass): void
6663 self ::assertNull ($ reflProperty ->getValue ($ mockProxy ));
6764 }
6865
69- /**
70- * @param class-string<RuntimeReflectionPropertyTestProxyMock> $proxyClass
71- *
72- * @testWith ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
73- * ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestCommonProxyMock"]
74- */
75- public function testSetValueOnProxyProperty (string $ proxyClass ): void
66+ public function testSetValueOnProxyProperty (): void
7667 {
7768 $ setCheckMock = $ this ->createMock (DummyMock::class);
7869 $ setCheckMock ->expects (self ::never ())->method ('callSet ' );
7970 $ initializer = static function () use ($ setCheckMock ): void {
8071 $ setCheckMock ->callSet ();
8172 };
8273
83- $ mockProxy = new $ proxyClass ($ initializer );
84-
85- $ reflProperty = new RuntimeReflectionProperty ($ proxyClass , 'checkedProperty ' );
74+ $ mockProxy = new RuntimeReflectionPropertyTestProxyMock ($ initializer );
75+ $ reflProperty = new RuntimeReflectionProperty (RuntimeReflectionPropertyTestProxyMock::class, 'checkedProperty ' );
8676
8777 $ reflProperty ->setValue ($ mockProxy , 'newValue ' );
8878 self ::assertSame ('newValue ' , $ mockProxy ->checkedProperty );
8979
9080 unset($ mockProxy ->checkedProperty );
9181 $ reflProperty ->setValue ($ mockProxy , 'otherNewValue ' );
9282 self ::assertSame ('otherNewValue ' , $ mockProxy ->checkedProperty );
93-
94- if (! $ mockProxy instanceof CommonProxy) {
95- return ;
96- }
97-
98- $ setCheckMock = $ this ->createMock (DummyMock::class);
99- $ setCheckMock ->expects (self ::once ())->method ('callSet ' );
100- $ initializer = static function () use ($ setCheckMock ): void {
101- $ setCheckMock ->callSet ();
102- };
103-
104- $ mockProxy ->__setInitializer ($ initializer );
105- $ mockProxy ->__setInitialized (true );
106-
107- unset($ mockProxy ->checkedProperty );
108- $ reflProperty ->setValue ($ mockProxy , 'againNewValue ' );
109- self ::assertSame ('againNewValue ' , $ mockProxy ->checkedProperty );
11083 }
11184}
11285
@@ -180,66 +153,6 @@ public function __isset(string $name): bool
180153 return isset ($ this ->checkedProperty );
181154 }
182155}
183- /**
184- * Mock that simulates proxy property lazy loading
185- *
186- * @implements CommonProxy<object>
187- */
188- class RuntimeReflectionPropertyTestCommonProxyMock extends RuntimeReflectionPropertyTestProxyMock implements CommonProxy
189- {
190- /** @param mixed $value */
191- public function __set (string $ name , $ value ): void
192- {
193- if ($ this ->initializer !== null ) {
194- ($ this ->initializer )();
195- }
196-
197- $ this ->checkedProperty = $ value ;
198- }
199-
200- /**
201- * {@inheritDoc}
202- */
203- public function __getInitializer ()
204- {
205- return $ this ->initializer ;
206- }
207-
208- /**
209- * {@inheritDoc}
210- */
211- public function __setInitializer (?Closure $ initializer = null )
212- {
213- $ this ->initializer = $ initializer ;
214- }
215-
216- /**
217- * {@inheritDoc}
218- *
219- * @return mixed[] Keys are the property names, and values are the default
220- * values for those properties.
221- * @phpstan-return array<string, mixed>
222- */
223- public function __getLazyProperties ()
224- {
225- return [];
226- }
227-
228- /**
229- * {@inheritDoc}
230- */
231- public function __setCloner (?Closure $ cloner = null )
232- {
233- }
234-
235- /**
236- * {@inheritDoc}
237- */
238- public function __getCloner ()
239- {
240- throw new LogicException ('Not implemented ' );
241- }
242- }
243156
244157class RuntimeReflectionPropertyTestClass
245158{
0 commit comments