richdocuments/tests/controller/documentcontrollertest.php

81 lines
2.0 KiB
PHP
Raw Normal View History

2014-10-29 15:39:10 +03:00
<?php
/**
2015-12-16 17:57:44 +03:00
* ownCloud - Richdocuments App
2014-10-29 15:39:10 +03:00
*
* @author Victor Dubiniuk
* @copyright 2014 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
2015-12-16 17:57:44 +03:00
namespace OCA\Richdocuments\Controller;
2014-10-29 15:39:10 +03:00
class DocumentControllerTest extends \PHPUnit_Framework_TestCase {
2015-12-16 17:57:44 +03:00
private $appName = 'richdocuments';
2014-10-29 15:39:10 +03:00
private $request;
private $l10n;
private $settings;
2016-03-08 10:51:49 -04:00
private $cache;
2016-03-08 18:35:44 -04:00
private $logger;
2014-11-05 01:39:23 +03:00
private $uid = 'jack_the_documents_tester';
private $password = 'password';
2014-10-29 15:39:10 +03:00
private $controller;
2016-03-08 10:51:49 -04:00
2014-10-29 15:39:10 +03:00
public function setUp(){
$this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock()
2015-12-16 18:31:08 +03:00
;
2014-10-29 15:39:10 +03:00
$this->settings = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock()
;
$this->l10n = $this->getMockBuilder('\OCP\IL10N')
->disableOriginalConstructor()
->getMock()
;
2016-03-08 18:35:44 -04:00
$this->cache = $this->getMockBuilder('\OCP\ICacheFactory')
->disableOriginalConstructor()
->getMock()
;
$this->logger = $this->getMockBuilder('\OCP\ILogger')
->disableOriginalConstructor()
->getMock()
;
2014-10-29 15:39:10 +03:00
$this->controller = new DocumentController(
$this->appName,
$this->request,
$this->settings,
$this->l10n,
2016-03-08 10:51:49 -04:00
$this->uid,
2016-03-08 18:35:44 -04:00
$this->cache,
$this->logger
2014-10-29 15:39:10 +03:00
);
2016-03-08 10:51:49 -04:00
2015-05-25 18:50:32 +03:00
$userManager = \OC::$server->getUserManager();
$userSession = \OC::$server->getUserSession();
if (!$userManager->userExists($this->uid)){
$userManager->createUser($this->uid, $this->password);
\OC::$server->getUserFolder($this->uid);
2014-11-05 01:39:23 +03:00
}
2015-05-25 18:50:32 +03:00
$userSession->login($this->uid, $this->password);
2014-11-05 01:39:23 +03:00
\OC_Util::setupFS();
2014-10-29 15:39:10 +03:00
}
2015-12-16 18:31:08 +03:00
/**
* @expectedException \OCP\Files\NotFoundException
*/
2014-10-29 15:39:10 +03:00
public function testRename(){
$result = array(
'status' => 'error',
'message' => (string) $this->l10n->t('You don\'t have permission to rename this document')
);
$this->request->post = array(
'fileId' => 500,
'name' => 'newname.ext'
);
$response = $this->controller->rename(500);
}
}