-
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.
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
- Loading branch information
Showing
8 changed files
with
180 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpFinance\DoubleEntry\Domain\Account; | ||
|
||
final class AccountFilter | ||
{ | ||
private ?AccountChartId $accountChartId = null; | ||
|
||
public function getAccountChartId(): ?AccountChartId | ||
{ | ||
return $this->accountChartId; | ||
} | ||
|
||
public function withAccountChartId(?AccountChartId $accountChartId): self | ||
{ | ||
$new = clone $this; | ||
$new->accountChartId = $accountChartId; | ||
return $new; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpFinance\DoubleEntry\Tests\Account; | ||
|
||
use PhpFinance\DoubleEntry\Domain\Account\AccountChartId; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class AccountChartIdTest extends TestCase | ||
{ | ||
public static function dataIsEqualTo(): array | ||
{ | ||
return [ | ||
'equal' => [ | ||
true, | ||
new AccountChartId('7'), | ||
new AccountChartId('7'), | ||
], | ||
'non-equal' => [ | ||
false, | ||
new AccountChartId('7'), | ||
new AccountChartId('42'), | ||
], | ||
]; | ||
} | ||
|
||
#[DataProvider('dataIsEqualTo')] | ||
public function testIsEqualTo(bool $expected, AccountChartId $id1, AccountChartId $id2): void | ||
{ | ||
$this->assertSame($expected, $id1->isEqualTo($id2)); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpFinance\DoubleEntry\Tests\Account; | ||
|
||
use PhpFinance\DoubleEntry\Domain\Account\AccountChartId; | ||
use PhpFinance\DoubleEntry\Domain\Account\AccountFilter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class AccountFilterTest extends TestCase | ||
{ | ||
public function testDefaultValues(): void | ||
{ | ||
$filter = new AccountFilter(); | ||
|
||
$this->assertNull($filter->getAccountChartId()); | ||
} | ||
|
||
public function testValues(): void | ||
{ | ||
$accountChartId = new AccountChartId('test-chart-id'); | ||
|
||
$filter = (new AccountFilter()) | ||
->withAccountChartId($accountChartId); | ||
|
||
$this->assertSame($accountChartId->value, $filter->getAccountChartId()->value); | ||
} | ||
|
||
public function testImmutability(): void | ||
{ | ||
$filter = new AccountFilter(); | ||
|
||
$this->assertNotSame($filter, $filter->withAccountChartId(new AccountChartId('test-chart-id'))); | ||
} | ||
} |
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