This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
lnldap/tests/classes/LDAPCaching.php

60 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2013-07-13 12:42:02 +00:00
<?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)
2013-08-16 02:21:17 +00:00
->execute();
2013-07-13 12:42:02 +00:00
$u = $x->search(array(''))
->scope('base')
->cached($cached,$force)
2013-08-16 02:21:17 +00:00
->execute();
2013-07-13 12:42:02 +00:00
2014-04-29 04:26:56 +00:00
if (! Kohana::$caching OR $expect) {
2013-07-13 12:42:02 +00:00
$this->assertInstanceOf('Database_LDAP_Result',$u['']);
2014-04-29 04:26:56 +00:00
} else {
2013-07-13 12:42:02 +00:00
$this->assertInstanceOf('Database_LDAP_Result_Cached',$u['']);
2014-04-29 04:26:56 +00:00
}
2013-07-13 12:42:02 +00:00
$x->disconnect();
}
}