Completed
Pull Request — master (#1276)
by Thomas
04:23
created

AutoConfigControllerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 *
6
 * ownCloud - Mail app
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 Lesser General Public
19
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
use Test\TestCase;
23
use OCA\Mail\Controller\AutoCompleteController;
24
25
class AutoConfigControllerTest extends TestCase {
26
27
	private $request;
28
	private $service;
29
	private $controller;
30
31
	protected function setUp() {
32
		parent::setUp();
33
34
		$this->request = $this->getMock('OCP\IRequest');
35
		$this->service = $this->getMockBuilder('OCA\Mail\Service\AutoCompletion\AutoCompleteService')
36
			->disableOriginalConstructor()
37
			->getMock();
38
		$this->controller = new AutoCompleteController('mail', $this->request,
39
			$this->service);
40
	}
41
42
	public function testAutoComplete() {
43
		$term = 'john d';
44
		$result = 'johne doe';
45
46
		$this->service->expects($this->once())
47
			->method('findMatches')
48
			->with($this->equalTo($term))
49
			->will($this->returnValue($result));
50
51
		$response = $this->controller->index($term);
52
53
		$this->assertEquals($result, $response);
54
	}
55
56
}
57