Skip to content

Commit

Permalink
test(feature): expect thrown exception for imbalanced frozen period
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Aug 27, 2023
1 parent bdb730a commit 8a633c0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions t/Feature/Resource/FrozenPeriodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
use CodeIgniter\Test\Fabricator;

use Tests\Feature\Helper\AuthenticatedHTTPTestCase;
use App\Models\CurrencyModel;

use App\Exceptions\UnprocessableRequest;
use App\Models\AccountModel;
use App\Models\ModifierModel;
use App\Models\CurrencyModel;
use App\Models\FinancialEntryModel;
use App\Models\FrozenPeriodModel;
use App\Models\ModifierModel;
use App\Models\SummaryCalculationModel;

class FrozenPeriodTest extends AuthenticatedHTTPTestCase
Expand Down Expand Up @@ -625,14 +627,18 @@ public function testImbalanceCreate()
"user_id" => $authenticated_info->getUser()->id
])->make();

$result = $authenticated_info
->getRequest()
->withBodyFormat("json")
->post("/api/v1/frozen_periods", [
"frozen_period" => $frozen_period->toArray()
]);
try {
$result = $authenticated_info
->getRequest()
->withBodyFormat("json")
->post("/api/v1/frozen_periods", [
"frozen_period" => $frozen_period->toArray()
]);
$this->assertTrue(false);
} catch (Throwable $code) {
$this->assertTrue(true);
}

$result->assertStatus(400);
$this->seeNumRecords(0, "frozen_periods", []);
$this->seeNumRecords(0, "summary_calculations", []);
}
Expand Down

0 comments on commit 8a633c0

Please sign in to comment.