Add unit test for address book contact deletion and update default page parameter in addressBookGetContacts method
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

This commit is contained in:
netkas 2025-03-20 13:14:49 -04:00
parent 947064a386
commit 61d25a5904
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 30 additions and 1 deletions

View file

@ -290,7 +290,7 @@
* @return Contact[] An array of Contact objects * @return Contact[] An array of Contact objects
* @throws RpcException Thrown if there was an error with the RPC request * @throws RpcException Thrown if there was an error with the RPC request
*/ */
public function addressBookGetContacts(int $page=0, ?int $limit=null): array public function addressBookGetContacts(int $page=1, ?int $limit=null): array
{ {
$request = new RpcRequest(StandardMethods::ADDRESS_BOOK_GET_CONTACTS, parameters: [ $request = new RpcRequest(StandardMethods::ADDRESS_BOOK_GET_CONTACTS, parameters: [
'page' => $page, 'page' => $page,

View file

@ -36,4 +36,33 @@
$aliceClient->addressBookAddContact($johnClient->getIdentifiedAs()); $aliceClient->addressBookAddContact($johnClient->getIdentifiedAs());
$this->assertTrue($aliceClient->addressBookContactExists($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()));
}
} }