1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Calendar App |
4
|
|
|
* |
5
|
|
|
* @author Georg Ehrke |
6
|
|
|
* @copyright 2016 Georg Ehrke <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This library is free software; you can redistribute it and/or |
9
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
10
|
|
|
* License as published by the Free Software Foundation; either |
11
|
|
|
* version 3 of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* This library is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public |
19
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
namespace OCA\Calendar\Controller; |
23
|
|
|
|
24
|
|
|
class EmailControllerTest extends \PHPUnit_Framework_TestCase { |
25
|
|
|
|
26
|
|
|
private $appName; |
27
|
|
|
private $request; |
28
|
|
|
private $config; |
29
|
|
|
private $userSession; |
30
|
|
|
private $mailer; |
31
|
|
|
private $l10n; |
32
|
|
|
private $defaults; |
33
|
|
|
|
34
|
|
|
private $dummyUser; |
35
|
|
|
|
36
|
|
|
private $controller; |
37
|
|
|
|
38
|
|
|
public function setUp() { |
39
|
|
|
$this->appName = 'calendar'; |
40
|
|
|
$this->request = $this->getMockBuilder('\OCP\IRequest') |
41
|
|
|
->disableOriginalConstructor() |
42
|
|
|
->getMock(); |
43
|
|
|
$this->config = $this->getMockBuilder('\OCP\IConfig') |
44
|
|
|
->disableOriginalConstructor() |
45
|
|
|
->getMock(); |
46
|
|
|
$this->userSession = $this->getMockBuilder('\OCP\IUserSession') |
47
|
|
|
->disableOriginalConstructor() |
48
|
|
|
->getMock(); |
49
|
|
|
|
50
|
|
|
$this->dummyUser = $this->getMockBuilder('OCP\IUser') |
51
|
|
|
->disableOriginalConstructor() |
52
|
|
|
->getMock(); |
53
|
|
|
|
54
|
|
|
$this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer') |
55
|
|
|
->disableOriginalConstructor() |
56
|
|
|
->getMock(); |
57
|
|
|
|
58
|
|
|
$this->l10n = $this->getMockBuilder('OC\L10N\L10N') |
59
|
|
|
->disableOriginalConstructor() |
60
|
|
|
->getMock(); |
61
|
|
|
|
62
|
|
|
$this->defaults = $this->getMockBuilder('OCP\Defaults') |
63
|
|
|
->disableOriginalConstructor() |
64
|
|
|
->getMock(); |
65
|
|
|
|
66
|
|
|
$this->controller = new EmailController($this->appName, $this->request, |
67
|
|
|
$this->userSession, $this->config, $this->mailer, $this->l10n, $this->defaults); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @dataProvider indexEmailPublicLink |
72
|
|
|
*/ |
73
|
|
|
public function testEmailPublicLink($to, $url, $name) { |
74
|
|
|
|
75
|
|
|
$this->userSession->expects($this->exactly(1)) |
76
|
|
|
->method('getUser') |
77
|
|
|
->will($this->returnValue($this->dummyUser)); |
78
|
|
|
|
79
|
|
|
$actual = $this->controller->sendEmailPublicLink($to, $url, $name); |
80
|
|
|
|
81
|
|
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function indexEmailPublicLink() { |
86
|
|
|
return [ |
87
|
|
|
['[email protected]', 'myurl.tld', 'user123'], |
88
|
|
|
['testtesttld', 'myurl.tld', 'user123'], |
89
|
|
|
]; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|