Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

strategy:
matrix:
php-versions: ["8.0", "8.1"]
php-versions: ["8.0", "8.1", "8.2"]
server-versions: ["stable27"]

services:
Expand Down
12 changes: 8 additions & 4 deletions tests/CurrentUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down Expand Up @@ -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())
Expand Down
10 changes: 10 additions & 0 deletions tests/Listener/SetUserDefaultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions tests/Listener/UserDeletedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class UserDeletedTest extends TestCase {
*/
private $listener;

/**
* @var IUser|MockObject
*/
private $user;

public const UID = 'myuser';

public function setUp(): void {
Expand Down
13 changes: 13 additions & 0 deletions tests/Mock/Request.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace OCA\Activity\Tests\Mock;

use OCP\IRequest;

// We need this as we need to mock ::$server
// which can not be accessed on PHP 8.2 due to deprecation of dynamic properties.
interface Request extends IRequest {
public function __get(string $prop): mixed;
}