Code Duplication    Length = 20-20 lines in 3 locations

tests/unit/controller/settingscontrollerTest.php 3 locations

@@ 94-113 (lines=20) @@
91
		$this->assertEquals(422, $actual->getStatus());
92
	}
93
94
	public function testSetViewWithConfigException() {
95
		$this->userSession->expects($this->once())
96
			->method('getUser')
97
			->will($this->returnValue($this->dummyUser));
98
99
		$this->dummyUser->expects($this->once())
100
			->method('getUID')
101
			->will($this->returnValue('user123'));
102
103
		$this->config->expects($this->once())
104
			->method('setUserValue')
105
			->with('user123', $this->appName, 'currentView', 'month')
106
			->will($this->throwException(new \Exception));
107
108
		$actual = $this->controller->setConfig('view', 'month');
109
110
		$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual);
111
		$this->assertEquals([], $actual->getData());
112
		$this->assertEquals(500, $actual->getStatus());
113
	}
114
115
	public function testGetView() {
116
		$this->userSession->expects($this->once())
@@ 115-134 (lines=20) @@
112
		$this->assertEquals(500, $actual->getStatus());
113
	}
114
115
	public function testGetView() {
116
		$this->userSession->expects($this->once())
117
			->method('getUser')
118
			->will($this->returnValue($this->dummyUser));
119
120
		$this->dummyUser->expects($this->once())
121
			->method('getUID')
122
			->will($this->returnValue('user123'));
123
124
		$this->config->expects($this->once())
125
			->method('getUserValue')
126
			->with('user123', $this->appName, 'currentView', 'month')
127
			->will($this->returnValue('agendaWeek'));
128
129
		$actual = $this->controller->getConfig('view');
130
131
		$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual);
132
		$this->assertEquals(['value' => 'agendaWeek'], $actual->getData());
133
		$this->assertEquals(200, $actual->getStatus());
134
	}
135
136
	public function testGetViewWithConfigException() {
137
		$this->userSession->expects($this->once())
@@ 136-155 (lines=20) @@
133
		$this->assertEquals(200, $actual->getStatus());
134
	}
135
136
	public function testGetViewWithConfigException() {
137
		$this->userSession->expects($this->once())
138
			->method('getUser')
139
			->will($this->returnValue($this->dummyUser));
140
141
		$this->dummyUser->expects($this->once())
142
			->method('getUID')
143
			->will($this->returnValue('user123'));
144
145
		$this->config->expects($this->once())
146
			->method('getUserValue')
147
			->with('user123', $this->appName, 'currentView', 'month')
148
			->will($this->throwException(new \Exception));
149
150
		$actual = $this->controller->getConfig('view');
151
152
		$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual);
153
		$this->assertEquals([], $actual->getData());
154
		$this->assertEquals(500, $actual->getStatus());
155
	}
156
157
	public function testGetNotExistingConfig() {
158
		$actual = $this->controller->getConfig('foo');