diff --git a/src/Action/Account/FetchAccounts.php b/src/Action/Account/FetchAccounts.php index 272bd32..fb482b8 100644 --- a/src/Action/Account/FetchAccounts.php +++ b/src/Action/Account/FetchAccounts.php @@ -5,18 +5,18 @@ namespace App\Action\Account; use App\Action\ActionInterface; +use App\Contract\Repository\AccountRepositoryInterface; use App\Contract\Repository\MyFxBookRepositoryInterface; use App\Dto\Aggregator\AggregateInterface; use App\Event\CreateAccountEvent; use App\Event\UpdateAccountEvent; use App\Exception\AccountNotFoundException; -use App\Repository\AccountRepository; use Symfony\Component\EventDispatcher\EventDispatcherInterface; final readonly class FetchAccounts implements ActionInterface { public function __construct( - private AccountRepository $accountRepository, + private AccountRepositoryInterface $accountRepository, private EventDispatcherInterface $eventBus, private MyFxBookRepositoryInterface $myFxBookRepository ) {} diff --git a/src/Contract/Repository/AccountRepositoryInterface.php b/src/Contract/Repository/AccountRepositoryInterface.php new file mode 100644 index 0000000..d4e6bae --- /dev/null +++ b/src/Contract/Repository/AccountRepositoryInterface.php @@ -0,0 +1,15 @@ +createMock(Account::class); $account->method('getAccountId')->willReturn(1); - $accountRepository = $this->getMockBuilder(AccountRepository::class)->disableOriginalConstructor()->getMock(); + $accountRepository = $this->getMockBuilder(AccountRepositoryInterface::class)->addMethods(['findAll'])->getMock(); $accountRepository->expects($this->once())->method('findAll')->willReturn([$account]); - $eventBus = $this->getMockBuilder(EventDispatcherInterface::class)->disableOriginalConstructor()->getMock(); + $eventBus = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); $eventBus->expects($this->exactly(3))->method('dispatch')->with($this->callback(function ($object) { if ($object instanceof CreateAccountEvent) { return true; @@ -38,7 +38,7 @@ public function testAction(): void $myFxBookRepository->expects($this->once())->method('accounts')->with('123abc#')->willReturn([['accountId' => 1], ['accountId' => 2]]); /** - * @var AccountRepository $accountRepository + * @var AccountRepositoryInterface $accountRepository * @var EventDispatcherInterface $eventBus * @var MyFxBookRepositoryInterface $myFxBookRepository */