/
TestBase.php
94 lines (81 loc) · 2.29 KB
/
TestBase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Copyright 2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2014 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mail_Autoconfig
* @subpackage UnitTests
*/
/**
* Base driver for Tests for the SRV Driver.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2014 Horde LLC
* @ignore
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mail_Autoconfig
* @subpackage UnitTests
*/
abstract class Horde_Mail_Autoconfig_Driver_TestBase
extends Horde_Test_Case
{
private $driver;
public function setUp()
{
$this->driver = $this->_getDriver();
}
abstract protected function _getDriver();
public function tearDown()
{
unset($this->driver);
}
/**
* @dataProvider provider
*/
public function testGetMsaConfig($domains)
{
if (!$domains) {
$this->markTestSkipped();
}
$res = $this->driver->msaSearch($domains, array(
'email' => new Horde_Mail_Rfc822_Address('test@example.com')
));
$this->assertNotFalse($res);
$this->assertNotEmpty($res);
foreach ($res as $val) {
$this->assertInstanceOf('Horde_Mail_Autoconfig_Server_Msa', $val);
}
}
/**
* @dataProvider provider
*/
public function testGetMailConfig($domains)
{
if (!$domains) {
$this->markTestSkipped();
}
$res = $this->driver->mailSearch($domains, array(
'email' => new Horde_Mail_Rfc822_Address('test@example.com')
));
$this->assertNotFalse($res);
$this->assertNotEmpty($res);
foreach ($res as $val) {
$this->assertInstanceOf('Horde_Mail_Autoconfig_Server', $val);
}
}
public function provider()
{
$config = self::getConfig('MAILAUTOCONFIG_TEST_CONFIG', __DIR__ . '/..');
if (!is_null($config) &&
!empty($config['mail_autoconfig']['domains'])) {
return $config['mail_autoconfig']['domains'];
}
return array(array(null));
}
}