-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted the whitespace formatting in Handler.php and Bitrix24Account.php for improved readability. Refactored HandlerTest.php to use Bitrix24AccountBuilder for cleaner test setup and added a new test case for handling domain URL changes across multiple accounts. Signed-off-by: mesilov <[email protected]>
- Loading branch information
Showing
5 changed files
with
229 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
tests/Functional/Bitrix24Accounts/Builders/Bitrix24AccountBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the bitrix24-php-lib package. | ||
* | ||
* © Maksim Mesilov <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the MIT-LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bitrix24\Lib\Tests\Functional\Bitrix24Accounts\Builders; | ||
|
||
use Bitrix24\Lib\Bitrix24Accounts\Entity\Bitrix24Account; | ||
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountInterface; | ||
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountStatus; | ||
use Bitrix24\SDK\Application\Contracts\Events\AggregateRootEventsEmitterInterface; | ||
use Bitrix24\SDK\Core\Credentials\AuthToken; | ||
use Bitrix24\SDK\Core\Credentials\Scope; | ||
use Carbon\CarbonImmutable; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
class Bitrix24AccountBuilder | ||
{ | ||
private Uuid $id; | ||
private int $bitrix24UserId; | ||
private bool $isBitrix24UserAdmin; | ||
/** bitrix24 portal unique id */ | ||
private string $memberId; | ||
private string $domainUrl; | ||
private Bitrix24AccountStatus $status; | ||
private AuthToken $authToken; | ||
private CarbonImmutable $createdAt; | ||
private CarbonImmutable $updatedAt; | ||
private int $applicationVersion; | ||
private Scope $applicationScope; | ||
|
||
public function __construct() | ||
{ | ||
$this->id = Uuid::v7(); | ||
$this->bitrix24UserId = random_int(1, 1_000_000); | ||
$this->isBitrix24UserAdmin = true; | ||
$this->memberId = Uuid::v4()->toRfc4122(); | ||
$this->domainUrl = Uuid::v7()->toRfc4122() . '-test.bitrix24.com'; | ||
$this->status = Bitrix24AccountStatus::active; | ||
$this->authToken = new AuthToken('old_1', 'old_2', 3600); | ||
$this->createdAt = CarbonImmutable::now(); | ||
$this->updatedAt = CarbonImmutable::now(); | ||
$this->applicationVersion = 1; | ||
$this->applicationScope = new Scope(); | ||
} | ||
|
||
public function withMemberId(string $memberId): self | ||
{ | ||
$this->memberId = $memberId; | ||
return $this; | ||
} | ||
|
||
public function withDomainUrl(string $domainUrl): self | ||
{ | ||
$this->domainUrl = $domainUrl; | ||
return $this; | ||
} | ||
|
||
public function withStatus(Bitrix24AccountStatus $status): self | ||
{ | ||
$this->status = $status; | ||
return $this; | ||
} | ||
|
||
public function build(): AggregateRootEventsEmitterInterface&Bitrix24AccountInterface | ||
{ | ||
return new Bitrix24Account( | ||
$this->id, | ||
$this->bitrix24UserId, | ||
$this->isBitrix24UserAdmin, | ||
$this->memberId, | ||
$this->domainUrl, | ||
$this->status, | ||
$this->authToken, | ||
$this->createdAt, | ||
$this->updatedAt, | ||
$this->applicationVersion, | ||
$this->applicationScope | ||
); | ||
} | ||
} |
Oops, something went wrong.