From 66473121065b737f8f4c125a9cb7907d387b3401 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 16 Jan 2024 16:41:11 +0100 Subject: [PATCH] fix(tests): Remove deprecated syntax Signed-off-by: Ferdinand Thiessen --- tests/CurrentUserTest.php | 12 ++++++++---- tests/Listener/SetUserDefaultsTest.php | 10 ++++++++++ tests/Listener/UserDeletedTest.php | 5 +++++ tests/Mock/Request.php | 13 +++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 tests/Mock/Request.php diff --git a/tests/CurrentUserTest.php b/tests/CurrentUserTest.php index 7254ac592..3b6a4b6e1 100644 --- a/tests/CurrentUserTest.php +++ b/tests/CurrentUserTest.php @@ -22,13 +22,14 @@ namespace OCA\Activity\Tests; use OCA\Activity\CurrentUser; +use OCA\Activity\Tests\Mock\Request; use OCP\IRequest; use OCP\IUser; +use OCP\IUserSession; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IShare; -use PHPUnit\Framework\MockObject\MockObject; -use OCP\IUserSession; use OCP\Share\IManager; +use PHPUnit\Framework\MockObject\MockObject; /** * Class CurrentUserTest @@ -48,7 +49,7 @@ class CurrentUserTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->request = $this->createMock(IRequest::class); + $this->request = $this->createMock(Request::class); $this->userSession = $this->createMock(IUserSession::class); $this->shareManager = $this->createMock(IManager::class); } @@ -183,7 +184,10 @@ public function dataGetCloudIDFromToken(): array { public function testGetCloudIDFromToken(array $server, $share, ?string $expected): void { $instance = $this->getInstance(); - $this->request->server = $server; + $this->request->method('__get')->willReturnCallback(fn (string $prop) => match ($prop) { + 'server' => $server, + default => null, + }); if ($share === null) { $this->shareManager->expects($this->never()) diff --git a/tests/Listener/SetUserDefaultsTest.php b/tests/Listener/SetUserDefaultsTest.php index 4a4ec2c84..8f086b454 100644 --- a/tests/Listener/SetUserDefaultsTest.php +++ b/tests/Listener/SetUserDefaultsTest.php @@ -42,6 +42,16 @@ class SetUserDefaultsTest extends TestCase { */ private $listener; + /** + * @var IUser|MockObject + */ + private $user; + + /** + * @var PostLoginEvent + */ + private $event; + public const UID = 'myuser'; public function setUp(): void { diff --git a/tests/Listener/UserDeletedTest.php b/tests/Listener/UserDeletedTest.php index b2a364ffd..693a982ea 100644 --- a/tests/Listener/UserDeletedTest.php +++ b/tests/Listener/UserDeletedTest.php @@ -53,6 +53,11 @@ class UserDeletedTest extends TestCase { */ private $listener; + /** + * @var IUser|MockObject + */ + private $user; + public const UID = 'myuser'; public function setUp(): void { diff --git a/tests/Mock/Request.php b/tests/Mock/Request.php new file mode 100644 index 000000000..02e8a0adc --- /dev/null +++ b/tests/Mock/Request.php @@ -0,0 +1,13 @@ +