|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc. |
|
6
|
|
|
* @license AGPL-3.0 |
|
7
|
|
|
* |
|
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
10
|
|
|
* as published by the Free Software Foundation. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU Affero General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
use OC\AvatarManager; |
|
22
|
|
|
use OCP\Files\IRootFolder; |
|
23
|
|
|
use OCP\IUserManager; |
|
24
|
|
|
|
|
25
|
|
|
class AvatarManagerTest extends \Test\TestCase { |
|
26
|
|
|
/** @var IRootFolder */ |
|
27
|
|
|
private $rootFolder; |
|
28
|
|
|
|
|
29
|
|
|
/** @var AvatarManager */ |
|
30
|
|
|
private $avatarManager; |
|
31
|
|
|
|
|
32
|
|
|
/** @var IUserManager */ |
|
33
|
|
|
private $userManager; |
|
34
|
|
|
|
|
35
|
|
|
public function setUp() { |
|
36
|
|
|
parent::setUp(); |
|
37
|
|
|
|
|
38
|
|
|
$this->rootFolder = $this->getMock('\OCP\Files\IRootFolder'); |
|
39
|
|
|
$this->userManager = $this->getMock('\OCP\IUserManager'); |
|
40
|
|
|
$l = $this->getMock('\OCP\IL10N'); |
|
41
|
|
|
$l->method('t')->will($this->returnArgument(0)); |
|
42
|
|
|
$this->avatarManager = new \OC\AvatarManager( |
|
43
|
|
|
$this->userManager, |
|
44
|
|
|
$this->rootFolder, |
|
45
|
|
|
$l);; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @expectedException Exception |
|
50
|
|
|
* @expectedExceptionMessage user does not exist |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testGetAvatarInvalidUser() { |
|
53
|
|
|
$this->avatarManager->getAvatar('invalidUser'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testGetAvatarValidUser() { |
|
57
|
|
|
$this->userManager->expects($this->once()) |
|
|
|
|
|
|
58
|
|
|
->method('userExists') |
|
59
|
|
|
->with('validUser') |
|
60
|
|
|
->willReturn(true); |
|
61
|
|
|
|
|
62
|
|
|
$folder = $this->getMock('\OCP\Files\Folder'); |
|
63
|
|
|
$this->rootFolder->expects($this->once()) |
|
|
|
|
|
|
64
|
|
|
->method('getUserFolder') |
|
65
|
|
|
->with('validUser') |
|
66
|
|
|
->willReturn($folder); |
|
67
|
|
|
|
|
68
|
|
|
$folder->expects($this->once()) |
|
69
|
|
|
->method('getParent') |
|
70
|
|
|
->will($this->returnSelf()); |
|
71
|
|
|
|
|
72
|
|
|
$this->avatarManager->getAvatar('validUser'); |
|
73
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.