Add VariableManager, RpcClient classes, and cache enhancements

This commit is contained in:
netkas 2024-09-30 03:00:02 -04:00
parent 38092a639e
commit e55f4d57f9
27 changed files with 606 additions and 56 deletions

View file

@ -20,6 +20,8 @@ class CryptographyTest extends TestCase
$this->assertObjectHasProperty('privateKey', $keyPair);
$this->assertIsString($keyPair->getPublicKey());
$this->assertIsString($keyPair->getPrivateKey());
print_r($keyPair);
}
/**

View file

@ -0,0 +1,21 @@
<?php
namespace Socialbox\Classes;
use PHPUnit\Framework\TestCase;
use Socialbox\Exceptions\ResolutionException;
use Socialbox\Objects\ResolvedServer;
class ServerResolverTest extends TestCase
{
/**
* Test for the function resolveDomain of the class ServerResolver
*/
public function testResolveDomain(): void
{
// successful resolution
$resolvedServer = ServerResolver::resolveDomain('n64.cc');
self::assertNotEmpty($resolvedServer->getEndpoint());
self::assertNotEmpty($resolvedServer->getPublicKey());
}
}

View file

@ -6,7 +6,6 @@ use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Socialbox\Classes\Cryptography;
use Socialbox\Classes\Utilities;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Objects\SessionRecord;
class SessionManagerTest extends TestCase
@ -27,14 +26,6 @@ class SessionManagerTest extends TestCase
$this->assertTrue(SessionManager::sessionExists($uuid));
}
public function testGetSessionWithInvalidUuid(): void
{
$uuid = 'invalid_uuid';
$this->expectException(DatabaseOperationException::class);
SessionManager::getSession($uuid);
}
public function testGetSessionWithValidUuid(): void
{
$keyPair = Cryptography::generateKeyPair();

View file

@ -0,0 +1,34 @@
<?php
namespace Socialbox\Managers;
use PDOException;
use PHPUnit\Framework\TestCase;
use Socialbox\Abstracts\CacheLayer;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Managers\VariableManager;
class VariableManagerTest extends TestCase
{
/**
* Test the setter method for a variable in the VariableManager class.
*
*/
public function testSetVariable(): void
{
CacheLayer::getInstance()->clear();
VariableManager::deleteVariable('test_name');
VariableManager::setVariable('test_name', 'test_value');
$this->assertTrue(VariableManager::variableExists('test_name'));
$this->assertEquals('test_value', VariableManager::getVariable('test_name'));
VariableManager::deleteVariable('test_name');
VariableManager::deleteVariable('test_name2');
VariableManager::setVariable('test_name2', 'test_value2');
$this->assertTrue(VariableManager::variableExists('test_name2'));
$this->assertEquals('test_value2', VariableManager::getVariable('test_name2'));
VariableManager::deleteVariable('test_name2');
}
}