66
77use GuzzleHttp \Psr7 \Response ;
88use PHPUnit \Framework \MockObject \MockObject ;
9- use ReflectionClass ;
10- use ReflectionException ;
119use Sysix \LexOffice \Api ;
1210use Sysix \LexOffice \PaginationClient ;
1311
@@ -16,44 +14,19 @@ class PaginationClientTest extends TestClient
1614 /**
1715 * @param Response[] $responses
1816 *
19- * @throws ReflectionException
20- *
21- * @return array{0: Api&MockObject, 1: PaginationClient&MockObject}
17+ * @return array{0: Api&MockObject, 1: PaginationClient}
2218 */
2319 public function createPaginationClientMockObject (array $ responses )
2420 {
2521 $ api = $ this ->createApiMultiMockObject ($ responses );
2622
27- $ stub = $ this
28- ->getMockBuilder (PaginationClient::class)
29- ->onlyMethods ([])
30- ->setConstructorArgs ([$ api ])
31- ->getMock ();
32-
33- $ this ->setProtectedProperty ($ stub , 'resource ' , 'resource ' );
23+ $ stub = new class ($ api ) extends PaginationClient {
24+ protected string $ resource = 'resource ' ;
25+ };
3426
3527 return [$ api , $ stub ];
3628 }
3729
38- /**
39- * Sets a protected property on a given object via reflection.
40- *
41- * @param object $object - instance in which protected value is being modified
42- * @param string $property - property on instance being modified
43- * @param mixed $value - new value of the property being modified
44- *
45- * @throws ReflectionException
46- *
47- * @see https://stackoverflow.com/a/37667018/7387397
48- */
49- public function setProtectedProperty (object $ object , string $ property , $ value ): void
50- {
51- $ reflection = new ReflectionClass ($ object );
52- $ reflection_property = $ reflection ->getProperty ($ property );
53- $ reflection_property ->setAccessible (true );
54- $ reflection_property ->setValue ($ object , $ value );
55- }
56-
5730 public function testGetAllSingle (): void
5831 {
5932 $ this ->expectDeprecationV1Warning ('getAll ' );
0 commit comments