adjust tests

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2021-01-08 16:14:44 +01:00 committed by backportbot[bot]
parent e0d85ed9a8
commit 6404627d0c
3 changed files with 24 additions and 4 deletions

View File

@ -26,11 +26,15 @@
namespace OCA\Files_External\Tests\Controller; namespace OCA\Files_External\Tests\Controller;
use OC\User\User;
use OCA\Files_External\Controller\GlobalStoragesController; use OCA\Files_External\Controller\GlobalStoragesController;
use OCA\Files_External\Service\BackendService; use OCA\Files_External\Service\BackendService;
use OCP\IGroupManager;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class GlobalStoragesControllerTest extends StoragesControllerTest { class GlobalStoragesControllerTest extends StoragesControllerTest {
protected function setUp(): void { protected function setUp(): void {
@ -42,12 +46,18 @@ class GlobalStoragesControllerTest extends StoragesControllerTest {
$this->service->method('getVisibilityType') $this->service->method('getVisibilityType')
->willReturn(BackendService::VISIBILITY_ADMIN); ->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( $this->controller = new GlobalStoragesController(
'files_external', 'files_external',
$this->createMock(IRequest::class), $this->createMock(IRequest::class),
$this->createMock(IL10N::class), $this->createMock(IL10N::class),
$this->service, $this->service,
$this->createMock(ILogger::class) $this->createMock(ILogger::class),
$session,
$this->createMock(IGroupManager::class),
); );
} }
} }

View File

@ -338,7 +338,9 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$response = $this->controller->show(1); $response = $this->controller->show(1);
$this->assertEquals(Http::STATUS_OK, $response->getStatus()); $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() { public function validateStorageProvider() {

View File

@ -27,14 +27,17 @@
namespace OCA\Files_External\Tests\Controller; namespace OCA\Files_External\Tests\Controller;
use OC\User\User;
use OCA\Files_External\Controller\UserStoragesController; use OCA\Files_External\Controller\UserStoragesController;
use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\BackendService; use OCA\Files_External\Service\BackendService;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\IGroupManager;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserSession; use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class UserStoragesControllerTest extends StoragesControllerTest { class UserStoragesControllerTest extends StoragesControllerTest {
@ -52,13 +55,18 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$this->service->method('getVisibilityType') $this->service->method('getVisibilityType')
->willReturn(BackendService::VISIBILITY_PERSONAL); ->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( $this->controller = new UserStoragesController(
'files_external', 'files_external',
$this->createMock(IRequest::class), $this->createMock(IRequest::class),
$this->createMock(IL10N::class), $this->createMock(IL10N::class),
$this->service, $this->service,
$this->createMock(IUserSession::class), $this->createMock(ILogger::class),
$this->createMock(ILogger::class) $session,
$this->createMock(IGroupManager::class)
); );
} }