Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jan 8, 2021
1 parent 518e91b commit 79b142c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@

namespace OCA\Files_External\Tests\Controller;

use OC\User\User;
use OCA\Files_External\Controller\GlobalStoragesController;
use OCA\Files_External\Service\BackendService;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class GlobalStoragesControllerTest extends StoragesControllerTest {
protected function setUp(): void {
Expand All @@ -42,12 +46,18 @@ protected function setUp(): void {
$this->service->method('getVisibilityType')
->willReturn(BackendService::VISIBILITY_ADMIN);

$session = $this->createMock(IUserSession::class);
$session->method('getUser')
->willReturn(new User('test', null, $this->createMock(EventDispatcherInterface::class)));

$this->controller = new GlobalStoragesController(
'files_external',
$this->createMock(IRequest::class),
$this->createMock(IL10N::class),
$this->service,
$this->createMock(ILogger::class)
$this->createMock(ILogger::class),
$session,
$this->createMock(IGroupManager::class),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ public function testGetStorage() {
$response = $this->controller->show(1);

$this->assertEquals(Http::STATUS_OK, $response->getStatus());
$this->assertEquals($storageConfig, $response->getData());
$expected = $storageConfig->jsonSerialize();
$expected['can_edit'] = false;
$this->assertEquals($expected, $response->getData());
}

public function validateStorageProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@

namespace OCA\Files_External\Tests\Controller;

use OC\User\User;
use OCA\Files_External\Controller\UserStoragesController;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\BackendService;
use OCP\AppFramework\Http;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class UserStoragesControllerTest extends StoragesControllerTest {

Expand All @@ -52,13 +55,18 @@ protected function setUp(): void {
$this->service->method('getVisibilityType')
->willReturn(BackendService::VISIBILITY_PERSONAL);

$session = $this->createMock(IUserSession::class);
$session->method('getUser')
->willReturn(new User('test', null, $this->createMock(EventDispatcherInterface::class)));

$this->controller = new UserStoragesController(
'files_external',
$this->createMock(IRequest::class),
$this->createMock(IL10N::class),
$this->service,
$this->createMock(IUserSession::class),
$this->createMock(ILogger::class)
$this->createMock(ILogger::class),
$session,
$this->createMock(IGroupManager::class)
);
}

Expand Down

0 comments on commit 79b142c

Please sign in to comment.