Skip to content

Commit 3a99b88

Browse files
committed
test(files_sharing): adjust mocks of Talk classes
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>
1 parent 7115658 commit 3a99b88

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,8 +1675,11 @@ public function testCanAccessRoomShare(bool $expected, IShare $share, bool $help
16751675
->with('spreed')
16761676
->willReturn(true);
16771677

1678-
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
1679-
->onlyMethods(['canAccessShare'])
1678+
// This is not possible anymore with PHPUnit 10+
1679+
// as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
1680+
// $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
1681+
$helper = $this->getMockBuilder(\stdClass::class)
1682+
->addMethods(['canAccessShare'])
16801683
->getMock();
16811684
$helper->method('canAccessShare')
16821685
->with($share, $this->currentUser)
@@ -2492,8 +2495,11 @@ public function testCreateShareRoom(): void {
24922495
->with('spreed')
24932496
->willReturn(true);
24942497

2495-
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
2496-
->onlyMethods(['createShare'])
2498+
// This is not possible anymore with PHPUnit 10+
2499+
// as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
2500+
// $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
2501+
$helper = $this->getMockBuilder(\stdClass::class)
2502+
->addMethods(['createShare'])
24972503
->getMock();
24982504
$helper->method('createShare')
24992505
->with(
@@ -2598,7 +2604,10 @@ public function testCreateShareRoomHelperThrowException(): void {
25982604
->with('spreed')
25992605
->willReturn(true);
26002606

2601-
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
2607+
// This is not possible anymore with PHPUnit 10+
2608+
// as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
2609+
// $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
2610+
$helper = $this->getMockBuilder(\stdClass::class)
26022611
->addMethods(['createShare'])
26032612
->getMock();
26042613
$helper->method('createShare')
@@ -5093,8 +5102,11 @@ public function testFormatRoomShare(array $expects, IShare $share, bool $helperA
50935102
->with('spreed')
50945103
->willReturn(true);
50955104

5096-
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
5097-
->onlyMethods(['formatShare', 'canAccessShare'])
5105+
// This is not possible anymore with PHPUnit 10+
5106+
// as `setMethods` was removed and now real reflection is used, thus the class needs to exist.
5107+
// $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
5108+
$helper = $this->getMockBuilder(\stdClass::class)
5109+
->addMethods(['formatShare', 'canAccessShare'])
50985110
->getMock();
50995111
$helper->method('formatShare')
51005112
->with($share)

0 commit comments

Comments
 (0)