/
Base.php
110 lines (98 loc) · 2.44 KB
/
Base.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* Driver test base.
*
* PHP version 5
*
* @category Horde
* @package Turba
* @subpackage UnitTests
* @author Gunnar Wrobel <wrobel@pardus.de>
* @link http://www.horde.org/apps/turba
* @license http://www.horde.org/licenses/apache Apache-like
*/
/**
* Prepare the test setup.
*/
require_once __DIR__ . '/../../TestCase.php';
/**
* Driver test base.
*
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @category Horde
* @package Turba
* @subpackage UnitTests
* @author Gunnar Wrobel <wrobel@pardus.de>
* @link http://www.horde.org/apps/turba
* @license http://www.horde.org/licenses/apache Apache-like
*/
class Turba_Unit_Driver_Base extends Turba_TestCase
{
/**
* The test setup.
*
* @var Horde_Test_Setup
*/
static $setup;
/**
* @static Turba_Driver
*/
static $driver;
/**
* List of tasks added during the test.
*/
private $_added = array();
public static function setUpBeforeClass()
{
self::$setup = new Horde_Test_Setup();
self::createBasicTurbaSetup(self::$setup);
parent::setUpBeforeClass();
}
public static function tearDownAfterClass()
{
self::$driver = null;
self::tearDownBasicTurbaSetup();
self::tearDownShares();
parent::tearDownAfterClass();
}
public function setUp()
{
$error = self::$setup->getError();
if (!empty($error)) {
$this->markTestSkipped($error);
}
}
public function tearDown()
{
parent::tearDown();
foreach ($this->_added as $added) {
try {
self::$driver->delete($added);
} catch (Turba_Exception $e) {
}
}
}
private function _add($attributes)
{
$id = self::$driver->add($attributes);
$this->_added[] = $id;
return $id;
}
public function testAdd()
{
$id = $this->_add(array('lastname' => 'TEST'));
$contact = self::$driver->getObject($id);
$this->assertEquals('TEST', $contact->attributes['lastname']);
}
public function testNullSearch()
{
$this->assertInstanceOf(
'Turba_List',
self::$driver->search(array(), null, 'AND')
);
}
}