Fix semester context, attendance rosters, and billing workflows
- load global semester helpers consistently and use date-based semester defaults - fix grading and daily attendance duplicate student/section rows - keep attendance violations scoped to the current semester by default - update invoice, refund, discount, payment, and financial aid flows - add configuration cleanup migrations for duplicate calendar/semester keys - refresh parent registration/report-card and print request handling - update related models, services, views, cron notes, and test coverage
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\App\Controllers\Administrator;
|
||||
|
||||
use App\Controllers\Administrator\FinancialAidController;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
|
||||
class FinancialAidRequestStub
|
||||
{
|
||||
public function __construct(private array $post = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function getPost(?string $key = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return $this->post;
|
||||
}
|
||||
|
||||
return $this->post[$key] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
class TestableFinancialAidController extends FinancialAidController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function setRequestObject($request): self
|
||||
{
|
||||
$this->request = $request;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
class FinancialAidControllerTest extends CIUnitTestCase
|
||||
{
|
||||
public function testPostedAdminAmountWinsOverRequestedAmount(): void
|
||||
{
|
||||
$controller = (new TestableFinancialAidController())
|
||||
->setRequestObject(new FinancialAidRequestStub(['admin_amount' => '175.50']));
|
||||
|
||||
$this->assertSame(175.50, $this->approvalAmount($controller, [
|
||||
'requested_amount' => '250.00',
|
||||
]));
|
||||
}
|
||||
|
||||
public function testBlankAdminAmountFallsBackToRequestedAmount(): void
|
||||
{
|
||||
$controller = (new TestableFinancialAidController())
|
||||
->setRequestObject(new FinancialAidRequestStub(['admin_amount' => '']));
|
||||
|
||||
$this->assertSame(250.00, $this->approvalAmount($controller, [
|
||||
'requested_amount' => '250.00',
|
||||
]));
|
||||
}
|
||||
|
||||
private function approvalAmount(FinancialAidController $controller, array $request): float
|
||||
{
|
||||
$reflection = new \ReflectionMethod($controller, 'approvalAmount');
|
||||
$reflection->setAccessible(true);
|
||||
|
||||
return $reflection->invoke($controller, $request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user