1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 22:57:14 +02:00

Added IPHandler test class.

This commit is contained in:
Cameron
2020-02-24 16:42:56 -08:00
parent 126f84d1e1
commit 22323b3c77
2 changed files with 163 additions and 0 deletions

View File

@@ -1278,6 +1278,7 @@ class banlistManager
public function __construct()
{
e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_banlist.php");
$this->ourConfigDir = e107::getIPHandler()->getConfigDir();
$this->banTypes = array( // Used in Admin-ui.
'-1' => BANLAN_101, // manual

View File

@@ -0,0 +1,162 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2020 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
class eIPHandlerTest extends \Codeception\Test\Unit
{
/** @var eIPHandler */
protected $ip;
protected function _before()
{
try
{
$this->ip = $this->make('eIPHandler');
} catch(Exception $e)
{
$this->assertTrue(false, "Couldn't load eIPHandler object");
}
$this->__construct();
}
/* public function testMakeEmailQuery()
{
}
public function testGet_host_name()
{
}
public function testSetIP()
{
}
public function testIpDecode()
{
}
public function testWhatIsThis()
{
}
public function testIp6AddWildcards()
{
}
public function testIsUserLogged()
{
}
public function testCheckFilePerms()
{
}
public function test__construct()
{
}
public function testCheckBan()
{
}
public function testPermsToString()
{
}
public function testMakeDomainQuery()
{
}*/
public function testAdd_ban()
{
// $bantype = 1 for manual, 2 for flooding, 4 for multiple logins
$banDurations = array(
'0' => 0,
'-1' => 0, // manually added ban
'-2' => 0, // flood
'-3' => 8, // hits
'-4' => 10, // multi-login
'-5' => 0, // imported
'-6' => 0, // banned user
'-8' => 0 // unknown
);
define('LAN_SETSAVED', "Saved"); // for preferences.
//set ban duration pref.
e107::getConfig()->set('ban_durations',$banDurations)->save(false,true, false);
$result = $this->ip->add_ban(2,"unit test generated ban", '123.123.123.123', 0,);
$this->assertTrue($result);
}
/*
public function testGetIP()
{
}
public function testGetConfigDir()
{
}
public function testRegenerateFiles()
{
}
public function testBan()
{
}
public function testIsAddressRoutable()
{
}
public function testIpEncode()
{
}
public function testDebug()
{
}
public function testGetUserToken()
{
}
*/
}