注:所有的代碼工作正常,沒有PHPUnit的的PHPUnit:memcache_connect不是PHPUnit的測試用例工作
文件1:的common.php:
public function setNIMUID($NIMUID) {
if(is_bool(Cache::get("$NIMUID"))) {
$user_Array=array("_JID"=>(string)$NIMUID);
Cache::set("$NIMUID",$user_Array);
}
$this->NIMUID=(string)$NIMUID ;
}
文件2:memcache.class。 PHP
方法1:
protected function __construct(array $servers) {
if(!$servers) {
trigger_error('No memcache servers to connect', E_USER_WARNING);
}
for($i = 0, $n = count($servers); $i<$n; ++ $i) {
($con = memcache_connect(key($servers[$i]), current($servers[$i])))&&$this->mc_servers[] = $con;
}
$this->mc_servers_count = count($this->mc_servers);
if(!$this->mc_servers_count) {
$this->mc_servers[0] = null;
}
}
方法2:
static function get($key) {
return self::singleton()->getMemcacheLink($key)->get($key);
}
方法3:
static function singleton() {
//Write here where from to get the servers list from, like
global $memcache_servers;
self::$instance||self::$instance = new Cache($memcache_servers);
return self::$instance;
}
文件3:commonTest.php
public function testCommon()
{
$Common = new Common();
$Common->setNIMUID("saurabh4");
}
$ memcache_servers變量:
$memcache_servers = array(
array('localhost'=>'11211'),
array('127.0.0.1'=>'11211')
);
錯誤:
Fatal error: Call to undefined function memcache_connect()