Skip to content

Commit

Permalink
test(feature): specialize test to ensure index frozen period works
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Aug 26, 2023
1 parent a089bec commit 9fb0490
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions t/Feature/Resource/FrozenPeriodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
use App\Models\AccountModel;
use App\Models\ModifierModel;
use App\Models\FinancialEntryModel;
use App\Models\FrozenPeriodModel;

class FrozenPeriodTest extends AuthenticatedHTTPTestCase
{
public function DefaultIndex()
public function testDefaultIndex()
{
$authenticated_info = $this->makeAuthenticatedInfo();

Expand All @@ -25,8 +26,12 @@ public function DefaultIndex()
$account_fabricator->setOverrides([
"currency_id" => $currency->id
]);
$debit_account = $account_fabricator->create();
$credit_account = $account_fabricator->create();
$debit_account = $account_fabricator->setOverrides([
"kind" => ASSET_ACCOUNT_KIND
], false)->create();
$credit_account = $account_fabricator->setOverrides([
"kind" => EQUITY_ACCOUNT_KIND
], false)->create();
$modifier_fabricator = new Fabricator(ModifierModel::class);
$modifier_fabricator->setOverrides([
"debit_account_id" => $debit_account->id,
Expand All @@ -37,16 +42,18 @@ public function DefaultIndex()
$financial_entry_fabricator->setOverrides([
"modifier_id" => $modifier->id
]);
$financial_entries = $financial_entry_fabricator->create(10);
$financial_entry = $financial_entry_fabricator->create();
$frozen_period_fabricator = new Fabricator(FrozenPeriodModel::class);
$frozen_period_fabricator->setOverrides([
"user_id" => $authenticated_info->getUser()->id
]);
$frozen_period = $frozen_period_fabricator->create();

$result = $authenticated_info->getRequest()->get("/api/v1/financial_entries");
$result = $authenticated_info->getRequest()->get("/api/v1/frozen_periods");

$result->assertOk();
$result->assertJSONExact([
"accounts" => json_decode(json_encode([ $debit_account, $credit_account ])),
"currencies" => [ $currency ],
"financial_entries" => json_decode(json_encode($financial_entries)),
"modifiers" => json_decode(json_encode([ $modifier ])),
"frozen_periods" => json_decode(json_encode([ $frozen_period ]))
]);
}

Expand Down Expand Up @@ -305,18 +312,15 @@ public function DefaultForceDelete()
$this->seeNumRecords(0, "financial_entries", []);
}

public function EmptyIndex()
public function testEmptyIndex()
{
$authenticated_info = $this->makeAuthenticatedInfo();

$result = $authenticated_info->getRequest()->get("/api/v1/financial_entries");
$result = $authenticated_info->getRequest()->get("/api/v1/frozen_periods");

$result->assertOk();
$result->assertJSONExact([
"accounts" => [],
"currencies" => [],
"financial_entries" => [],
"modifiers" => [],
"frozen_periods" => json_decode(json_encode([ $frozen_period ])),
]);
}

Expand Down

0 comments on commit 9fb0490

Please sign in to comment.