Skip to content

Commit

Permalink
Add InMemoryContactPersonRepositoryImplementation and tests
Browse files Browse the repository at this point in the history
This commit introduces the InMemoryContactPersonRepositoryImplementation class, which provides an in-memory implementation of the ContactPersonRepositoryInterface. It also includes associated unit test cases to ensure that the implementation behaves as expected. This mainly assists developers in the process of testing without needing a real database.

Signed-off-by: mesilov <[email protected]>
  • Loading branch information
mesilov committed Jul 21, 2024
1 parent cca7f46 commit 269db81
Show file tree
Hide file tree
Showing 4 changed files with 738 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

namespace Bitrix24\SDK\Application\Contracts\ContactPersons\Repository;

use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts;
use Bitrix24\SDK\Application\Contracts\ContactPersons\Entity\ContactPersonInterface;
use Bitrix24\SDK\Application\Contracts\ContactPersons\Entity\ContactPersonStatus;
use Bitrix24\SDK\Application\Contracts\ContactPersons\Exceptions\ContactPersonNotFoundException;
use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException;
use libphonenumber\PhoneNumber;
use Symfony\Component\Uid\Uuid;

interface ContactPersonRepositoryInterface
{
/**
* Save contact person to persistence storage
*/
public function save(ContactPersonInterface $contactPerson): void;

/**
* Delete contact person from persistence storage
* @throws ContactPersonNotFoundException
* @throws InvalidArgumentException
*/
public function delete(Uuid $uuid): void;

/**
* Get contact person by id
* @throws ContactPersonNotFoundException
*/
public function getById(Uuid $uuid): ContactPersonInterface;

/**
* Find contact persons with email and filter by status and isEmailVerified flag
* @param non-empty-string $email
* @param ContactPersonStatus|null $status
* @param bool|null $isEmailVerified
* @return ContactPersonInterface[]
*/
public function findByEmail(string $email, ?ContactPersonStatus $status = null, ?bool $isEmailVerified = null): array;

/**
* Find contact persons with PhoneNumber and filter by status and isEmailVerified flag
* @param PhoneNumber $phoneNumber
* @param ContactPersonStatus|null $status
* @param bool|null $isPhoneVerified
* @return ContactPersonInterface[]
*/
public function findByPhone(PhoneNumber $phoneNumber, ?ContactPersonStatus $status = null, ?bool $isPhoneVerified = null): array;

/**
* Find contact person by external id
*
* @param non-empty-string $externalId
* @return ContactPersonInterface|null
*/
public function findByExternalId(string $externalId): ?ContactPersonInterface;
}
Loading

0 comments on commit 269db81

Please sign in to comment.