aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-05-31 22:39:37 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2025-05-31 22:39:37 +0200
commit3a99b8891705b3820db6398b97e09bbf4e83e4bc (patch)
treee1c02d8c5fd1cdfec1426534afa2aff04d956e57
parent71156583271c094d21fef28032e38ab3854cb84a (diff)
downloadnextcloud-server-test/fix-files-sharing.tar.gz
nextcloud-server-test/fix-files-sharing.zip
test(files_sharing): adjust mocks of `Talk` classestest/fix-files-sharing
Classes need to exist to be mocked (reflection), thus unknown classes only can be mocked as `stdClass`. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 6275ff614e7..203e09e217e 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -1675,8 +1675,11 @@ class ShareAPIControllerTest extends TestCase {
->with('spreed')
->willReturn(true);
- $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
- ->onlyMethods(['canAccessShare'])
+ // This is not possible anymore with PHPUnit 10+
+ // as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
+ // $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
+ $helper = $this->getMockBuilder(\stdClass::class)
+ ->addMethods(['canAccessShare'])
->getMock();
$helper->method('canAccessShare')
->with($share, $this->currentUser)
@@ -2492,8 +2495,11 @@ class ShareAPIControllerTest extends TestCase {
->with('spreed')
->willReturn(true);
- $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
- ->onlyMethods(['createShare'])
+ // This is not possible anymore with PHPUnit 10+
+ // as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
+ // $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
+ $helper = $this->getMockBuilder(\stdClass::class)
+ ->addMethods(['createShare'])
->getMock();
$helper->method('createShare')
->with(
@@ -2598,7 +2604,10 @@ class ShareAPIControllerTest extends TestCase {
->with('spreed')
->willReturn(true);
- $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
+ // This is not possible anymore with PHPUnit 10+
+ // as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
+ // $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
+ $helper = $this->getMockBuilder(\stdClass::class)
->addMethods(['createShare'])
->getMock();
$helper->method('createShare')
@@ -5093,8 +5102,11 @@ class ShareAPIControllerTest extends TestCase {
->with('spreed')
->willReturn(true);
- $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
- ->onlyMethods(['formatShare', 'canAccessShare'])
+ // This is not possible anymore with PHPUnit 10+
+ // as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
+ // $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
+ $helper = $this->getMockBuilder(\stdClass::class)
+ ->addMethods(['formatShare', 'canAccessShare'])
->getMock();
$helper->method('formatShare')
->with($share)