Completed
Push — update-colorpicker-aba18e70 ( aba18e )
by Thomas
28:08
created

BackendCollectionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 7
Bugs 1 Features 1
Metric Value
wmc 3
c 7
b 1
f 1
lcom 1
cbo 1
dl 0
loc 85
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 54 1
A testFind() 0 6 1
A testBySubscriptionType() 0 3 1
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');
0 ignored issues
show
Unused Code introduced by
$this->backends[0] = $th...alendar\\Db\\Backend'); does not seem to be reachable.

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 or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

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.

Loading history...
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
}