@@ -647,6 +647,8 @@ public function test_print_login() {
647647 * Test the initiate_webdavclient function.
648648 */
649649 public function test_initiate_webdavclient () {
650+ global $ CFG ;
651+
650652 $ idwebdav = $ this ->get_endpoint_id ('webdav_endpoint ' );
651653 if (!empty ($ idwebdav )) {
652654 foreach ($ idwebdav as $ id ) {
@@ -655,12 +657,29 @@ public function test_initiate_webdavclient() {
655657 }
656658
657659 $ generator = $ this ->getDataGenerator ()->get_plugin_generator ('repository_owncloud ' );
658-
659660 $ generator ->test_create_single_endpoint ($ this ->issuer ->get ('id ' ), "webdav_endpoint " ,
660661 "https://www.default.test:8080/webdav/index.php " );
662+
663+ $ fakeaccesstoken = new stdClass ();
664+ $ fakeaccesstoken ->token = "fake access token " ;
665+ $ oauthmock = $ this ->createMock (\core \oauth2 \client::class);
666+ $ oauthmock ->expects ($ this ->once ())->method ('get_accesstoken ' )->will ($ this ->returnValue ($ fakeaccesstoken ));
667+ $ this ->set_private_property ($ oauthmock , 'client ' );
668+
661669 $ dav = phpunit_util::call_internal_method ($ this ->repo , "initiate_webdavclient " , [], 'repository_owncloud ' );
662670
663- $ port = $ this ->get_private_property ($ dav , '_port ' )->getValue ($ dav );
671+ // Verify that port is set correctly (private property).
672+ $ refclient = new ReflectionClass ($ dav );
673+ if ($ CFG ->branch >= 34 ) {
674+ // Class owncloud_client is only alias; get property from parent.
675+ // TODO Rewrite as soon as M 3.3 is unsupported.
676+ $ refclient = $ refclient ->getParentClass ();
677+ }
678+
679+ $ property = $ refclient ->getProperty ('_port ' );
680+ $ property ->setAccessible (true );
681+
682+ $ port = $ property ->getValue ($ dav );
664683
665684 $ this ->assertEquals ('8080 ' , $ port );
666685 }
@@ -672,21 +691,6 @@ public function test_supported_returntypes() {
672691 $ this ->assertEquals (FILE_INTERNAL | FILE_EXTERNAL | FILE_REFERENCE , $ this ->repo ->supported_returntypes ());
673692 }
674693
675- /**
676- * Get private property from any class
677- *
678- * @param string $refobject name of the class
679- * @param string $propertyname name of the private property
680- * @return ReflectionProperty the resulting reflection property.
681- */
682- protected function get_private_property ($ refobject , $ propertyname ) {
683- $ refclient = new ReflectionClass ($ refobject );
684- $ property = $ refclient ->getProperty ($ propertyname );
685- $ property ->setAccessible (true );
686-
687- return $ property ;
688- }
689-
690694 /**
691695 * Helper method, which inserts a given mock value into the repository_owncloud object.
692696 *
0 commit comments