Browse Source

fix(tests): Fix PHP warnings in tests

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/54905/head
Côme Chilliet 4 weeks ago
parent
commit
cba4f1b616
No known key found for this signature in database GPG Key ID: A3E2F658B28C760A
  1. 1
      apps/dav/tests/unit/DAV/Listener/UserEventsListenerTest.php
  2. 37
      apps/dav/tests/unit/Upload/UploadAutoMkcolPluginTest.php
  3. 6
      apps/files/tests/Controller/ViewControllerTest.php

1
apps/dav/tests/unit/DAV/Listener/UserEventsListenerTest.php

@ -34,6 +34,7 @@ class UserEventsListenerTest extends TestCase {
private ExampleContactService&MockObject $exampleContactService;
private ExampleEventService&MockObject $exampleEventService;
private LoggerInterface&MockObject $logger;
private IJobList&MockObject $jobList;
private UserEventsListener $userEventsListener;

37
apps/dav/tests/unit/Upload/UploadAutoMkcolPluginTest.php

@ -20,11 +20,29 @@ use Sabre\HTTP\ResponseInterface;
use Test\TestCase;
class UploadAutoMkcolPluginTest extends TestCase {
private Tree&MockObject $tree;
private RequestInterface&MockObject $request;
private ResponseInterface&MockObject $response;
private UploadAutoMkcolPlugin $plugin;
protected function setUp(): void {
parent::setUp();
$server = $this->createMock(Server::class);
$this->tree = $this->createMock(Tree::class);
$server->tree = $this->tree;
$this->plugin = new UploadAutoMkcolPlugin();
$this->request = $this->createMock(RequestInterface::class);
$this->response = $this->createMock(ResponseInterface::class);
$server->httpRequest = $this->request;
$server->httpResponse = $this->response;
$this->plugin->initialize($server);
}
public static function dataMissingHeaderShouldReturnTrue(): Generator {
yield 'missing X-NC-WebDAV-Auto-Mkcol header' => [null];
yield 'empty X-NC-WebDAV-Auto-Mkcol header' => [''];
@ -113,21 +131,4 @@ class UploadAutoMkcolPluginTest extends TestCase {
$return = $this->plugin->beforeMethod($this->request, $this->response);
self::assertTrue($return);
}
protected function setUp(): void {
parent::setUp();
$server = $this->createMock(Server::class);
$this->tree = $this->createMock(Tree::class);
$server->tree = $this->tree;
$this->plugin = new UploadAutoMkcolPlugin();
$this->request = $this->createMock(RequestInterface::class);
$this->response = $this->createMock(ResponseInterface::class);
$server->httpRequest = $this->request;
$server->httpResponse = $this->response;
$this->plugin->initialize($server);
}
}

6
apps/files/tests/Controller/ViewControllerTest.php

@ -308,6 +308,12 @@ class ViewControllerTest extends TestCase {
}
});
$this->config
->method('getUserValue')
->willReturnMap([
[$this->user->getUID(), 'files', 'files_sorting_configs', '{}', '{}'],
]);
$this->viewController->index('', '', null);
}
}
Loading…
Cancel
Save