summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-07-12 14:30:39 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-12 17:50:06 +0200
commit999dc64c72ec8d5229acfc0e01803563c05eb4e7 (patch)
tree1b0c082a3089e6a13a61c80686da69393e3b1ea2 /apps/files
parente56a907dde1cad169b9ca18c30b7cf0ad16e273a (diff)
downloadnextcloud-server-999dc64c72ec8d5229acfc0e01803563c05eb4e7.tar.gz
nextcloud-server-999dc64c72ec8d5229acfc0e01803563c05eb4e7.zip
Fix tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/lib/Controller/ViewController.php28
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php23
2 files changed, 29 insertions, 22 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index ba90e6e1fa2..f240e04c721 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -28,6 +28,7 @@
namespace OCA\Files\Controller;
+use OCA\Files\Activity\Helper;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
@@ -68,19 +69,10 @@ class ViewController extends Controller {
protected $appManager;
/** @var IRootFolder */
protected $rootFolder;
+ /** @var Helper */
+ protected $activityHelper;
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IURLGenerator $urlGenerator
- * @param IL10N $l10n
- * @param IConfig $config
- * @param EventDispatcherInterface $eventDispatcherInterface
- * @param IUserSession $userSession
- * @param IAppManager $appManager
- * @param IRootFolder $rootFolder
- */
- public function __construct($appName,
+ public function __construct(string $appName,
IRequest $request,
IURLGenerator $urlGenerator,
IL10N $l10n,
@@ -88,7 +80,8 @@ class ViewController extends Controller {
EventDispatcherInterface $eventDispatcherInterface,
IUserSession $userSession,
IAppManager $appManager,
- IRootFolder $rootFolder
+ IRootFolder $rootFolder,
+ Helper $activityHelper
) {
parent::__construct($appName, $request);
$this->appName = $appName;
@@ -100,6 +93,7 @@ class ViewController extends Controller {
$this->userSession = $userSession;
$this->appManager = $appManager;
$this->rootFolder = $rootFolder;
+ $this->activityHelper = $activityHelper;
}
/**
@@ -162,18 +156,14 @@ class ViewController extends Controller {
$user = $this->userSession->getUser()->getUID();
- //Get Favorite-Folder
- $tagger = \OC::$server->getTagManager();
- $helper = new \OCA\Files\Activity\Helper($tagger);
-
try {
- $favElements = $helper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
+ $favElements = $this->activityHelper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
} catch (\RuntimeException $e) {
$favElements['folders'] = null;
}
$collapseClasses = '';
- if (sizeof($favElements['folders']) > 0) {
+ if (count($favElements['folders']) > 0) {
$collapseClasses = 'collapsible';
}
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index eae627fd6a4..67700ca7bc1 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -29,6 +29,7 @@
namespace OCA\Files\Tests\Controller;
+use OCA\Files\Activity\Helper;
use OCA\Files\Controller\ViewController;
use OCP\AppFramework\Http;
use OCP\Files\File;
@@ -71,6 +72,8 @@ class ViewControllerTest extends TestCase {
private $appManager;
/** @var IRootFolder|\PHPUnit_Framework_MockObject_MockObject */
private $rootFolder;
+ /** @var Helper|\PHPUnit_Framework_MockObject_MockObject */
+ private $activityHelper;
public function setUp() {
parent::setUp();
@@ -89,6 +92,7 @@ class ViewControllerTest extends TestCase {
->method('getUser')
->will($this->returnValue($this->user));
$this->rootFolder = $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock();
+ $this->activityHelper = $this->createMock(Helper::class);
$this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController')
->setConstructorArgs([
'files',
@@ -99,7 +103,8 @@ class ViewControllerTest extends TestCase {
$this->eventDispatcher,
$this->userSession,
$this->appManager,
- $this->rootFolder
+ $this->rootFolder,
+ $this->activityHelper,
])
->setMethods([
'getStorageInfo',
@@ -120,7 +125,7 @@ class ViewControllerTest extends TestCase {
'owner' => 'MyName',
'ownerDisplayName' => 'MyDisplayName',
]));
- $this->config->expects($this->exactly(3))
+ $this->config
->method('getUserValue')
->will($this->returnValueMap([
[$this->user->getUID(), 'files', 'file_sorting', 'name', 'name'],
@@ -138,7 +143,7 @@ class ViewControllerTest extends TestCase {
$nav->assign('usage', '123 B');
$nav->assign('quota', 100);
$nav->assign('total_space', '100 B');
- $nav->assign('webdavurl', '');
+ //$nav->assign('webdavurl', '');
$nav->assign('navigationItems', [
[
'id' => 'files',
@@ -172,6 +177,10 @@ class ViewControllerTest extends TestCase {
'icon' => '',
'type' => 'link',
'classes' => '',
+ 'sublist' => [],
+ 'draggableSublist' => false,
+ 'defaultExpandedState' => false,
+ 'enableMenuButton' => 0,
],
[
'id' => 'sharingin',
@@ -299,6 +308,14 @@ class ViewControllerTest extends TestCase {
$policy = new Http\ContentSecurityPolicy();
$policy->addAllowedFrameDomain('\'self\'');
$expected->setContentSecurityPolicy($policy);
+
+ $this->activityHelper->method('getFavoriteFilePaths')
+ ->with($this->user->getUID())
+ ->willReturn([
+ 'item' => [],
+ 'folders' => [],
+ ]);
+
$this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
}