| 1 |
lars |
1 |
<?php
|
|
|
2 |
// Call Net_LDAP2_EntryTest::main() if this source file is executed directly.
|
|
|
3 |
if (!defined("PHPUnit_MAIN_METHOD")) {
|
|
|
4 |
define("PHPUnit_MAIN_METHOD", "Net_LDAP2_EntryTest::main");
|
|
|
5 |
}
|
|
|
6 |
|
|
|
7 |
require_once "PHPUnit/Framework/TestCase.php";
|
|
|
8 |
require_once "PHPUnit/Framework/TestSuite.php";
|
|
|
9 |
|
|
|
10 |
require_once 'Net_LDAP2Test.php'; // for config methods
|
|
|
11 |
|
|
|
12 |
require_once 'Net/LDAP2/Entry.php';
|
|
|
13 |
require_once 'Net/LDAP2/Entry.php';
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* Test class for Net_LDAP2_Entry.
|
|
|
17 |
* Generated by PHPUnit_Util_Skeleton on 2007-10-09 at 10:33:12.
|
|
|
18 |
*/
|
|
|
19 |
class Net_LDAP2_EntryTest extends PHPUnit_Framework_TestCase {
|
|
|
20 |
/**
|
|
|
21 |
* Stores the LDAP configuration
|
|
|
22 |
*/
|
|
|
23 |
var $ldapcfg = false;
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Runs the test methods of this class.
|
|
|
27 |
*
|
|
|
28 |
* @access public
|
|
|
29 |
* @static
|
|
|
30 |
*/
|
|
|
31 |
public static function main() {
|
|
|
32 |
require_once "PHPUnit/TextUI/TestRunner.php";
|
|
|
33 |
|
|
|
34 |
$suite = new PHPUnit_Framework_TestSuite("Net_LDAP2_EntryTest");
|
|
|
35 |
$result = PHPUnit_TextUI_TestRunner::run($suite);
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Sets up the fixture, for example, open a network connection.
|
|
|
40 |
* This method is called before a test is executed.
|
|
|
41 |
*
|
|
|
42 |
* @access protected
|
|
|
43 |
*/
|
|
|
44 |
protected function setUp() {
|
|
|
45 |
$this->ldapcfg = $this->getTestConfig();
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Tears down the fixture, for example, close a network connection.
|
|
|
50 |
* This method is called after a test is executed.
|
|
|
51 |
*
|
|
|
52 |
* @access protected
|
|
|
53 |
*/
|
|
|
54 |
protected function tearDown() {
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* This checks if a valid LDAP testconfig is present and loads it.
|
|
|
59 |
*
|
|
|
60 |
* If so, it is loaded and returned as array. If not, false is returned.
|
|
|
61 |
*
|
|
|
62 |
* @return false|array
|
|
|
63 |
*/
|
|
|
64 |
public function getTestConfig() {
|
|
|
65 |
$config = false;
|
|
|
66 |
$file = dirname(__FILE__).'/ldapconfig.ini';
|
|
|
67 |
if (file_exists($file) && is_readable($file)) {
|
|
|
68 |
$config = parse_ini_file($file, true);
|
|
|
69 |
} else {
|
|
|
70 |
return false;
|
|
|
71 |
}
|
|
|
72 |
// validate ini
|
|
|
73 |
$v_error = $file.' is probably invalid. Did you quoted values correctly?';
|
|
|
74 |
$this->assertTrue(array_key_exists('global', $config), $v_error);
|
|
|
75 |
$this->assertTrue(array_key_exists('test', $config), $v_error);
|
|
|
76 |
$this->assertEquals(7, count($config['global']), $v_error);
|
|
|
77 |
$this->assertEquals(7, count($config['test']), $v_error);
|
|
|
78 |
|
|
|
79 |
// reformat things a bit, for convinience
|
|
|
80 |
$config['global']['server_binddn'] =
|
|
|
81 |
$config['global']['server_binddn'].','.$config['global']['server_base_dn'];
|
|
|
82 |
$config['test']['existing_attrmv'] = explode('|', $config['test']['existing_attrmv']);
|
|
|
83 |
return $config;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Establishes a working connection
|
|
|
88 |
*
|
|
|
89 |
* @return Net_LDAP2
|
|
|
90 |
*/
|
|
|
91 |
public function &connect() {
|
|
|
92 |
// Check extension
|
|
|
93 |
if (true !== Net_LDAP2::checkLDAPExtension()) {
|
|
|
94 |
$this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.');
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
// Simple working connect and privilegued bind
|
|
|
98 |
$lcfg = array(
|
|
|
99 |
'host' => $this->ldapcfg['global']['server_address'],
|
|
|
100 |
'port' => $this->ldapcfg['global']['server_port'],
|
|
|
101 |
'basedn' => $this->ldapcfg['global']['server_base_dn'],
|
|
|
102 |
'binddn' => $this->ldapcfg['global']['server_binddn'],
|
|
|
103 |
'bindpw' => $this->ldapcfg['global']['server_bindpw'],
|
|
|
104 |
'filter' => '(ou=*)',
|
|
|
105 |
);
|
|
|
106 |
$ldap = Net_LDAP2::connect($lcfg);
|
|
|
107 |
$this->assertType('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check credentials and host address. If those are correct, file a bug!');
|
|
|
108 |
return $ldap;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
/* ---------- TESTS ---------- */
|
|
|
112 |
|
|
|
113 |
/**
|
|
|
114 |
* @todo Implement testCreateFresh().
|
|
|
115 |
*/
|
|
|
116 |
public function testCreateFresh() {
|
|
|
117 |
// test failing creation
|
|
|
118 |
$t = Net_LDAP2_Entry::createFresh("cn=test", "I should be an array");
|
|
|
119 |
$this->assertTrue(Net_LDAP2::isError($t), 'Creating fresh entry succeeded but was supposed to fail!');
|
|
|
120 |
|
|
|
121 |
// test failing creation
|
|
|
122 |
$t = Net_LDAP2_Entry::createFresh("cn=test",
|
|
|
123 |
array(
|
|
|
124 |
'attr1' => 'single',
|
|
|
125 |
'attr2' => array('mv1', 'mv2')
|
|
|
126 |
)
|
|
|
127 |
);
|
|
|
128 |
$this->assertType('Net_LDAP2_Entry', $t, 'Creating fresh entry failed but was supposed to succeed!');
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
/**
|
|
|
132 |
* @todo Implement testCreateExisting().
|
|
|
133 |
*/
|
|
|
134 |
public function testCreateExisting() {
|
|
|
135 |
// Remove the following line when you implement this test.
|
|
|
136 |
$this->markTestIncomplete(
|
|
|
137 |
"This test has not been implemented yet."
|
|
|
138 |
);
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
/**
|
|
|
142 |
* @todo Implement testDn().
|
|
|
143 |
*/
|
|
|
144 |
public function testDn() {
|
|
|
145 |
// Remove the following line when you implement this test.
|
|
|
146 |
$this->markTestIncomplete(
|
|
|
147 |
"This test has not been implemented yet."
|
|
|
148 |
);
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
/**
|
|
|
152 |
* @todo Implement test_setAttributes().
|
|
|
153 |
*/
|
|
|
154 |
public function test_setAttributes() {
|
|
|
155 |
// Remove the following line when you implement this test.
|
|
|
156 |
$this->markTestIncomplete(
|
|
|
157 |
"This test has not been implemented yet."
|
|
|
158 |
);
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
/**
|
|
|
162 |
* @todo Implement testGetValues().
|
|
|
163 |
*/
|
|
|
164 |
public function testGetValues() {
|
|
|
165 |
// Remove the following line when you implement this test.
|
|
|
166 |
$this->markTestIncomplete(
|
|
|
167 |
"This test has not been implemented yet."
|
|
|
168 |
);
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
/**
|
|
|
172 |
* @todo Implement testGetValue().
|
|
|
173 |
*/
|
|
|
174 |
public function testGetValue() {
|
|
|
175 |
// Remove the following line when you implement this test.
|
|
|
176 |
$this->markTestIncomplete(
|
|
|
177 |
"This test has not been implemented yet."
|
|
|
178 |
);
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
/**
|
|
|
182 |
* @todo Implement testGet_value().
|
|
|
183 |
*/
|
|
|
184 |
public function testGet_value() {
|
|
|
185 |
// Remove the following line when you implement this test.
|
|
|
186 |
$this->markTestIncomplete(
|
|
|
187 |
"This test has not been implemented yet."
|
|
|
188 |
);
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
/**
|
|
|
192 |
* @todo Implement testAttributes().
|
|
|
193 |
*/
|
|
|
194 |
public function testAttributes() {
|
|
|
195 |
// Remove the following line when you implement this test.
|
|
|
196 |
$this->markTestIncomplete(
|
|
|
197 |
"This test has not been implemented yet."
|
|
|
198 |
);
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
/**
|
|
|
202 |
* @todo Implement testExists().
|
|
|
203 |
*/
|
|
|
204 |
public function testExists() {
|
|
|
205 |
// Remove the following line when you implement this test.
|
|
|
206 |
$this->markTestIncomplete(
|
|
|
207 |
"This test has not been implemented yet."
|
|
|
208 |
);
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
/**
|
|
|
212 |
* @todo Implement testAdd().
|
|
|
213 |
*/
|
|
|
214 |
public function testAdd() {
|
|
|
215 |
// Remove the following line when you implement this test.
|
|
|
216 |
$this->markTestIncomplete(
|
|
|
217 |
"This test has not been implemented yet."
|
|
|
218 |
);
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
/**
|
|
|
222 |
* @todo Implement testDelete().
|
|
|
223 |
*/
|
|
|
224 |
public function testDelete() {
|
|
|
225 |
// Remove the following line when you implement this test.
|
|
|
226 |
$this->markTestIncomplete(
|
|
|
227 |
"This test has not been implemented yet."
|
|
|
228 |
);
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
/**
|
|
|
232 |
* @todo Implement testReplace().
|
|
|
233 |
*/
|
|
|
234 |
public function testReplace() {
|
|
|
235 |
// Remove the following line when you implement this test.
|
|
|
236 |
$this->markTestIncomplete(
|
|
|
237 |
"This test has not been implemented yet."
|
|
|
238 |
);
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
/**
|
|
|
242 |
* @todo Implement testUpdate().
|
|
|
243 |
*/
|
|
|
244 |
public function testUpdate() {
|
|
|
245 |
// Remove the following line when you implement this test.
|
|
|
246 |
$this->markTestIncomplete(
|
|
|
247 |
"This test has not been implemented yet."
|
|
|
248 |
);
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
/**
|
|
|
252 |
* @todo Implement test_getAttrName().
|
|
|
253 |
*/
|
|
|
254 |
public function test_getAttrName() {
|
|
|
255 |
// Remove the following line when you implement this test.
|
|
|
256 |
$this->markTestIncomplete(
|
|
|
257 |
"This test has not been implemented yet."
|
|
|
258 |
);
|
|
|
259 |
}
|
|
|
260 |
|
|
|
261 |
/**
|
|
|
262 |
* @todo Implement testGetLDAP().
|
|
|
263 |
*/
|
|
|
264 |
public function testGetLDAP() {
|
|
|
265 |
// Remove the following line when you implement this test.
|
|
|
266 |
$this->markTestIncomplete(
|
|
|
267 |
"This test has not been implemented yet."
|
|
|
268 |
);
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
/**
|
|
|
272 |
* @todo Implement testSetLDAP().
|
|
|
273 |
*/
|
|
|
274 |
public function testSetLDAP() {
|
|
|
275 |
// Remove the following line when you implement this test.
|
|
|
276 |
$this->markTestIncomplete(
|
|
|
277 |
"This test has not been implemented yet."
|
|
|
278 |
);
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
/**
|
|
|
282 |
* @todo Implement testPreg_match().
|
|
|
283 |
*/
|
|
|
284 |
public function testPreg_match() {
|
|
|
285 |
// Remove the following line when you implement this test.
|
|
|
286 |
$this->markTestIncomplete(
|
|
|
287 |
"This test has not been implemented yet."
|
|
|
288 |
);
|
|
|
289 |
}
|
|
|
290 |
}
|
|
|
291 |
|
|
|
292 |
// Call Net_LDAP2_EntryTest::main() if this source file is executed directly.
|
|
|
293 |
if (PHPUnit_MAIN_METHOD == "Net_LDAP2_EntryTest::main") {
|
|
|
294 |
Net_LDAP2_EntryTest::main();
|
|
|
295 |
}
|
|
|
296 |
?>
|