connect(); // We'll do a query first. $u = $x->search(array('')) ->scope('base') ->execute(); $this->assertEquals(1,$u->count()); foreach ($u[''] as $k => $v) { $this->assertEquals('',$k); $this->assertTrue(is_array($v)); } $x->disconnect(); } function testDatabase_LDAP_Result_Many() { $x = LDAP::factory('user'); $x->connect(); $y = LDAP::factory('auth'); $y->connect(); // We'll do a query first. $u = $x->search(NULL) ->scope('sub') ->where('uid','=','bart*') ->execute(); foreach ($u['dc=example.com'] as $k => $v) { $this->assertEquals('cn=Bart Simpson,dc=example.com',$k); $this->assertTrue(is_array($v)); } $this->assertEquals(2,count($u['o=Simpsons'])); $this->assertEquals(count($u['o=Simpsons']),$u['o=Simpsons']->count()); $c = 0; foreach ($u['o=Simpsons'] as $k => $v) { if (! $c++) $this->assertEquals('cn=Bart Simpson,ou=People,o=Simpsons',$k); else $this->assertEquals('cn=Bart Simpson-ML,ou=People,o=Simpsons',$k); $this->assertTrue(is_array($v)); } $x->disconnect(); } function testDatabase_LDAP_Search_Result_One() { $x = LDAP::factory('user'); $x->connect(); // We'll do a query first. $u = $x->search(array('')) ->scope('base') ->execute(); $this->assertEquals(1,$u->count()); foreach ($u as $k => $v) { $this->assertEquals('',$k); $this->assertTrue(is_array($v)); } $x->disconnect(); } function testDatabase_LDAP_Search_Result_Many() { $x = LDAP::factory('user'); $x->connect(); $y = LDAP::factory('auth'); $y->connect(); // We'll do a query first. $u = $x->search(NULL) ->scope('sub') ->where('uid','=','bart*') ->execute(); $this->assertEquals(3,count($u)); $c = 0; foreach ($u as $k => $v) { switch (++$c) { case 1: $this->assertEquals('cn=Bart Simpson,dc=example.com',$k); break; case 2: $this->assertEquals('cn=Bart Simpson,ou=People,o=Simpsons',$k); break; case 3: $this->assertEquals('cn=Bart Simpson-ML,ou=People,o=Simpsons',$k); break; default: throw new Kohana_Exception('Unknown value of c? (:c)',array(':c'=>serialize($c))); } $this->assertTrue(is_array($v)); } $x->disconnect(); } function testDatabase_LDAP_Search_Result_OneDeep() { $x = LDAP::factory('user'); $x->connect(); $y = LDAP::factory('auth'); $y->connect(); // We'll do a query first. $u = $x->search(NULL) ->scope('sub') ->where('uid','=','bart-ml') ->execute(); $this->assertEquals(1,count($u)); $c = 0; foreach ($u as $k => $v) { switch (++$c) { case 1: $this->assertEquals('cn=Bart Simpson-ML,ou=People,o=Simpsons',$k); break; default: throw new Kohana_Exception('Unknown value of c? (:c)',array(':c'=>serialize($c))); } $this->assertTrue(is_array($v)); } $x->disconnect(); } }