60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* This should test all LDAP server caching configuration
|
|
*
|
|
* @package Kohana/LDAP
|
|
* @category Test
|
|
* @author Deon George
|
|
* @copyright (c) 2013 phpLDAPadmin Development Team
|
|
* @license http://dev.phpldapadmin.org/license.html
|
|
* @group ldap
|
|
* @group ldap.server
|
|
*/
|
|
Class LDAPCaching extends Unittest_TestCase {
|
|
function hosts() {
|
|
return array(
|
|
array(FALSE,TRUE,FALSE,60),
|
|
array(TRUE,TRUE,FALSE,0),
|
|
array(TRUE,FALSE,FALSE,60),
|
|
array(TRUE,FALSE,FALSE,0),
|
|
array(TRUE,FALSE,TRUE,60),
|
|
array(TRUE,FALSE,TRUE,0),
|
|
array(TRUE,TRUE,TRUE,60),
|
|
array(TRUE,TRUE,TRUE,0),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Test that we can connect to an LDAP server
|
|
* @dataProvider hosts
|
|
*/
|
|
function testCache($expect,$caching,$force,$cached) {
|
|
$connection = Arr::merge(Kohana::$config->load('database.default'),array(
|
|
'caching'=>$caching,
|
|
));
|
|
|
|
$x = LDAP::factory('user',NULL,$connection);
|
|
$x->connect();
|
|
|
|
// We'll do a query first.
|
|
$u = $x->search(array(''))
|
|
->scope('base')
|
|
->cached($cached,$force)
|
|
->execute();
|
|
|
|
$u = $x->search(array(''))
|
|
->scope('base')
|
|
->cached($cached,$force)
|
|
->execute();
|
|
|
|
if (! Kohana::$caching OR $expect) {
|
|
$this->assertInstanceOf('Database_LDAP_Result',$u['']);
|
|
} else {
|
|
$this->assertInstanceOf('Database_LDAP_Result_Cached',$u['']);
|
|
}
|
|
|
|
$x->disconnect();
|
|
}
|
|
}
|