Completed
Push — master ( 0cb710...8aa71f )
by Christoph
14:38
created

MozillaIspDbtest::queryData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 *
6
 * ownCloud - 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
22
namespace OCA\Mail\Tests\Service\Autoconfig;
23
24
use OCA\Mail\Service\AutoConfig\MozillaIspDb;
25
use PHPUnit_Framework_TestCase;
26
27
class MozillaIspDbtest extends PHPUnit_Framework_TestCase {
28
29
	private $mozillaIspDb;
30
31
	protected function setUp() {
32
		parent::setUp();
33
34
		$logger = $this->getMockBuilder('\OCA\Mail\Service\Logger')
35
			->disableOriginalConstructor()
36
			->getMock();
37
		$this->mozillaIspDb = new MozillaIspDb($logger);
38
	}
39
40
	public function queryData() {
41
		return [
42
		    ['gmail.com'],
43
		    ['outlook.com'],
44
		    ['yahoo.de'],
45
		];
46
	}
47
48
	/**
49
	 * @dataProvider queryData
50
	 *
51
	 * @param string $domain
52
	 */
53
	public function testQueryGmail($domain) {
54
		$result = $this->mozillaIspDb->query($domain);
55
56
		$this->assertContainsIspData($result);
57
	}
58
59
	private function assertContainsIspData($data) {
60
		$this->assertArrayHasKey('imap', $data);
61
		$this->assertTrue(count($data['imap']) >= 1, 'no isp imap data returned');
62
		$this->assertArrayHasKey('smtp', $data);
63
		$this->assertTrue(count($data['smtp']) >= 1, 'no isp smtp data returned');
64
	}
65
66
}
67