DocumentControllerTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
c 4
b 0
f 0
lcom 1
cbo 1
dl 0
loc 59
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B setUp() 0 30 2
A testCreate() 0 7 1
A testRename() 0 9 1
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