From 982c3561744bdf545f676ea548a38131098b5008 Mon Sep 17 00:00:00 2001 From: dev-rminds Date: Thu, 26 Feb 2026 11:45:52 +0200 Subject: [PATCH] add unit-tests for search classes: announcements, business types, employee events, employees and fund-forms covered, added placeholder classes for remaining search types --- config/forus/event_permissions.php | 4 +- .../Unit/Searches/AnnouncementSearchTest.php | 338 ++++++++++++++++++ .../Unit/Searches/BusinessTypeSearchTest.php | 53 +++ .../Searches/EmployeeEventLogSearchTest.php | 266 ++++++++++++++ tests/Unit/Searches/EmployeesSearchTest.php | 171 +++++++++ tests/Unit/Searches/FundFormSearchTest.php | 191 ++++++++++ .../Unit/Searches/FundProviderSearchTest.php | 27 ++ tests/Unit/Searches/FundRequestSearchTest.php | 19 + tests/Unit/Searches/FundSearchTest.php | 19 + .../FundTopUpTransactionSearchTest.php | 19 + .../Unit/Searches/NotificationSearchTest.php | 19 + tests/Unit/Searches/OfficeSearchTest.php | 19 + .../Unit/Searches/OrganizationSearchTest.php | 21 ++ .../PhysicalCardRequestSearchTest.php | 19 + .../Unit/Searches/PhysicalCardSearchTest.php | 19 + .../Searches/PhysicalCardTypeSearchTest.php | 19 + .../PrevalidationRequestSearchTest.php | 19 + .../Unit/Searches/PrevalidationSearchTest.php | 19 + .../Searches/ProductCategorySearchTest.php | 19 + .../ProductReservationsSearchTest.php | 19 + tests/Unit/Searches/ProductSearchTest.php | 21 ++ tests/Unit/Searches/RecordSearchTest.php | 21 ++ tests/Unit/Searches/RecordTypeSearchTest.php | 19 + .../Searches/ReimbursementsSearchTest.php | 19 + .../ReservationExtraPaymentsSearchTest.php | 19 + tests/Unit/Searches/SearchTestCase.php | 27 ++ .../Searches/Sponsor/EmailLogSearchTest.php | 30 ++ .../Sponsor/FundIdentitiesSearchTest.php | 30 ++ .../Sponsor/HouseholdProfilesSearchTest.php | 20 ++ .../Searches/Sponsor/HouseholdSearchTest.php | 20 ++ .../Searches/Sponsor/IdentitiesSearchTest.php | 23 ++ ...FundRequestPayoutBankAccountSearchTest.php | 27 ++ ...TransactionPayoutBankAccountSearchTest.php | 27 ++ .../ProfilePayoutBankAccountSearchTest.php | 27 ++ ...imbursementPayoutBankAccountSearchTest.php | 27 ++ .../Unit/Searches/VoucherRecordSearchTest.php | 19 + .../VoucherTransactionBulksSearchTest.php | 19 + .../VoucherTransactionsSearchTest.php | 19 + tests/Unit/Searches/VouchersSearchTest.php | 22 ++ .../Searches/WebshopGenericSearchTest.php | 19 + 40 files changed, 1752 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/Searches/AnnouncementSearchTest.php create mode 100644 tests/Unit/Searches/BusinessTypeSearchTest.php create mode 100644 tests/Unit/Searches/EmployeeEventLogSearchTest.php create mode 100644 tests/Unit/Searches/EmployeesSearchTest.php create mode 100644 tests/Unit/Searches/FundFormSearchTest.php create mode 100644 tests/Unit/Searches/FundProviderSearchTest.php create mode 100644 tests/Unit/Searches/FundRequestSearchTest.php create mode 100644 tests/Unit/Searches/FundSearchTest.php create mode 100644 tests/Unit/Searches/FundTopUpTransactionSearchTest.php create mode 100644 tests/Unit/Searches/NotificationSearchTest.php create mode 100644 tests/Unit/Searches/OfficeSearchTest.php create mode 100644 tests/Unit/Searches/OrganizationSearchTest.php create mode 100644 tests/Unit/Searches/PhysicalCardRequestSearchTest.php create mode 100644 tests/Unit/Searches/PhysicalCardSearchTest.php create mode 100644 tests/Unit/Searches/PhysicalCardTypeSearchTest.php create mode 100644 tests/Unit/Searches/PrevalidationRequestSearchTest.php create mode 100644 tests/Unit/Searches/PrevalidationSearchTest.php create mode 100644 tests/Unit/Searches/ProductCategorySearchTest.php create mode 100644 tests/Unit/Searches/ProductReservationsSearchTest.php create mode 100644 tests/Unit/Searches/ProductSearchTest.php create mode 100644 tests/Unit/Searches/RecordSearchTest.php create mode 100644 tests/Unit/Searches/RecordTypeSearchTest.php create mode 100644 tests/Unit/Searches/ReimbursementsSearchTest.php create mode 100644 tests/Unit/Searches/ReservationExtraPaymentsSearchTest.php create mode 100644 tests/Unit/Searches/SearchTestCase.php create mode 100644 tests/Unit/Searches/Sponsor/EmailLogSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/FundIdentitiesSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/HouseholdProfilesSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/HouseholdSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/IdentitiesSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/PayoutBankAccounts/FundRequestPayoutBankAccountSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/PayoutBankAccounts/PayoutTransactionPayoutBankAccountSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/PayoutBankAccounts/ProfilePayoutBankAccountSearchTest.php create mode 100644 tests/Unit/Searches/Sponsor/PayoutBankAccounts/ReimbursementPayoutBankAccountSearchTest.php create mode 100644 tests/Unit/Searches/VoucherRecordSearchTest.php create mode 100644 tests/Unit/Searches/VoucherTransactionBulksSearchTest.php create mode 100644 tests/Unit/Searches/VoucherTransactionsSearchTest.php create mode 100644 tests/Unit/Searches/VouchersSearchTest.php create mode 100644 tests/Unit/Searches/WebshopGenericSearchTest.php diff --git a/config/forus/event_permissions.php b/config/forus/event_permissions.php index ee5e530b8..8e78ceb02 100644 --- a/config/forus/event_permissions.php +++ b/config/forus/event_permissions.php @@ -7,7 +7,7 @@ 'permissions' => [ Permission::MANAGE_BANK_CONNECTIONS, ], - 'events' => array_merge([ + 'events' => [ 'disabled', 'monetary_account_changed', 'replaced', @@ -16,7 +16,7 @@ // 'created', // 'rejected', - ]), + ], ], 'voucher' => [ diff --git a/tests/Unit/Searches/AnnouncementSearchTest.php b/tests/Unit/Searches/AnnouncementSearchTest.php new file mode 100644 index 000000000..fe27e8427 --- /dev/null +++ b/tests/Unit/Searches/AnnouncementSearchTest.php @@ -0,0 +1,338 @@ +identity = $this->makeIdentity(); + + $this->organization = $this->makeTestOrganization($this->identity); + $this->makeTestFund($this->organization); + + $this->otherOrganization = $this->makeTestOrganization($this->makeIdentity()); + $this->makeTestFund($this->otherOrganization); + } + + /** + * @return void + */ + public function testQueryBuilds(): void + { + $search = new AnnouncementSearch([], Announcement::query()); + + $this->assertQueryBuilds($search->query()); + } + + /** + * @return void + */ + public function testFiltersByClientTypeDashboards(): void + { + $dashboard = $this->makeAnnouncement(['scope' => 'dashboards']); + $webshop = $this->makeAnnouncement(['scope' => Implementation::FRONTEND_WEBSHOP]); + $sponsor = $this->makeAnnouncement(['scope' => Implementation::FRONTEND_SPONSOR_DASHBOARD]); + $provider = $this->makeAnnouncement(['scope' => Implementation::FRONTEND_PROVIDER_DASHBOARD]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($dashboard->id, $ids); + $this->assertContains($sponsor->id, $ids); + $this->assertNotContains($webshop->id, $ids); + $this->assertNotContains($provider->id, $ids); + } + + /** + * @return void + */ + public function testFiltersByClientTypeWebshopAndImplementation(): void + { + $implementation = $this->organization->implementations()->first(); + $this->assertNotNull($implementation); + + $otherImplementation = $this->otherOrganization->implementations()->first(); + $this->assertNotNull($otherImplementation); + + $global = $this->makeAnnouncement([ + 'scope' => Implementation::FRONTEND_WEBSHOP, + ]); + + $current = $this->makeAnnouncement([ + 'scope' => Implementation::FRONTEND_WEBSHOP, + 'implementation_id' => $implementation->id, + ]); + + $other = $this->makeAnnouncement([ + 'scope' => Implementation::FRONTEND_WEBSHOP, + 'implementation_id' => $otherImplementation->id, + ]); + + $dashboards = $this->makeAnnouncement([ + 'scope' => 'dashboards', + ]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_WEBSHOP, + 'implementation_id' => $implementation->id, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($global->id, $ids); + $this->assertContains($current->id, $ids); + $this->assertNotContains($other->id, $ids); + $this->assertNotContains($dashboards->id, $ids); + } + + /** + * @return void + */ + public function testFiltersByOrganizationId(): void + { + $match = $this->makeAnnouncement(['organization_id' => $this->organization->id]); + $other = $this->makeAnnouncement(['organization_id' => $this->otherOrganization->id]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + 'organization_id' => $this->organization->id, + 'identity_address' => $this->identity->address, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($match->id, $ids); + $this->assertNotContains($other->id, $ids); + } + + /** + * @return void + */ + public function testFiltersByIdentityAddressForRole(): void + { + $employee = $this->organization->findEmployee($this->identity->address); + $this->assertNotNull($employee); + + $role = $employee->roles()->first(); + $this->assertNotNull($role); + + $match = $this->makeAnnouncement(['role_id' => $role->id]); + $outsider = $this->makeIdentity(); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + 'organization_id' => $this->organization->id, + 'identity_address' => $this->identity->address, + ]); + + $ids = $results->pluck('id')->toArray(); + $this->assertContains($match->id, $ids); + + $otherResults = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + 'organization_id' => $this->organization->id, + 'identity_address' => $outsider->address, + ]); + + $otherIds = $otherResults->pluck('id')->toArray(); + $this->assertNotContains($match->id, $otherIds); + } + + /** + * @return void + */ + public function testFiltersByIdentityAddressForBankConnection(): void + { + $bankConnectionType = (new BankConnection())->getMorphClass(); + $bankConnection = $this->makeBankConnection($this->organization); + + $match = $this->makeAnnouncement([ + 'announceable_type' => $bankConnectionType, + 'announceable_id' => $bankConnection->id, + ]); + + $otherBankConnection = $this->makeBankConnection($this->otherOrganization); + + $other = $this->makeAnnouncement([ + 'announceable_type' => $bankConnectionType, + 'announceable_id' => $otherBankConnection->id, + ]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + 'organization_id' => $this->organization->id, + 'identity_address' => $this->identity->address, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($match->id, $ids); + $this->assertNotContains($other->id, $ids); + } + + /** + * @return void + */ + public function testFiltersFallbackToGlobalWhenMissingIdentity(): void + { + $employee = $this->organization->findEmployee($this->identity->address); + $this->assertNotNull($employee); + + $role = $employee->roles()->first(); + $this->assertNotNull($role); + + $global = $this->makeAnnouncement(); + $organization = $this->makeAnnouncement(['organization_id' => $this->organization->id]); + $roleAnnouncement = $this->makeAnnouncement(['role_id' => $role->id]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + 'organization_id' => $this->organization->id, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($global->id, $ids); + $this->assertNotContains($organization->id, $ids); + $this->assertNotContains($roleAnnouncement->id, $ids); + } + + /** + * @return void + */ + public function testFiltersFallbackToGlobalWhenMissingOrganization(): void + { + $employee = $this->organization->findEmployee($this->identity->address); + $this->assertNotNull($employee); + + $role = $employee->roles()->first(); + $this->assertNotNull($role); + + $global = $this->makeAnnouncement(); + $organization = $this->makeAnnouncement(['organization_id' => $this->organization->id]); + $roleAnnouncement = $this->makeAnnouncement(['role_id' => $role->id]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + 'identity_address' => $this->identity->address, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($global->id, $ids); + $this->assertNotContains($organization->id, $ids); + $this->assertNotContains($roleAnnouncement->id, $ids); + } + + /** + * @return void + */ + public function testFiltersExcludeInactiveAnnouncements(): void + { + $active = $this->makeAnnouncement(['active' => true]); + $inactive = $this->makeAnnouncement(['active' => false]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($active->id, $ids); + $this->assertNotContains($inactive->id, $ids); + } + + /** + * @return void + */ + public function testFiltersByStartAt(): void + { + $future = $this->makeAnnouncement(['start_at' => now()->addDay()]); + $past = $this->makeAnnouncement(['start_at' => now()->subDay()]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($past->id, $ids); + $this->assertNotContains($future->id, $ids); + } + + /** + * @return void + */ + public function testFiltersByExpireAt(): void + { + $expired = $this->makeAnnouncement(['expire_at' => now()->subDay()]); + $active = $this->makeAnnouncement(['expire_at' => now()->addDay()]); + + $results = $this->search([ + 'client_type' => Implementation::FRONTEND_SPONSOR_DASHBOARD, + ]); + + $ids = $results->pluck('id')->toArray(); + + $this->assertContains($active->id, $ids); + $this->assertNotContains($expired->id, $ids); + } + + /** + * @param array $overrides + * @return Announcement + */ + protected function makeAnnouncement(array $overrides = []): Announcement + { + return Announcement::create([ + 'type' => 'warning', + 'scope' => 'dashboards', + 'title' => $this->faker->text(), + 'description' => $this->faker->text(), + 'expire_at' => now()->addDay(), + 'active' => true, + ...$overrides, + ]); + } + + /** + * @param array $filters + * @return Collection + */ + protected function search(array $filters): Collection + { + return (new AnnouncementSearch($filters, Announcement::query()))->query()->get(); + } +} diff --git a/tests/Unit/Searches/BusinessTypeSearchTest.php b/tests/Unit/Searches/BusinessTypeSearchTest.php new file mode 100644 index 000000000..668a30d60 --- /dev/null +++ b/tests/Unit/Searches/BusinessTypeSearchTest.php @@ -0,0 +1,53 @@ +assertQueryBuilds($search->query()); + } + + public function testFiltersByUsed(): void + { + $identity = $this->makeIdentity(); + $organization = $this->makeTestOrganization($identity); + $fund = $this->makeTestFund($organization); + + $providerProducts = $this->makeTestProviderWithProducts(1); + $providerProduct = $providerProducts[0]; + $this->addProductToFund($fund, $providerProduct, false); + + $usedType = BusinessType::find($providerProduct->organization->business_type_id); + $this->assertNotNull($usedType); + + $unusedType = BusinessType::create([ + 'key' => 'unused_type', + ]); + + $unusedOrganization = $this->makeTestOrganization($this->makeIdentity(), [ + 'business_type_id' => $unusedType->id, + ]); + + $search = new BusinessTypeSearch(['used' => true], BusinessType::query()); + $ids = $search->query()->pluck('id')->toArray(); + + $this->assertContains($usedType->id, $ids); + $this->assertNotContains($unusedOrganization->business_type_id, $ids); + } +} diff --git a/tests/Unit/Searches/EmployeeEventLogSearchTest.php b/tests/Unit/Searches/EmployeeEventLogSearchTest.php new file mode 100644 index 000000000..f79d07d74 --- /dev/null +++ b/tests/Unit/Searches/EmployeeEventLogSearchTest.php @@ -0,0 +1,266 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity); + $employee = $organization->employees()->firstOrFail(); + $search = new EmployeeEventLogSearch($employee, [], EventLog::query()); + + $this->assertQueryBuilds($search->query()); + } + + /** + * @return void + */ + public function testFiltersByQueryOnIdentityEmail(): void + { + [$organization, $employee] = $this->makeOrganizationEmployee(); + ['events' => $events, 'permissions' => $permissions] = $this->getEventConfig('fund'); + + $fund = $this->makeTestFund($organization); + + $matchIdentity = $this->makeIdentity('match@test.com'); + $otherIdentity = $this->makeIdentity('other@test.com'); + $matchLogs = $this->createLogs($fund, $events, $matchIdentity->address); + + $this->createLogs($fund, $events, $otherIdentity->address); + $role = $this->attachRoleToEmployee($employee); + + $this->assertSearchMatchesPermissions($role, $permissions, fn () => new EmployeeEventLogSearch($employee, [ + 'q' => 'match@test.com', + 'loggable' => ['fund'], + ], EventLog::query()), collect($matchLogs)->pluck('id')->toArray()); + } + + /** + * @return void + */ + public function testFiltersByLoggableTypeFund(): void + { + [$organization, $employee, $employeeIdentity] = $this->makeOrganizationEmployee(); + ['events' => $events, 'permissions' => $permissions] = $this->getEventConfig('fund'); + + $fund = $this->makeTestFund($organization); + $logs = $this->createLogs($fund, $events, $employeeIdentity->address); + $role = $this->attachRoleToEmployee($employee); + + $this->assertSearchMatchesPermissions($role, $permissions, fn () => new EmployeeEventLogSearch($employee, [ + 'loggable' => ['fund'], + ], EventLog::query()), collect($logs)->pluck('id')->toArray()); + } + + /** + * @return void + */ + public function testFiltersByLoggableId(): void + { + [$organization, $employee, $employeeIdentity] = $this->makeOrganizationEmployee(); + ['events' => $events, 'permissions' => $permissions] = $this->getEventConfig('fund'); + + $fund = $this->makeTestFund($organization); + $otherFund = $this->makeTestFund($organization); + $matchLogs = $this->createLogs($fund, $events, $employeeIdentity->address); + + $this->createLogs($otherFund, $events, $employeeIdentity->address); + $role = $this->attachRoleToEmployee($employee); + + $this->assertSearchMatchesPermissions($role, $permissions, fn () => new EmployeeEventLogSearch($employee, [ + 'loggable' => ['fund'], + 'loggable_id' => $fund->id, + ], EventLog::query()), collect($matchLogs)->pluck('id')->toArray()); + } + + /** + * @return void + */ + public function testReturnsNoResultsWhenLoggableIsEmpty(): void + { + [$organization, $employee, $employeeIdentity] = $this->makeOrganizationEmployee(); + ['events' => $events, 'permissions' => $permissions] = $this->getEventConfig('fund'); + + $fund = $this->makeTestFund($organization); + $role = $this->attachRoleToEmployee($employee); + + $this->createLogs($fund, $events, $employeeIdentity->address); + + $this->assertSearchMatchesPermissions($role, $permissions, fn () => new EmployeeEventLogSearch($employee, [ + 'loggable' => [], + ], EventLog::query()), []); + } + + /** + * @return void + */ + public function testVoucherExportedSpecialCase(): void + { + [$organization, $employee, $employeeIdentity] = $this->makeOrganizationEmployee(); + ['events' => $events, 'permissions' => $permissions] = $this->getEventConfig('voucher'); + + $fund = $this->makeTestFund($organization); + $voucher = $this->makeTestVoucher($fund, $this->makeIdentity(), dispatchCreated: false); + + $log = $fund->logs()->create([ + 'event' => Fund::EVENT_VOUCHERS_EXPORTED, + 'data' => ['fund_export_voucher_ids' => [$voucher->id]], + 'identity_address' => $employeeIdentity->address, + ]); + + $voucherLogs = $this->createLogs($voucher, $events, $employeeIdentity->address); + $role = $this->attachRoleToEmployee($employee); + + $this->assertSearchMatchesPermissions($role, $permissions, fn () => new EmployeeEventLogSearch($employee, [ + 'loggable' => ['voucher'], + 'loggable_id' => $voucher->id, + ], EventLog::query()), collect($voucherLogs)->pluck('id')->push($log->id)->toArray()); + } + + /** + * @return void + */ + public function testFiltersByLoggableTypeBankConnection(): void + { + [$organization, $employee, $employeeIdentity] = $this->makeOrganizationEmployee(); + ['events' => $events, 'permissions' => $permissions] = $this->getEventConfig('bank_connection'); + + $this->makeTestFund($organization); + + $bankConnection = $this->makeBankConnection($organization); + $logs = $this->createLogs($bankConnection, $events, $employeeIdentity->address); + $role = $this->attachRoleToEmployee($employee); + + $this->assertSearchMatchesPermissions($role, $permissions, fn () => new EmployeeEventLogSearch($employee, [ + 'loggable' => ['bank_connection'], + ], EventLog::query()), collect($logs)->pluck('id')->toArray()); + } + + /** + * @return void + */ + public function testFiltersByLoggableTypeEmployees(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $ownerEmployee = $organization->employees()->firstOrFail(); + $employeeIdentity = $this->makeIdentity('employee@test.com'); + $employee = $organization->employees()->create([ + 'identity_address' => $employeeIdentity->address, + ]); + + ['events' => $events, 'permissions' => $permissions] = $this->getEventConfig('employees'); + + $logs = $this->createLogs($employee, $events, $employeeIdentity->address); + $role = $this->attachRoleToEmployee($employee); + $ownerLogs = $ownerEmployee->logs()->whereIn('event', $events)->pluck('id')->toArray(); + + $this->assertSearchMatchesPermissions($role, $permissions, fn () => new EmployeeEventLogSearch($employee, [ + 'loggable' => ['employees'], + ], EventLog::query()), collect($logs)->pluck('id')->merge($ownerLogs)->toArray()); + } + + /** + * @param Role $role + * @param array $permissions + * @param callable $buildSearch + * @param array $expectedIds + * @return void + */ + private function assertSearchMatchesPermissions( + Role $role, + array $permissions, + callable $buildSearch, + array $expectedIds, + ): void { + $expected = collect($expectedIds)->sort()->values()->toArray(); + + foreach ($permissions as $permission) { + $role->permissions()->sync(Permission::where('key', $permission)->pluck('id')->toArray()); + + $search = $buildSearch(); + $actual = collect($search->query()->pluck('id')->toArray())->sort()->values()->toArray(); + + $this->assertSame($expected, $actual); + } + } + + /** + * @return array + */ + private function makeOrganizationEmployee(): array + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $employeeIdentity = $this->makeIdentity('employee@test.com'); + $employee = $organization->addEmployee($employeeIdentity); + + return [$organization, $employee, $employeeIdentity]; + } + + /** + * @param $employee + * @return Role + */ + private function attachRoleToEmployee($employee): Role + { + $role = Role::firstOrFail(); + $employee->roles()->sync([$role->id]); + + return $role; + } + + /** + * @param string $key + * @return array + */ + private function getEventConfig(string $key): array + { + $events = Config::get("forus.event_permissions.$key.events"); + $this->assertNotEmpty($events); + + $permissions = Config::get("forus.event_permissions.$key.permissions"); + $this->assertNotEmpty($permissions); + + return [ + 'events' => $events, + 'permissions' => $permissions, + ]; + } + + /** + * @param $loggable + * @param array $events + * @param string $identityAddress + * @return array + */ + private function createLogs($loggable, array $events, string $identityAddress): array + { + return array_map(fn (string $event) => $loggable->logs()->create([ + 'event' => $event, + 'data' => [], + 'identity_address' => $identityAddress, + ]), $events); + } +} diff --git a/tests/Unit/Searches/EmployeesSearchTest.php b/tests/Unit/Searches/EmployeesSearchTest.php new file mode 100644 index 000000000..8dcc58bd2 --- /dev/null +++ b/tests/Unit/Searches/EmployeesSearchTest.php @@ -0,0 +1,171 @@ +assertQueryBuilds($search->query()); + } + + /** + * @return void + */ + public function testFiltersByRole(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $role1 = $this->createRole('test_role_1'); + $role2 = $this->createRole('test_role_2'); + + $employee1 = $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role1->id]); + $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role2->id]); + + $this->assertSearchIds(['role' => $role1->key], [$employee1->id]); + } + + /** + * @return void + */ + public function testFiltersByRoles(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $role1 = $this->createRole('test_role_1'); + $role2 = $this->createRole('test_role_2'); + $role3 = $this->createRole('test_role_3'); + + $employee1 = $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role1->id]); + $employee2 = $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role2->id]); + $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role3->id]); + + $this->assertSearchIds([ + 'roles' => [$role1->key, $role2->key], + ], [$employee1->id, $employee2->id]); + } + + /** + * @return void + */ + public function testFiltersByPermission(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $permission1 = $this->createPermission('test_permission_1'); + $permission2 = $this->createPermission('test_permission_2'); + $role1 = $this->createRole('test_role_1', [$permission1->key]); + $role2 = $this->createRole('test_role_2', [$permission2->key]); + + $employee1 = $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role1->id]); + $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role2->id]); + + $this->assertSearchIds(['permission' => $permission1->key], [$employee1->id]); + } + + /** + * @return void + */ + public function testFiltersByPermissions(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $permission1 = $this->createPermission('test_permission_1'); + $permission2 = $this->createPermission('test_permission_2'); + $permission3 = $this->createPermission('test_permission_3'); + $role1 = $this->createRole('test_role_1', [$permission1->key]); + $role2 = $this->createRole('test_role_2', [$permission2->key]); + $role3 = $this->createRole('test_role_3', [$permission3->key]); + + $employee1 = $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role1->id]); + $employee2 = $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role2->id]); + $this->createEmployeeWithRoles($organization, $this->makeIdentity(), [$role3->id]); + + $this->assertSearchIds([ + 'permissions' => [$permission1->key, $permission2->key], + ], [$employee1->id, $employee2->id]); + } + + /** + * @return void + */ + public function testFiltersByQuery(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $matchIdentity = $this->makeIdentity('match@test.com'); + $otherIdentity = $this->makeIdentity('other@test.com'); + + $matchEmployee = $this->createEmployeeWithRoles($organization, $matchIdentity, []); + $this->createEmployeeWithRoles($organization, $otherIdentity, []); + + $this->assertSearchIds(['q' => 'match@'], [$matchEmployee->id]); + } + + /** + * @param string $key + * @param array $permissionKeys + * @return Role + */ + private function createRole(string $key, array $permissionKeys = []): Role + { + $role = Role::firstOrCreate(['key' => $key]); + + if ($permissionKeys) { + $role->permissions()->sync(Permission::whereIn('key', $permissionKeys)->pluck('id')->toArray()); + } + + return $role; + } + + /** + * @param string $key + * @return Permission + */ + private function createPermission(string $key): Permission + { + $name = str_replace('_', ' ', $key); + + return Permission::firstOrCreate(['key' => $key], ['name' => $name]); + } + + /** + * @param Organization $organization + * @param Identity $identity + * @param array $roleIds + * @return Employee + */ + private function createEmployeeWithRoles( + Organization $organization, + Identity $identity, + array $roleIds, + ): Employee { + return $organization->addEmployee($identity, $roleIds); + } + + /** + * @param array $filters + * @param array $expectedIds + * @return void + */ + private function assertSearchIds(array $filters, array $expectedIds): void + { + $expected = collect($expectedIds)->sort()->values()->toArray(); + $search = new EmployeesSearch($filters, Employee::query()); + $actual = collect($search->query()->pluck('id')->toArray())->sort()->values()->toArray(); + + $this->assertSame($expected, $actual); + } +} diff --git a/tests/Unit/Searches/FundFormSearchTest.php b/tests/Unit/Searches/FundFormSearchTest.php new file mode 100644 index 000000000..f31467ab9 --- /dev/null +++ b/tests/Unit/Searches/FundFormSearchTest.php @@ -0,0 +1,191 @@ +assertQueryBuilds($search->query()); + } + + /** + * @return void + */ + public function testFiltersByFundId(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $fund1 = $this->makeTestFund($organization); + $fund2 = $this->makeTestFund($organization); + + $form1 = $this->createFundForm($fund1, 'Form 1'); + $this->createFundForm($fund2, 'Form 2'); + + $this->assertSearchIds(['fund_id' => $fund1->id], [$form1->id], $organization); + } + + /** + * @return void + */ + public function testFiltersByQueryMatchesFormAndFundName(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + + $fundA = $this->makeTestFund($organization, ['name' => 'Match Fund']); + $fundB = $this->makeTestFund($organization, ['name' => 'Other Fund']); + $fundC = $this->makeTestFund($organization, ['name' => 'Missing Fund']); + + $formA = $this->createFundForm($fundA, 'Other Form'); + $formB = $this->createFundForm($fundB, 'Match Form'); + + $this->createFundForm($fundC, 'Other Form 2'); + $this->assertSearchIds(['q' => 'Match'], [$formA->id, $formB->id], $organization); + } + + /** + * @return void + */ + public function testFiltersByImplementationId(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $fund1 = $this->makeTestFund($organization); + $implementation2 = $this->makeTestImplementation($organization); + $fund2 = $this->makeTestFund($organization, implementation: $implementation2); + + $this->createFundForm($fund1, 'Form 1'); + $form2 = $this->createFundForm($fund2, 'Form 2'); + + $this->assertSearchIds(['implementation_id' => $implementation2->id], [$form2->id], $organization); + } + + /** + * @return void + */ + public function testFiltersByStateActive(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $activeFund = $this->makeTestFund($organization); + $archivedFund = $this->makeTestFund($organization, ['end_date' => now()->subDay()]); + + $activeForm = $this->createFundForm($activeFund, 'Active Form'); + $this->createFundForm($archivedFund, 'Archived Form'); + + $this->assertSearchIds(['state' => 'active'], [$activeForm->id], $organization); + } + + /** + * @return void + */ + public function testFiltersByStateArchived(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $activeFund = $this->makeTestFund($organization); + $archivedFund = $this->makeTestFund($organization, ['end_date' => now()->subDay()]); + + $this->createFundForm($activeFund, 'Active Form'); + $archivedForm = $this->createFundForm($archivedFund, 'Archived Form'); + + $this->assertSearchIds(['state' => 'archived'], [$archivedForm->id], $organization); + } + + /** + * @return void + */ + public function testOrdersByCreatedAt(): void + { + $organization = $this->makeTestOrganization($this->makeIdentity()); + $fund1 = $this->makeTestFund($organization); + $fund2 = $this->makeTestFund($organization); + + $olderForm = $this->createFundForm($fund1, 'Older Form', now()->subDay()); + $newerForm = $this->createFundForm($fund2, 'Newer Form', now()); + + $this->assertSearchOrder([ + 'order_by' => 'created_at', + 'order_dir' => 'asc', + ], [$olderForm->id, $newerForm->id], $organization); + + $this->assertSearchOrder([ + 'order_by' => 'created_at', + 'order_dir' => 'desc', + ], [$newerForm->id, $olderForm->id], $organization); + } + + /** + * @param Fund $fund + * @param string $name + * @param Carbon|null $createdAt + * @return FundForm + */ + private function createFundForm(Fund $fund, string $name, Carbon $createdAt = null): FundForm + { + $form = $fund->fund_form()->create([ + 'name' => $name, + ]); + + if ($createdAt) { + $form->forceFill([ + 'created_at' => $createdAt, + ])->save(); + } + + return $form; + } + + /** + * @param array $filters + * @param Organization $organization + * @return FundFormSearch + */ + private function makeSearch(array $filters, Organization $organization): FundFormSearch + { + return new FundFormSearch($filters, FundForm::whereRelation('fund', 'organization_id', $organization->id)); + } + + /** + * @param array $filters + * @param array $expectedIds + * @param Organization $organization + * @return void + */ + private function assertSearchIds(array $filters, array $expectedIds, Organization $organization): void + { + $expected = collect($expectedIds)->sort()->values()->toArray(); + $search = $this->makeSearch($filters, $organization); + $actual = collect($search->query()->pluck('id')->toArray())->sort()->values()->toArray(); + + $this->assertSame($expected, $actual); + } + + /** + * @param array $filters + * @param array $expectedIds + * @param Organization $organization + * @return void + */ + private function assertSearchOrder(array $filters, array $expectedIds, Organization $organization): void + { + $search = $this->makeSearch($filters, $organization); + $actual = $search->query()->pluck('id')->toArray(); + + $this->assertSame($expectedIds, $actual); + } +} diff --git a/tests/Unit/Searches/FundProviderSearchTest.php b/tests/Unit/Searches/FundProviderSearchTest.php new file mode 100644 index 000000000..b2c7497d8 --- /dev/null +++ b/tests/Unit/Searches/FundProviderSearchTest.php @@ -0,0 +1,27 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity); + + $search = new FundProviderSearch([], FundProvider::query(), $organization); + + $this->assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/FundRequestSearchTest.php b/tests/Unit/Searches/FundRequestSearchTest.php new file mode 100644 index 000000000..68e007de8 --- /dev/null +++ b/tests/Unit/Searches/FundRequestSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/FundSearchTest.php b/tests/Unit/Searches/FundSearchTest.php new file mode 100644 index 000000000..a3afa05de --- /dev/null +++ b/tests/Unit/Searches/FundSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/FundTopUpTransactionSearchTest.php b/tests/Unit/Searches/FundTopUpTransactionSearchTest.php new file mode 100644 index 000000000..d31df88a9 --- /dev/null +++ b/tests/Unit/Searches/FundTopUpTransactionSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/NotificationSearchTest.php b/tests/Unit/Searches/NotificationSearchTest.php new file mode 100644 index 000000000..139a669a6 --- /dev/null +++ b/tests/Unit/Searches/NotificationSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/OfficeSearchTest.php b/tests/Unit/Searches/OfficeSearchTest.php new file mode 100644 index 000000000..99981f87e --- /dev/null +++ b/tests/Unit/Searches/OfficeSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/OrganizationSearchTest.php b/tests/Unit/Searches/OrganizationSearchTest.php new file mode 100644 index 000000000..306eacadf --- /dev/null +++ b/tests/Unit/Searches/OrganizationSearchTest.php @@ -0,0 +1,21 @@ +assertQueryBuilds($search->query()); + } + + +} diff --git a/tests/Unit/Searches/PhysicalCardRequestSearchTest.php b/tests/Unit/Searches/PhysicalCardRequestSearchTest.php new file mode 100644 index 000000000..cba1e7cb8 --- /dev/null +++ b/tests/Unit/Searches/PhysicalCardRequestSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/PhysicalCardSearchTest.php b/tests/Unit/Searches/PhysicalCardSearchTest.php new file mode 100644 index 000000000..6696e5d47 --- /dev/null +++ b/tests/Unit/Searches/PhysicalCardSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/PhysicalCardTypeSearchTest.php b/tests/Unit/Searches/PhysicalCardTypeSearchTest.php new file mode 100644 index 000000000..472b59a33 --- /dev/null +++ b/tests/Unit/Searches/PhysicalCardTypeSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/PrevalidationRequestSearchTest.php b/tests/Unit/Searches/PrevalidationRequestSearchTest.php new file mode 100644 index 000000000..a993734f1 --- /dev/null +++ b/tests/Unit/Searches/PrevalidationRequestSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/PrevalidationSearchTest.php b/tests/Unit/Searches/PrevalidationSearchTest.php new file mode 100644 index 000000000..75ea1548e --- /dev/null +++ b/tests/Unit/Searches/PrevalidationSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/ProductCategorySearchTest.php b/tests/Unit/Searches/ProductCategorySearchTest.php new file mode 100644 index 000000000..6fcaa7d87 --- /dev/null +++ b/tests/Unit/Searches/ProductCategorySearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/ProductReservationsSearchTest.php b/tests/Unit/Searches/ProductReservationsSearchTest.php new file mode 100644 index 000000000..87f98f77d --- /dev/null +++ b/tests/Unit/Searches/ProductReservationsSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/ProductSearchTest.php b/tests/Unit/Searches/ProductSearchTest.php new file mode 100644 index 000000000..11258ede7 --- /dev/null +++ b/tests/Unit/Searches/ProductSearchTest.php @@ -0,0 +1,21 @@ +assertQueryBuilds($search->query()); + } + + +} diff --git a/tests/Unit/Searches/RecordSearchTest.php b/tests/Unit/Searches/RecordSearchTest.php new file mode 100644 index 000000000..e288e82e7 --- /dev/null +++ b/tests/Unit/Searches/RecordSearchTest.php @@ -0,0 +1,21 @@ +assertQueryBuilds($search->query()); + } + + +} diff --git a/tests/Unit/Searches/RecordTypeSearchTest.php b/tests/Unit/Searches/RecordTypeSearchTest.php new file mode 100644 index 000000000..6e84870bf --- /dev/null +++ b/tests/Unit/Searches/RecordTypeSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/ReimbursementsSearchTest.php b/tests/Unit/Searches/ReimbursementsSearchTest.php new file mode 100644 index 000000000..af9e5e38c --- /dev/null +++ b/tests/Unit/Searches/ReimbursementsSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/ReservationExtraPaymentsSearchTest.php b/tests/Unit/Searches/ReservationExtraPaymentsSearchTest.php new file mode 100644 index 000000000..6e60f7172 --- /dev/null +++ b/tests/Unit/Searches/ReservationExtraPaymentsSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/SearchTestCase.php b/tests/Unit/Searches/SearchTestCase.php new file mode 100644 index 000000000..4eaf0e757 --- /dev/null +++ b/tests/Unit/Searches/SearchTestCase.php @@ -0,0 +1,27 @@ +assertIsString($builder->toSql()); + + $this->assertNoException( + fn () => $builder->limit(1)->get(), + 'Search query should execute without exceptions.' + ); + } +} diff --git a/tests/Unit/Searches/Sponsor/EmailLogSearchTest.php b/tests/Unit/Searches/Sponsor/EmailLogSearchTest.php new file mode 100644 index 000000000..fc547b83c --- /dev/null +++ b/tests/Unit/Searches/Sponsor/EmailLogSearchTest.php @@ -0,0 +1,30 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity); + + $this->expectException(HttpException::class); + + $search = new EmailLogSearch([], EmailLog::query(), $organization); + $search->query(); + } +} diff --git a/tests/Unit/Searches/Sponsor/FundIdentitiesSearchTest.php b/tests/Unit/Searches/Sponsor/FundIdentitiesSearchTest.php new file mode 100644 index 000000000..9d31a528f --- /dev/null +++ b/tests/Unit/Searches/Sponsor/FundIdentitiesSearchTest.php @@ -0,0 +1,30 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity); + $fund = $this->makeTestFund($organization); + + $search = new FundIdentitiesSearch([], $fund); + + $this->assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/Sponsor/HouseholdProfilesSearchTest.php b/tests/Unit/Searches/Sponsor/HouseholdProfilesSearchTest.php new file mode 100644 index 000000000..900c505a3 --- /dev/null +++ b/tests/Unit/Searches/Sponsor/HouseholdProfilesSearchTest.php @@ -0,0 +1,20 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/Sponsor/HouseholdSearchTest.php b/tests/Unit/Searches/Sponsor/HouseholdSearchTest.php new file mode 100644 index 000000000..78bb71a67 --- /dev/null +++ b/tests/Unit/Searches/Sponsor/HouseholdSearchTest.php @@ -0,0 +1,20 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/Sponsor/IdentitiesSearchTest.php b/tests/Unit/Searches/Sponsor/IdentitiesSearchTest.php new file mode 100644 index 000000000..cde321795 --- /dev/null +++ b/tests/Unit/Searches/Sponsor/IdentitiesSearchTest.php @@ -0,0 +1,23 @@ +expectException(InvalidArgumentException::class); + + $search = new IdentitiesSearch([], Identity::query()); + + $search->query(); + } +} diff --git a/tests/Unit/Searches/Sponsor/PayoutBankAccounts/FundRequestPayoutBankAccountSearchTest.php b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/FundRequestPayoutBankAccountSearchTest.php new file mode 100644 index 000000000..1af08a174 --- /dev/null +++ b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/FundRequestPayoutBankAccountSearchTest.php @@ -0,0 +1,27 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity, ['bsn_enabled' => true]); + + $search = new FundRequestPayoutBankAccountSearch($organization, []); + + $this->assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/Sponsor/PayoutBankAccounts/PayoutTransactionPayoutBankAccountSearchTest.php b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/PayoutTransactionPayoutBankAccountSearchTest.php new file mode 100644 index 000000000..653263c63 --- /dev/null +++ b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/PayoutTransactionPayoutBankAccountSearchTest.php @@ -0,0 +1,27 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity, ['bsn_enabled' => true]); + + $search = new PayoutTransactionPayoutBankAccountSearch($organization, []); + + $this->assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/Sponsor/PayoutBankAccounts/ProfilePayoutBankAccountSearchTest.php b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/ProfilePayoutBankAccountSearchTest.php new file mode 100644 index 000000000..77e634ce3 --- /dev/null +++ b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/ProfilePayoutBankAccountSearchTest.php @@ -0,0 +1,27 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity, ['bsn_enabled' => true]); + + $search = new ProfilePayoutBankAccountSearch($organization, []); + + $this->assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/Sponsor/PayoutBankAccounts/ReimbursementPayoutBankAccountSearchTest.php b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/ReimbursementPayoutBankAccountSearchTest.php new file mode 100644 index 000000000..dc718b1b8 --- /dev/null +++ b/tests/Unit/Searches/Sponsor/PayoutBankAccounts/ReimbursementPayoutBankAccountSearchTest.php @@ -0,0 +1,27 @@ +makeIdentity(); + $organization = $this->makeTestOrganization($identity, ['bsn_enabled' => true]); + + $search = new ReimbursementPayoutBankAccountSearch($organization, []); + + $this->assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/VoucherRecordSearchTest.php b/tests/Unit/Searches/VoucherRecordSearchTest.php new file mode 100644 index 000000000..0369dcad6 --- /dev/null +++ b/tests/Unit/Searches/VoucherRecordSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/VoucherTransactionBulksSearchTest.php b/tests/Unit/Searches/VoucherTransactionBulksSearchTest.php new file mode 100644 index 000000000..aa8605d0b --- /dev/null +++ b/tests/Unit/Searches/VoucherTransactionBulksSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/VoucherTransactionsSearchTest.php b/tests/Unit/Searches/VoucherTransactionsSearchTest.php new file mode 100644 index 000000000..66b94ed6c --- /dev/null +++ b/tests/Unit/Searches/VoucherTransactionsSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/VouchersSearchTest.php b/tests/Unit/Searches/VouchersSearchTest.php new file mode 100644 index 000000000..ea6b4cf1a --- /dev/null +++ b/tests/Unit/Searches/VouchersSearchTest.php @@ -0,0 +1,22 @@ + 'all', + 'source' => 'all', + ], Voucher::query()); + + $this->assertQueryBuilds($search->query()); + } +} diff --git a/tests/Unit/Searches/WebshopGenericSearchTest.php b/tests/Unit/Searches/WebshopGenericSearchTest.php new file mode 100644 index 000000000..473bcb4f2 --- /dev/null +++ b/tests/Unit/Searches/WebshopGenericSearchTest.php @@ -0,0 +1,19 @@ +assertQueryBuilds($search->query('funds')); + } +}