Completed
Pull Request — master (#1638)
by Thomas
06:26
created

AutoConfigControllerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 *
6
 * Mail
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
use Test\TestCase;
22
use OCA\Mail\Controller\AutoCompleteController;
23
24
class AutoConfigControllerTest extends TestCase {
25
26
	private $request;
27
	private $service;
28
	private $controller;
29
30
	protected function setUp() {
31
		parent::setUp();
32
33
		$this->request = $this->getMock('OCP\IRequest');
34
		$this->service = $this->getMockBuilder('OCA\Mail\Service\AutoCompletion\AutoCompleteService')
35
			->disableOriginalConstructor()
36
			->getMock();
37
		$this->controller = new AutoCompleteController('mail', $this->request,
38
			$this->service);
39
	}
40
41
	public function testAutoComplete() {
42
		$term = 'john d';
43
		$result = 'johne doe';
44
45
		$this->service->expects($this->once())
46
			->method('findMatches')
47
			->with($this->equalTo($term))
48
			->will($this->returnValue($result));
49
50
		$response = $this->controller->index($term);
51
52
		$this->assertEquals($result, $response);
53
	}
54
55
}
56