first commit
This commit is contained in:
42
tests/Feature/ReportingCycleTest.php
Normal file
42
tests/Feature/ReportingCycleTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\ReportingCycle;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ReportingCycleTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedRolesAndPermissions();
|
||||
}
|
||||
|
||||
public function test_reporting_year_is_calculated_from_renewal_year(): void
|
||||
{
|
||||
// Peraturan: pembaharuan 2028 => pelaporan 2026.
|
||||
$this->assertEquals(2026, ReportingCycle::reportingYearFor(2028));
|
||||
$this->assertEquals(2025, ReportingCycle::reportingYearFor(2027));
|
||||
}
|
||||
|
||||
public function test_jpp_can_create_cycle_with_calculated_reporting_year(): void
|
||||
{
|
||||
$jpp = $this->makeUserWithRole('JPP Admin');
|
||||
|
||||
$this->actingAs($jpp)->post(route('reporting-cycles.store'), [
|
||||
'renewal_year' => 2028,
|
||||
'licence_period_year' => 1,
|
||||
'status' => 'aktif',
|
||||
])->assertRedirect();
|
||||
|
||||
$cycle = ReportingCycle::where('renewal_year', 2028)->first();
|
||||
$this->assertNotNull($cycle);
|
||||
$this->assertEquals(2026, $cycle->reporting_year);
|
||||
$this->assertEquals('2026-01-01', $cycle->period_start->toDateString());
|
||||
$this->assertEquals('2026-12-31', $cycle->period_end->toDateString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user