PageRenderTime 52ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Zend/Ldap/Node/OfflineTest.php

https://bitbucket.org/ksekar/campus
PHP | 666 lines | 529 code | 78 blank | 59 comment | 0 complexity | f6d5ba0cf5b43f335c227d48e3df22c3 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Ldap
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: OfflineTest.php 24594 2012-01-05 21:27:01Z matthew $
  21. */
  22. /**
  23. * Zend_Ldap_TestCase
  24. */
  25. require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestCase.php';
  26. /**
  27. * Zend_Ldap_Node
  28. */
  29. require_once 'Zend/Ldap/Node.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Ldap
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Ldap
  37. * @group Zend_Ldap_Node
  38. */
  39. class Zend_Ldap_Node_OfflineTest extends Zend_Ldap_TestCase
  40. {
  41. protected function _assertLocalDateTimeString($timestamp, $value)
  42. {
  43. $this->assertEquals(date('YmdHisO', $timestamp), $value);
  44. }
  45. protected function _assertUtcDateTimeString($localTimestamp, $value)
  46. {
  47. $localOffset = date('Z', $localTimestamp);
  48. $utcTimestamp = $localTimestamp - $localOffset;
  49. $this->assertEquals(date('YmdHis', $utcTimestamp) . 'Z', $value);
  50. }
  51. public function testCreateFromArrayStringDn()
  52. {
  53. $data=$this->_createTestArrayData();
  54. $node=Zend_Ldap_Node::fromArray($data);
  55. $this->assertType('Zend_Ldap_Node', $node);
  56. $this->assertFalse($node->isAttached());
  57. $this->assertFalse($node->willBeDeleted());
  58. $this->assertFalse($node->willBeMoved());
  59. $this->assertTrue($node->isNew());
  60. }
  61. public function testCreateFromArrayObjectDn()
  62. {
  63. $data=$this->_createTestArrayData();
  64. $data['dn']=Zend_Ldap_Dn::fromString($data['dn']);
  65. $node=Zend_Ldap_Node::fromArray($data);
  66. $this->assertType('Zend_Ldap_Node', $node);
  67. $this->assertFalse($node->isAttached());
  68. }
  69. /**
  70. * @expectedException Zend_Ldap_Exception
  71. */
  72. public function testCreateFromArrayMissingDn()
  73. {
  74. $data=$this->_createTestArrayData();
  75. unset($data['dn']);
  76. $node=Zend_Ldap_Node::fromArray($data);
  77. }
  78. /**
  79. * @expectedException Zend_Ldap_Exception
  80. */
  81. public function testCreateFromArrayIllegalDn()
  82. {
  83. $data=$this->_createTestArrayData();
  84. $data['dn']=5;
  85. $node=Zend_Ldap_Node::fromArray($data);
  86. }
  87. /**
  88. * @expectedException Zend_Ldap_Exception
  89. */
  90. public function testCreateFromArrayMalformedDn()
  91. {
  92. $data=$this->_createTestArrayData();
  93. $data['dn']='name1,cn=name2,dc=example,dc=org';
  94. $node=Zend_Ldap_Node::fromArray($data);
  95. }
  96. public function testCreateFromArrayAndEnsureRdnValues()
  97. {
  98. $data=$this->_createTestArrayData();
  99. $data['dn']=Zend_Ldap_Dn::fromString($data['dn']);
  100. $node=Zend_Ldap_Node::fromArray($data);
  101. $this->assertType('Zend_Ldap_Node', $node);
  102. $this->assertFalse($node->isAttached());
  103. unset($data['dn']);
  104. $this->assertEquals($data, $node->getData());
  105. }
  106. public function testGetDnString()
  107. {
  108. $data=$this->_createTestArrayData();
  109. $node=Zend_Ldap_Node::fromArray($data);
  110. $this->assertEquals($data['dn'], $node->getDnString());
  111. }
  112. public function testGetDnArray()
  113. {
  114. $data=$this->_createTestArrayData();
  115. $node=Zend_Ldap_Node::fromArray($data);
  116. $exA=Zend_Ldap_Dn::explodeDn($data['dn']);
  117. $this->assertEquals($exA, $node->getDnArray());
  118. }
  119. public function testGetDnObject()
  120. {
  121. $data=$this->_createTestArrayData();
  122. $node=Zend_Ldap_Node::fromArray($data);
  123. $compareDn=Zend_Ldap_Dn::fromString('cn=name,dc=example,dc=org');
  124. $this->assertEquals($compareDn, $node->getDn());
  125. $this->assertNotSame($node->getDn(), $node->getDn());
  126. }
  127. public function testGetRdnString()
  128. {
  129. $node=$this->_createTestNode();
  130. $this->assertEquals('cn=name', $node->getRdnString());
  131. }
  132. public function testGetRdnArray()
  133. {
  134. $node=$this->_createTestNode();
  135. $this->assertEquals(array('cn' => 'name'), $node->getRdnArray());
  136. }
  137. public function testSerialize()
  138. {
  139. $node=$this->_createTestNode();
  140. $sdata=serialize($node);
  141. $newObject=unserialize($sdata);
  142. $this->assertEquals($node, $newObject);
  143. }
  144. public function testToString()
  145. {
  146. $node=$this->_createTestNode();
  147. $this->assertEquals('cn=name,dc=example,dc=org', $node->toString());
  148. $this->assertEquals('cn=name,dc=example,dc=org', (string)$node);
  149. }
  150. public function testToArray()
  151. {
  152. $node=$this->_createTestNode();
  153. $this->assertEquals(array(
  154. 'dn' => 'cn=name,dc=example,dc=org',
  155. 'cn' => array('name'),
  156. 'host' => array('a', 'b', 'c'),
  157. 'empty' => array(),
  158. 'boolean' => array(true, false),
  159. 'objectclass' => array('account', 'top'),
  160. ), $node->toArray());
  161. }
  162. public function testToJson()
  163. {
  164. $node=$this->_createTestNode();
  165. $this->assertEquals('{"dn":"cn=name,dc=example,dc=org",' .
  166. '"boolean":[true,false],' .
  167. '"cn":["name"],' .
  168. '"empty":[],' .
  169. '"host":["a","b","c"],' .
  170. '"objectclass":["account","top"]}', $node->toJson());
  171. }
  172. public function testGetData()
  173. {
  174. $data=$this->_createTestArrayData();
  175. $node=Zend_Ldap_Node::fromArray($data);
  176. ksort($data, SORT_STRING);
  177. unset($data['dn']);
  178. $this->assertEquals($data, $node->getData());
  179. }
  180. public function testGetObjectClass()
  181. {
  182. $node=$this->_createTestNode();
  183. $this->assertEquals(array('account', 'top'), $node->getObjectClass());
  184. }
  185. public function testModifyObjectClass()
  186. {
  187. $node=$this->_createTestNode();
  188. $this->assertEquals(array('account', 'top'), $node->getObjectClass());
  189. $node->setObjectClass('domain');
  190. $this->assertEquals(array('domain'), $node->getObjectClass());
  191. $node->setObjectClass(array('account', 'top'));
  192. $this->assertEquals(array('account', 'top'), $node->getObjectClass());
  193. $node->appendObjectClass('domain');
  194. $this->assertEquals(array('account', 'top', 'domain'), $node->getObjectClass());
  195. $node->setObjectClass('domain');
  196. $node->appendObjectClass(array('account', 'top'));
  197. $this->assertEquals(array('domain', 'account', 'top'), $node->getObjectClass());
  198. }
  199. public function testGetAttributes()
  200. {
  201. $node=$this->_createTestNode();
  202. $expected=array(
  203. 'boolean' => array(true, false),
  204. 'cn' => array('name'),
  205. 'empty' => array(),
  206. 'host' => array('a', 'b', 'c'),
  207. 'objectclass' => array('account', 'top'),
  208. );
  209. $this->assertEquals($expected, $node->getAttributes());
  210. $this->assertFalse($node->willBeDeleted());
  211. $this->assertFalse($node->willBeMoved());
  212. $this->assertFalse($node->isNew());
  213. $node->delete();
  214. $this->assertTrue($node->willBeDeleted());
  215. }
  216. public function testAppendToAttributeFirstTime()
  217. {
  218. $node=$this->_createTestNode();
  219. $node->appendToAttribute('host', 'newHost');
  220. $ts=mktime(12, 30, 30, 6, 25, 2008);
  221. $node->appendToDateTimeAttribute('objectClass', $ts);
  222. $this->assertEquals('newHost', $node->host[3]);
  223. $this->assertEquals($ts, $node->getDateTimeAttribute('objectClass', 2));
  224. }
  225. public function testExistsAttribute()
  226. {
  227. $node=$this->_createTestNode();
  228. $this->assertFalse($node->existsAttribute('nonExistant'));
  229. $this->assertFalse($node->existsAttribute('empty', false));
  230. $this->assertTrue($node->existsAttribute('empty', true));
  231. $node->newEmpty=null;
  232. $this->assertFalse($node->existsAttribute('newEmpty', false));
  233. $this->assertTrue($node->existsAttribute('newEmpty', true));
  234. $node->empty='string';
  235. $this->assertTrue($node->existsAttribute('empty', false));
  236. $this->assertTrue($node->existsAttribute('empty', true));
  237. $node->deleteAttribute('empty');
  238. $this->assertFalse($node->existsAttribute('empty', false));
  239. $this->assertTrue($node->existsAttribute('empty', true));
  240. }
  241. public function testGetSetAndDeleteMethods()
  242. {
  243. $node=$this->_createTestNode();
  244. $node->setAttribute('key', 'value1');
  245. $this->assertEquals('value1', $node->getAttribute('key', 0));
  246. $node->appendToAttribute('key', 'value2');
  247. $this->assertEquals('value1', $node->getAttribute('key', 0));
  248. $this->assertEquals('value2', $node->getAttribute('key', 1));
  249. $this->assertTrue($node->existsAttribute('key', true));
  250. $this->assertTrue($node->existsAttribute('key', false));
  251. $node->deleteAttribute('key');
  252. $this->assertEquals(0, count($node->getAttribute('key')));
  253. $this->assertTrue($node->existsAttribute('key', true));
  254. $this->assertFalse($node->existsAttribute('key', false));
  255. $ts=mktime(12, 30, 30, 6, 25, 2008);
  256. $node->setDateTimeAttribute('key', $ts, false);
  257. $this->_assertLocalDateTimeString($ts, $node->getAttribute('key', 0));
  258. $this->assertEquals($ts, $node->getDateTimeAttribute('key', 0));
  259. $node->appendToDateTimeAttribute('key', $ts, true);
  260. $this->_assertLocalDateTimeString($ts, $node->getAttribute('key', 0));
  261. $this->assertEquals($ts, $node->getDateTimeAttribute('key', 0));
  262. $this->_assertUtcDateTimeString($ts, $node->getAttribute('key', 1));
  263. $this->assertEquals($ts, $node->getDateTimeAttribute('key', 1));
  264. $this->assertTrue($node->existsAttribute('key', true));
  265. $this->assertTrue($node->existsAttribute('key', false));
  266. $node->deleteAttribute('key');
  267. $this->assertEquals(0, count($node->getAttribute('key')));
  268. $this->assertTrue($node->existsAttribute('key', true));
  269. $this->assertFalse($node->existsAttribute('key', false));
  270. $node->setPasswordAttribute('pa$$w0rd', Zend_Ldap_Attribute::PASSWORD_HASH_MD5);
  271. $this->assertEquals('{MD5}bJuLJ96h3bhF+WqiVnxnVA==', $node->getAttribute('userPassword', 0));
  272. $this->assertTrue($node->existsAttribute('userPassword', true));
  273. $this->assertTrue($node->existsAttribute('userPassword', false));
  274. $node->deleteAttribute('userPassword');
  275. $this->assertEquals(0, count($node->getAttribute('userPassword')));
  276. $this->assertTrue($node->existsAttribute('userPassword', true));
  277. $this->assertFalse($node->existsAttribute('userPassword', false));
  278. }
  279. public function testOverloading()
  280. {
  281. $node=$this->_createTestNode();
  282. $node->key='value1';
  283. $this->assertEquals('value1', $node->key[0]);
  284. $this->assertTrue(isset($node->key));
  285. unset($node->key);
  286. $this->assertEquals(0, count($node->key));
  287. $this->assertFalse(isset($node->key));
  288. }
  289. /**
  290. * @expectedException Zend_Ldap_Exception
  291. */
  292. public function testIllegalAttributeAccessRdnAttributeSet()
  293. {
  294. $node=$this->_createTestNode();
  295. $node->cn='test';
  296. }
  297. /**
  298. * @expectedException Zend_Ldap_Exception
  299. */
  300. public function testIllegalAttributeAccessDnSet()
  301. {
  302. $node=$this->_createTestNode();
  303. $node->dn='test';
  304. }
  305. public function testAttributeAccessDnGet()
  306. {
  307. $node=$this->_createTestNode();
  308. $this->assertType('string', $node->dn);
  309. $this->assertEquals($node->getDn()->toString(), $node->dn);
  310. }
  311. public function testArrayAccess()
  312. {
  313. $node=$this->_createTestNode();
  314. $node['key']='value1';
  315. $this->assertEquals('value1', $node['key'][0]);
  316. $this->assertTrue(isset($node['key']));
  317. unset($node['key']);
  318. $this->assertEquals(0, count($node['key']));
  319. $this->assertFalse(isset($node['key']));
  320. }
  321. public function testCreateEmptyNode()
  322. {
  323. $dn='cn=name,dc=example,dc=org';
  324. $objectClass=array('account', 'test', 'inetOrgPerson');
  325. $node=Zend_Ldap_Node::create($dn, $objectClass);
  326. $this->assertEquals($dn, $node->getDnString());
  327. $this->assertEquals('cn=name', $node->getRdnString());
  328. $this->assertEquals('name', $node->cn[0]);
  329. $this->assertEquals($objectClass, $node->objectClass);
  330. $this->assertFalse($node->willBeDeleted());
  331. $this->assertFalse($node->willBeMoved());
  332. $this->assertTrue($node->isNew());
  333. $node->delete();
  334. $this->assertTrue($node->willBeDeleted());
  335. }
  336. public function testGetChangedData()
  337. {
  338. $node=$this->_createTestNode();
  339. $node->host=array('d');
  340. $node->empty='not Empty';
  341. unset($node->objectClass);
  342. $changedData=$node->getChangedData();
  343. $this->assertEquals(array('d'), $changedData['host']);
  344. $this->assertEquals(array('not Empty'), $changedData['empty']);
  345. $this->assertEquals(array(), $changedData['objectclass']);
  346. }
  347. public function testDeleteUnusedAttribute()
  348. {
  349. $node=$this->_createTestNode();
  350. $node->deleteAttribute('nonexistant');
  351. $changedData=$node->getChangedData();
  352. $this->assertArrayNotHasKey('nonexistant', $changedData);
  353. }
  354. public function testRenameNodeString()
  355. {
  356. $data=$this->_createTestArrayData();
  357. $node=Zend_Ldap_Node::fromArray($data);
  358. $newDnString='cn=test+ou=Lab+uid=tester,cn=name,dc=example,dc=org';
  359. $node->setDn($newDnString);
  360. $this->assertEquals($data['dn'], $node->getCurrentDn()->toString());
  361. $this->assertEquals($newDnString, $node->getDn()->toString());
  362. $this->assertEquals(array('test'), $node->cn);
  363. $this->assertEquals(array('tester'), $node->uid);
  364. $this->assertEquals(array('Lab'), $node->ou);
  365. $this->assertFalse($node->willBeDeleted());
  366. $this->assertFalse($node->willBeMoved());
  367. $this->assertTrue($node->isNew());
  368. }
  369. public function testRenameNodeArray()
  370. {
  371. $data=$this->_createTestArrayData();
  372. $node=Zend_Ldap_Node::fromArray($data);
  373. $newDnArray=array(
  374. array('uid' => 'tester'),
  375. array('dc' => 'example'),
  376. array('dc' => 'org'));
  377. $node->setDn($newDnArray);
  378. $this->assertEquals($data['dn'], $node->getCurrentDn()->toString());
  379. $this->assertEquals($newDnArray, $node->getDn()->toArray());
  380. $this->assertEquals(array('name'), $node->cn);
  381. }
  382. public function testRenameNodeDnObject()
  383. {
  384. $data=$this->_createTestArrayData();
  385. $node=Zend_Ldap_Node::fromArray($data);
  386. $newDn=Zend_Ldap_Dn::fromString('cn=test+ou=Lab+uid=tester,cn=name,dc=example,dc=org');
  387. $node->setDn($newDn);
  388. $this->assertEquals($data['dn'], $node->getCurrentDn()->toString());
  389. $this->assertEquals($newDn, $node->getDn());
  390. $this->assertEquals(array('test'), $node->cn);
  391. $this->assertEquals(array('tester'), $node->uid);
  392. $this->assertEquals(array('Lab'), $node->ou);
  393. }
  394. public function testRenameNodeFromDataSource()
  395. {
  396. $node=$this->_createTestNode();
  397. $newDnString='cn=test+ou=Lab+uid=tester,cn=name,dc=example,dc=org';
  398. $node->rename($newDnString);
  399. $this->assertFalse($node->willBeDeleted());
  400. $this->assertTrue($node->willBeMoved());
  401. $this->assertFalse($node->isNew());
  402. }
  403. public function testDnObjectCloning()
  404. {
  405. $node1=$this->_createTestNode();
  406. $dn1=Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org');
  407. $node1->setDn($dn1);
  408. $dn1->prepend(array('cn' => 'name'));
  409. $this->assertNotEquals($dn1->toString(), $node1->getDn()->toString());
  410. $dn2=Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org');
  411. $node2=Zend_Ldap_Node::create($dn2);
  412. $dn2->prepend(array('cn' => 'name'));
  413. $this->assertNotEquals($dn2->toString(), $node2->getDn()->toString());
  414. $dn3=Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org');
  415. $node3=Zend_Ldap_Node::fromArray(array(
  416. 'dn' => $dn3,
  417. 'ou' => 'Test'), false);
  418. $dn3->prepend(array('cn' => 'name'));
  419. $this->assertNotEquals($dn3->toString(), $node3->getDn()->toString());
  420. }
  421. public function testGetChanges()
  422. {
  423. $node=$this->_createTestNode();
  424. $node->host=array('d');
  425. $node->empty='not Empty';
  426. unset($node->boolean);
  427. $changes=$node->getChanges();
  428. $this->assertEquals(array(
  429. 'add' => array(
  430. 'empty' => array('not Empty')
  431. ),
  432. 'delete' => array(
  433. 'boolean' => array()
  434. ),
  435. 'replace' => array(
  436. 'host' => array('d')
  437. )
  438. ), $changes);
  439. $node=Zend_Ldap_Node::create('uid=test,dc=example,dc=org', array('account'));
  440. $node->host='host';
  441. unset($node->cn);
  442. unset($node['sn']);
  443. $node['givenName']='givenName';
  444. $node->appendToAttribute('objectClass', 'domain');
  445. $this->assertEquals(array(
  446. 'uid' => array('test'),
  447. 'objectclass' => array('account', 'domain'),
  448. 'host' => array('host'),
  449. 'givenname' => array('givenName')
  450. ), $node->getChangedData());
  451. $this->assertEquals(array(
  452. 'add' => array(
  453. 'uid' => array('test'),
  454. 'objectclass' => array('account', 'domain'),
  455. 'host' => array('host'),
  456. 'givenname' => array('givenName'),
  457. ),
  458. 'delete' => array(),
  459. 'replace' => array()
  460. ), $node->getChanges());
  461. }
  462. public function testHasValue()
  463. {
  464. $node=$this->_createTestNode();
  465. $this->assertTrue($node->attributeHasValue('cn', 'name'));
  466. $this->assertFalse($node->attributeHasValue('cn', 'noname'));
  467. $this->assertTrue($node->attributeHasValue('boolean', true));
  468. $this->assertTrue($node->attributeHasValue('boolean', false));
  469. $this->assertTrue($node->attributeHasValue('host', array('a', 'b')));
  470. $this->assertTrue($node->attributeHasValue('host', array('a', 'b', 'c')));
  471. $this->assertFalse($node->attributeHasValue('host', array('a', 'b', 'c', 'd')));
  472. $this->assertTrue($node->attributeHasValue('boolean', array(true, false)));
  473. }
  474. public function testRemoveDuplicates()
  475. {
  476. $node=$this->_createTestNode();
  477. $node->strings1= array('value1', 'value2', 'value2', 'value3');
  478. $node->strings2= array('value1', 'value2', 'value3', 'value4');
  479. $node->boolean1= array(true, true, true, true);
  480. $node->boolean2= array(true, false, true, false);
  481. $expected=array(
  482. 'cn' => array('name'),
  483. 'host' => array('a', 'b', 'c'),
  484. 'empty' => array(),
  485. 'boolean' => array('TRUE', 'FALSE'),
  486. 'objectclass' => array('account', 'top'),
  487. 'strings1' => array('value1', 'value2', 'value3'),
  488. 'strings2' => array('value1', 'value2', 'value3', 'value4'),
  489. 'boolean1' => array('TRUE'),
  490. 'boolean2' => array('TRUE', 'FALSE'),
  491. );
  492. $node->removeDuplicatesFromAttribute('strings1');
  493. $node->removeDuplicatesFromAttribute('strings2');
  494. $node->removeDuplicatesFromAttribute('boolean1');
  495. $node->removeDuplicatesFromAttribute('boolean2');
  496. $this->assertEquals($expected, $node->getData(false));
  497. }
  498. public function testRemoveFromAttributeSimple()
  499. {
  500. $node=$this->_createTestNode();
  501. $node->test=array('value1', 'value2', 'value3', 'value3');
  502. $node->removeFromAttribute('test', 'value2');
  503. $this->assertEquals(array('value1', 'value3', 'value3'), $node->test);
  504. }
  505. public function testRemoveFromAttributeArray()
  506. {
  507. $node=$this->_createTestNode();
  508. $node->test=array('value1', 'value2', 'value3', 'value3');
  509. $node->removeFromAttribute('test', array('value1', 'value2'));
  510. $this->assertEquals(array('value3', 'value3'), $node->test);
  511. }
  512. public function testRemoveFromAttributeMultipleSimple()
  513. {
  514. $node=$this->_createTestNode();
  515. $node->test=array('value1', 'value2', 'value3', 'value3');
  516. $node->removeFromAttribute('test', 'value3');
  517. $this->assertEquals(array('value1', 'value2'), $node->test);
  518. }
  519. public function testRemoveFromAttributeMultipleArray()
  520. {
  521. $node=$this->_createTestNode();
  522. $node->test=array('value1', 'value2', 'value3', 'value3');
  523. $node->removeFromAttribute('test', array('value1', 'value3'));
  524. $this->assertEquals(array('value2'), $node->test);
  525. }
  526. /**
  527. * ZF-11611
  528. */
  529. public function testRdnAttributesHandleMultiValuedAttribute()
  530. {
  531. $data = array(
  532. 'dn' => 'cn=funkygroup,ou=Groupes,dc=domain,dc=local',
  533. 'objectClass' => array(
  534. 'groupOfNames',
  535. 'top',
  536. ),
  537. 'cn' => array(
  538. 'The Funkygroup',
  539. 'funkygroup',
  540. ),
  541. 'member' => 'uid=john-doe,ou=Users,dc=domain,dc=local',
  542. );
  543. $node = Zend_Ldap_Node::fromArray($data, true);
  544. $this->assertEmpty($node->getChangedData());
  545. }
  546. /**
  547. * ZF-11611
  548. */
  549. public function testRdnAttributesHandleMultiValuedAttribute2()
  550. {
  551. $data = array(
  552. 'dn' => 'cn=funkygroup,ou=Groupes,dc=domain,dc=local',
  553. 'objectClass' => array(
  554. 'groupOfNames',
  555. 'top',
  556. ),
  557. 'member' => 'uid=john-doe,ou=Users,dc=domain,dc=local',
  558. );
  559. $node = Zend_Ldap_Node::fromArray($data, true);
  560. $cn = $node->getAttribute('cn');
  561. $this->assertEquals(array(
  562. 0 => 'funkygroup'
  563. ), $cn);
  564. }
  565. /**
  566. * ZF-11611
  567. */
  568. public function testRdnAttributesHandleMultiValuedAttribute3()
  569. {
  570. $data = array(
  571. 'dn' => 'cn=funkygroup,ou=Groupes,dc=domain,dc=local',
  572. 'objectClass' => array(
  573. 'groupOfNames',
  574. 'top',
  575. ),
  576. 'cn' => array(
  577. 0 => 'The Funkygroup'
  578. ),
  579. 'member' => 'uid=john-doe,ou=Users,dc=domain,dc=local',
  580. );
  581. $node = Zend_Ldap_Node::fromArray($data, true);
  582. $cn = $node->getAttribute('cn');
  583. $this->assertEquals(array(
  584. 0 => 'The Funkygroup',
  585. 1 => 'funkygroup',
  586. ), $cn);
  587. }
  588. }