[Phpfreechat-svn] SF.net SVN: phpfreechat: [493] trunk/testcase
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-05-12 14:06:44
|
Revision: 493 Author: kerphi Date: 2006-05-12 07:06:35 -0700 (Fri, 12 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=493&view=rev Log Message: ----------- Container api modification: removeObsoleteNick now returns the disconnected users nicknames and their associated timestamp. Modified Paths: -------------- trunk/src/commands/getonlinenick.class.php trunk/src/containers/file.class.php trunk/testcase/container_generic.php Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-05-12 13:55:14 UTC (rev 492) +++ trunk/src/commands/getonlinenick.class.php 2006-05-12 14:06:35 UTC (rev 493) @@ -14,7 +14,7 @@ foreach ($disconnected_users as $u) { $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u), $sender, $recipient, $recipientid, 2); + $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u["nick"]), $sender, $recipient, $recipientid, 2); } // get the cached nickname list Modified: trunk/src/containers/file.class.php =================================================================== --- trunk/src/containers/file.class.php 2006-05-12 13:55:14 UTC (rev 492) +++ trunk/src/containers/file.class.php 2006-05-12 14:06:35 UTC (rev 493) @@ -281,7 +281,7 @@ * Notice: this function must remove all nicknames which are not uptodate from the given channel or from the server * @param $chan if NULL then check obsolete nick on the server, otherwise just check obsolete nick on the given channel * @param $timeout - * @return array() contains all disconnected nicknames + * @return array("nick"=>???, "timestamp"=>???) contains all disconnected nicknames and there timestamp */ function removeObsoleteNick($chan, $timeout) { @@ -299,16 +299,18 @@ while (false !== ($file = readdir($dir_handle))) { if ($file == "." || $file == "..") continue; // skip . and .. generic files - if (time() > (filemtime($nick_dir."/".$file)+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity + $f_time = filemtime($nick_dir."/".$file); + if (time() > ($f_time+$timeout/1000) ) // user will be disconnected after 'timeout' secondes of inactivity { - $deleted_user[] = $this->_decode($file); - unlink($nick_dir."/".$file); // disconnect expired user + $deleted_user[] = array("nick" => $this->_decode($file), + "timestamp" => $f_time); + @unlink($nick_dir."/".$file); // disconnect expired user } else { // optimisation: cache user list for next getOnlineNick call $users[] = array("nick" => $this->_decode($file), - "timestamp" => filemtime($nick_dir."/".$file)); + "timestamp" => $f_time); } } Modified: trunk/testcase/container_generic.php =================================================================== --- trunk/testcase/container_generic.php 2006-05-12 13:55:14 UTC (rev 492) +++ trunk/testcase/container_generic.php 2006-05-12 14:06:35 UTC (rev 493) @@ -113,18 +113,18 @@ $this->ct->createNick($chan, $nick, $nickid); sleep(2); $ret = $this->ct->removeObsoleteNick($chan, "1000"); - $this->assertTrue(in_array($nick, $ret), "nickname should be removed from the channel"); + $this->assertEquals(count($ret), 1, "1 nickname should be obsolete"); $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); - $this->assertFalse($isonline, "nickname shouldn't be online on the channel"); + $this->assertFalse($isonline, "nickname shouldn't be online anymore"); // on the server $chan = NULL; $this->ct->createNick($chan, $nick, $nickid); sleep(2); $ret = $this->ct->removeObsoleteNick($chan, "1000"); - $this->assertTrue(in_array($nick, $ret), "nickname should be removed from the server"); + $this->assertEquals(count($ret), 1, "1 nickname should be obsolete"); $isonline = ($this->ct->isNickOnline($chan, $nick) >= 0); - $this->assertFalse($isonline, "nickname shouldn't be online on the server"); + $this->assertFalse($isonline, "nickname shouldn't be online anymore"); } function testSetGetRmMeta_Generic() @@ -138,25 +138,25 @@ // set / get $this->ct->setMeta($nickid, "key1", "nickname", $nick); $metadata = $this->ct->getMeta("key1", "nickname", $nick); - $this->assertEquals($nickid, $metadata, "1-metadata value is not correct"); + $this->assertEquals($nickid, $metadata, "metadata value is not correct"); // set / rm / get $this->ct->setMeta($nickid, "key2", "nickname", $nick); $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertEquals($nickid, $metadata, "2-metadata value is not correct"); + $this->assertEquals($nickid, $metadata, "metadata value is not correct"); $this->ct->rmMeta("key2", "nickname", $nick); $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertNull($metadata, "3-metadata should not exists anymore"); + $this->assertNull($metadata, "metadata should not exists anymore"); // set / rm (all) / get $this->ct->setMeta($nickid, "key2", "nickname", $nick); $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertEquals($nickid, $metadata, "4-metadata value is not correct"); + $this->assertEquals($nickid, $metadata, "metadata value is not correct"); $this->ct->rmMeta(NULL, "nickname", $nick); $metadata = $this->ct->getMeta("key2", "nickname", $nick); - $this->assertNull($metadata, "5-metadata should not exists anymore"); + $this->assertNull($metadata, "metadata should not exists anymore"); $metadata = $this->ct->getMeta("key1", "nickname", $nick); - $this->assertNull($metadata, "6-metadata should not exists anymore"); + $this->assertNull($metadata, "metadata should not exists anymore"); } function testupdateNick_Generic() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |