1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class LibCaldav_mock |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var Func_CalendarBackend_Ovi |
11
|
|
|
*/ |
12
|
|
|
private $oviBackend; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var Func_CalendarBackend_Caldav |
16
|
|
|
*/ |
17
|
|
|
private $caldavBackend; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var int |
22
|
|
|
*/ |
23
|
|
|
private $oviUser; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var int |
27
|
|
|
*/ |
28
|
|
|
private $caldavUser; |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var Func_CalendarBackend_Ovi |
33
|
|
|
*/ |
34
|
3 |
|
public function getOviBackend() |
35
|
|
|
{ |
36
|
3 |
|
if (!isset($this->oviBackend)) { |
37
|
1 |
|
$this->oviBackend = new Func_CalendarBackend_Ovi(); |
38
|
1 |
|
} |
39
|
|
|
|
40
|
3 |
|
return $this->oviBackend; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return Func_CalendarBackend_Caldav |
47
|
|
|
*/ |
48
|
9 |
|
public function getCaldavBackend() |
49
|
|
|
{ |
50
|
9 |
|
if (!isset($this->caldavBackend)) { |
51
|
1 |
|
$this->caldavBackend = new Func_CalendarBackend_Caldav(); |
52
|
1 |
|
} |
53
|
|
|
|
54
|
9 |
|
return $this->caldavBackend; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return int |
59
|
|
|
*/ |
60
|
3 |
|
public function getOviUser() |
61
|
|
|
{ |
62
|
3 |
|
if (!isset($this->oviUser)) { |
63
|
1 |
|
$this->oviUser = bab_addUser('ovi', 'ovi', '', '[email protected]', 'ovi', 'secret', 'secret', true, $error); |
64
|
1 |
|
} |
65
|
|
|
|
66
|
3 |
|
return $this->oviUser; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Create a user in ovidentia |
72
|
|
|
* and link to a caldav backend |
73
|
|
|
* |
74
|
|
|
* @return int |
75
|
|
|
*/ |
76
|
8 |
|
public function getCaldavUser() |
77
|
|
|
{ |
78
|
8 |
|
if (!isset($this->caldavUser)) { |
79
|
|
|
|
80
|
1 |
|
$this->caldavUser = false; |
|
|
|
|
81
|
|
|
|
82
|
1 |
|
$id_user = bab_addUser('caldav', 'caldav', '', '[email protected]', 'caldav', 'secret', 'secret', true, $error); |
83
|
|
|
|
84
|
1 |
|
if (!$id_user) { |
85
|
|
|
throw new Exception($error); |
86
|
|
|
} |
87
|
|
|
|
88
|
1 |
|
$backend = $this->getCaldavBackend(); |
89
|
|
|
|
90
|
1 |
|
bab_setPersonnalCalendarBackend($id_user, $backend); |
91
|
|
|
|
92
|
1 |
|
$backend->setUserIdentifier($id_user, 'caldav_login'); |
93
|
1 |
|
$backend->setUserPassword($id_user, ''); // radicale do not need password |
94
|
1 |
|
$backend->setServerId($id_user, 1); // default server ID from the mock/server.sql file |
95
|
|
|
|
96
|
1 |
|
$this->caldavUser = $id_user; |
97
|
1 |
|
} |
98
|
8 |
|
return $this->caldavUser; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
} |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.