1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ownCloud - Calendar App |
4
|
|
|
* |
5
|
|
|
* @author Georg Ehrke |
6
|
|
|
* @copyright 2014 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\Db; |
23
|
|
|
|
24
|
|
|
class BackendCollectionTest extends \PHPUnit_Framework_TestCase { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var \OCA\Calendar\Db\BackendCollection |
28
|
|
|
*/ |
29
|
|
|
private $backendCollection; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
private $backends = []; |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Initialize the calendar object we are going to test |
40
|
|
|
*/ |
41
|
|
|
protected function setup() { |
42
|
|
|
$this->markTestSkipped('must be revisited.'); |
43
|
|
|
return; |
44
|
|
|
|
45
|
|
|
$this->backends[0] = $this->getMock('\OCA\Calendar\Db\Backend'); |
|
|
|
|
46
|
|
|
$this->backends[0]->expects($this->any()) |
47
|
|
|
->method('getId') |
48
|
|
|
->will($this->returnValue('database123')); |
49
|
|
|
|
50
|
|
|
$calendarAPIs[0] = $this->getMock('\OCA\Calendar\ICalendarAPI'); |
51
|
|
|
$calendarAPIs[0]->expects($this->any()) |
52
|
|
|
->method('listAll') |
53
|
|
|
->will($this->returnValue(['abc', 'def'])); |
54
|
|
|
|
55
|
|
|
$this->backends[0]->expects($this->any()) |
56
|
|
|
->method('getCalendarAPI') |
57
|
|
|
->will($this->returnValue($calendarAPIs[0])); |
58
|
|
|
|
59
|
|
|
$this->backends[1] = $this->getMock('OCA\Calendar\Db\Backend'); |
60
|
|
|
$this->backends[1]->expects($this->any()) |
61
|
|
|
->method('getId') |
62
|
|
|
->will($this->returnValue('caldav456')); |
63
|
|
|
|
64
|
|
|
$calendarAPIs[1] = $this->getMock('\OCA\Calendar\ICalendarAPI'); |
65
|
|
|
$calendarAPIs[1]->expects($this->any()) |
66
|
|
|
->method('listAll') |
67
|
|
|
->will($this->returnValue(['ghi', 'jkl'])); |
68
|
|
|
|
69
|
|
|
$this->backends[1]->expects($this->any()) |
70
|
|
|
->method('getCalendarAPI') |
71
|
|
|
->will($this->returnValue($calendarAPIs[1])); |
72
|
|
|
|
73
|
|
|
$this->backends[2] = $this->getMock('OCA\Calendar\Db\Backend'); |
74
|
|
|
$this->backends[2]->expects($this->any()) |
75
|
|
|
->method('getId') |
76
|
|
|
->will($this->returnValue('webcal789')); |
77
|
|
|
|
78
|
|
|
$calendarAPIs[2] = $this->getMock('\OCA\Calendar\ICalendarAPI'); |
79
|
|
|
$calendarAPIs[2]->expects($this->any()) |
80
|
|
|
->method('listAll') |
81
|
|
|
->will($this->returnValue(['mno', 'pqr'])); |
82
|
|
|
|
83
|
|
|
$this->backends[2]->expects($this->any())->method('getCalendarAPI')->will($this->returnValue($calendarAPIs[2])); |
84
|
|
|
|
85
|
|
|
$this->backends[3] = $this->getMock('OCA\Calendar\Db\Backend'); |
86
|
|
|
$this->backends[3]->expects($this->any())->method('getId')->will($this->returnValue('sharing012')); |
87
|
|
|
|
88
|
|
|
$calendarAPIs[3] = $this->getMock('\OCA\Calendar\ICalendarAPI'); |
89
|
|
|
$calendarAPIs[3]->expects($this->any())->method('listAll')->will($this->returnValue(['stu', 'vwx'])); |
90
|
|
|
|
91
|
|
|
$this->backends[3]->expects($this->any())->method('getCalendarAPI')->will($this->returnValue($calendarAPIs[3])); |
92
|
|
|
|
93
|
|
|
$this->backendCollection = new BackendCollection(null, null, null, null); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
public function testFind() { |
98
|
|
|
$this->assertSame($this->backends[0], $this->backendCollection->find('database123')); |
99
|
|
|
$this->assertSame($this->backends[1], $this->backendCollection->find('caldav456')); |
100
|
|
|
$this->assertSame($this->backends[2], $this->backendCollection->find('webcal789')); |
101
|
|
|
$this->assertSame($this->backends[3], $this->backendCollection->find('sharing012')); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
public function testBySubscriptionType() { |
106
|
|
|
|
107
|
|
|
} |
108
|
|
|
} |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.