socialbox-php/tests/Socialbox/AddressBookTest.php
netkas 61d25a5904
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
Add unit test for address book contact deletion and update default page parameter in addressBookGetContacts method
2025-03-20 13:14:49 -04:00

68 lines
No EOL
3.5 KiB
PHP

<?php
namespace Socialbox;
use Helper;
use PHPUnit\Framework\TestCase;
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\CryptographyException;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\ResolutionException;
use Socialbox\Exceptions\RpcException;
class AddressBookTest extends TestCase
{
/**
* @throws ResolutionException
* @throws RpcException
* @throws CryptographyException
* @throws DatabaseOperationException
*/
public function testAddressBookAdd(): void
{
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnAddressBookTest');
$johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe');
$johnClient->settingsSetPassword('SecretTestingPassword123');
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
$aliceClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'aliceAddressBookTest');
$aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Alice Smith');
$aliceClient->settingsSetPassword('SecretTestingPassword123');
$this->assertTrue($aliceClient->getSessionState()->isAuthenticated());
$johnClient->addressBookAddContact($aliceClient->getIdentifiedAs());
$this->assertTrue($johnClient->addressBookContactExists($aliceClient->getIdentifiedAs()));
$aliceClient->addressBookAddContact($johnClient->getIdentifiedAs());
$this->assertTrue($aliceClient->addressBookContactExists($johnClient->getIdentifiedAs()));
}
/**
* @throws DatabaseOperationException
* @throws ResolutionException
* @throws CryptographyException
* @throws RpcException
*/
public function testAddressBookDelete(): void
{
$johnClient = Helper::generateRandomClient(TEAPOT_DOMAIN, prefix: 'johnAddressBookTest');
$johnClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'John Doe');
$johnClient->settingsSetPassword('SecretTestingPassword123');
$this->assertTrue($johnClient->getSessionState()->isAuthenticated());
$aliceClient = Helper::generateRandomClient(COFFEE_DOMAIN, prefix: 'aliceAddressBookTest');
$aliceClient->settingsAddInformationField(InformationFieldName::DISPLAY_NAME, 'Alice Smith');
$aliceClient->settingsSetPassword('SecretTestingPassword123');
$this->assertTrue($aliceClient->getSessionState()->isAuthenticated());
$this->assertTrue($johnClient->addressBookAddContact($aliceClient->getIdentifiedAs()));
$this->assertTrue($johnClient->addressBookContactExists($aliceClient->getIdentifiedAs()));
$this->assertTrue($johnClient->addressBookDeleteContact($aliceClient->getIdentifiedAs()));
$this->assertFalse($johnClient->addressBookContactExists($aliceClient->getIdentifiedAs()));
$this->assertTrue($aliceClient->addressBookAddContact($johnClient->getIdentifiedAs()));
$this->assertTrue($aliceClient->addressBookContactExists($johnClient->getIdentifiedAs()));
$this->assertTrue($aliceClient->addressBookDeleteContact($johnClient->getIdentifiedAs()));
$this->assertFalse($aliceClient->addressBookContactExists($johnClient->getIdentifiedAs()));
}
}