mirror of
https://github.com/e107inc/e107.git
synced 2025-07-25 00:41:52 +02:00
Fixes #5487 test tweak
This commit is contained in:
@@ -360,7 +360,9 @@ class eIPHandlerTest extends \Codeception\Test\Unit
|
|||||||
$this::assertFalse($cached['result']);
|
$this::assertFalse($cached['result']);
|
||||||
$this::assertArrayHasKey('timestamp', $cached);
|
$this::assertArrayHasKey('timestamp', $cached);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
e107::getDb()->delete('banlist');
|
||||||
|
$this->ip->regenerateFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -400,7 +402,7 @@ class eIPHandlerTest extends \Codeception\Test\Unit
|
|||||||
*/
|
*/
|
||||||
public function testCheckBanCacheExpiration()
|
public function testCheckBanCacheExpiration()
|
||||||
{
|
{
|
||||||
|
e107::getSession('eIPHandler')->clearData();
|
||||||
$query = "`banlist_ip`='cameron@mydomain.co.uk' OR `banlist_ip`='*@mydomain.co.uk'";
|
$query = "`banlist_ip`='cameron@mydomain.co.uk' OR `banlist_ip`='*@mydomain.co.uk'";
|
||||||
|
|
||||||
// Ensure no ban exists
|
// Ensure no ban exists
|
||||||
@@ -420,15 +422,10 @@ class eIPHandlerTest extends \Codeception\Test\Unit
|
|||||||
// Simulate cache expiration (11 seconds)
|
// Simulate cache expiration (11 seconds)
|
||||||
e107::getSession('eIPHandler')->set('ban_check_' . md5($query), [
|
e107::getSession('eIPHandler')->set('ban_check_' . md5($query), [
|
||||||
'result' => true,
|
'result' => true,
|
||||||
'timestamp' => time() - 11
|
'timestamp' => time() - 370 // must be more than 360 @see checkban() line $cached['timestamp'] <= 360
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Insert active ban
|
$this->ip->add_ban(1,"nothing", 'cameron@mydomain.co.uk');
|
||||||
e107::getDb()->insert('banlist', [
|
|
||||||
'banlist_ip' => 'cameron@mydomain.co.uk',
|
|
||||||
'banlist_bantype' => 1,
|
|
||||||
'banlist_banexpires' => 0
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Test: new ban after expiration
|
// Test: new ban after expiration
|
||||||
$result = $this->ip->checkBan($query, true, true);
|
$result = $this->ip->checkBan($query, true, true);
|
||||||
|
Reference in New Issue
Block a user