1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ownCloud - Documents App |
4
|
|
|
* |
5
|
|
|
* @author Victor Dubiniuk |
6
|
|
|
* @copyright 2014 Victor Dubiniuk [email protected] |
7
|
|
|
* |
8
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
9
|
|
|
* later. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace OCA\Documents\Controller; |
13
|
|
|
|
14
|
|
|
class DocumentControllerTest extends \PHPUnit_Framework_TestCase { |
15
|
|
|
private $appName = 'documents'; |
16
|
|
|
private $request; |
17
|
|
|
private $l10n; |
18
|
|
|
private $settings; |
19
|
|
|
private $uid = 'jack_the_documents_tester'; |
20
|
|
|
private $password = 'password'; |
21
|
|
|
private $controller; |
22
|
|
|
|
23
|
|
|
public function setUp(){ |
24
|
|
|
$this->request = $this->getMockBuilder('\OCP\IRequest') |
25
|
|
|
->disableOriginalConstructor() |
26
|
|
|
->getMock() |
27
|
|
|
; |
28
|
|
|
$this->settings = $this->getMockBuilder('\OCP\IConfig') |
29
|
|
|
->disableOriginalConstructor() |
30
|
|
|
->getMock() |
31
|
|
|
; |
32
|
|
|
$this->l10n = $this->getMockBuilder('\OCP\IL10N') |
33
|
|
|
->disableOriginalConstructor() |
34
|
|
|
->getMock() |
35
|
|
|
; |
36
|
|
|
$this->controller = new DocumentController( |
37
|
|
|
$this->appName, |
38
|
|
|
$this->request, |
39
|
|
|
$this->settings, |
40
|
|
|
$this->l10n, |
41
|
|
|
$this->uid |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
$userManager = \OC::$server->getUserManager(); |
45
|
|
|
$userSession = \OC::$server->getUserSession(); |
46
|
|
|
if (!$userManager->userExists($this->uid)){ |
47
|
|
|
$userManager->createUser($this->uid, $this->password); |
48
|
|
|
\OC::$server->getUserFolder($this->uid); |
49
|
|
|
} |
50
|
|
|
$userSession->login($this->uid, $this->password); |
51
|
|
|
\OC_Util::setupFS(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
public function testRename(){ |
56
|
|
|
|
57
|
|
|
$this->request->post = array( |
58
|
|
|
'fileId' => 1500, |
59
|
|
|
'name' => 'newname.ext' |
60
|
|
|
); |
61
|
|
|
$response = $this->controller->rename(1500); |
62
|
|
|
$this->assertEquals('error', $response['status']); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testCreate(){ |
66
|
|
|
$currentDir = getcwd(); |
67
|
|
|
chdir('../../../'); |
68
|
|
|
$response = $this->controller->create(); |
69
|
|
|
chdir($currentDir); |
70
|
|
|
$this->assertEquals('success', $response['status']); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|