fix enrollment logic, add financial aid, fix class distribution
Tests / PHPUnit (push) Failing after 1m6s
Tests / PHPUnit (push) Failing after 1m6s
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
namespace Tests\App\Libraries;
|
||||
|
||||
use App\Libraries\Tuition\NewTuitionCalculatorService;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NewTuitionCalculatorServiceTest extends CIUnitTestCase
|
||||
class NewTuitionCalculatorServiceTest extends TestCase
|
||||
{
|
||||
public function testFamilyDiscountsApplyByStudentPosition(): void
|
||||
{
|
||||
@@ -17,17 +17,17 @@ class NewTuitionCalculatorServiceTest extends CIUnitTestCase
|
||||
['student_id' => 2, 'student_name' => 'Second', 'grade_level' => '2'],
|
||||
], [
|
||||
'grade_fee' => 9,
|
||||
'new_tuition_full_amount' => '350.00',
|
||||
'new_tuition_second_student_discount' => '50.00',
|
||||
'new_tuition_third_student_discount' => '50.00',
|
||||
'new_tuition_fourth_plus_discount' => '100.00',
|
||||
'new_tuition_full_amount' => '380.00',
|
||||
'new_tuition_second_student_discount' => '100.00',
|
||||
]);
|
||||
|
||||
$this->assertSame('1200.00', $result['total']);
|
||||
$this->assertSame('350.00', $result['details'][0]['amount']);
|
||||
$this->assertSame('300.00', $result['details'][1]['amount']);
|
||||
$this->assertSame('300.00', $result['details'][2]['amount']);
|
||||
$this->assertSame('250.00', $result['details'][3]['amount']);
|
||||
$this->assertSame('1220.00', $result['total']);
|
||||
$this->assertSame('380.00', $result['details'][0]['amount']);
|
||||
$this->assertSame('280.00', $result['details'][1]['amount']);
|
||||
$this->assertSame('280.00', $result['details'][2]['amount']);
|
||||
$this->assertSame('280.00', $result['details'][3]['amount']);
|
||||
$this->assertSame('new_first_student_full_amount', $result['details'][0]['rule']);
|
||||
$this->assertSame('new_additional_student_discount', $result['details'][1]['rule']);
|
||||
}
|
||||
|
||||
public function testDiscountCannotDriveAmountBelowZero(): void
|
||||
@@ -37,22 +37,19 @@ class NewTuitionCalculatorServiceTest extends CIUnitTestCase
|
||||
['student_id' => 1, 'student_name' => 'One', 'grade_level' => '1'],
|
||||
['student_id' => 2, 'student_name' => 'Two', 'grade_level' => '2'],
|
||||
['student_id' => 3, 'student_name' => 'Three', 'grade_level' => '3'],
|
||||
['student_id' => 4, 'student_name' => 'Four', 'grade_level' => '4'],
|
||||
['student_id' => 5, 'student_name' => 'Five', 'grade_level' => '5'],
|
||||
], [
|
||||
'grade_fee' => 9,
|
||||
'new_tuition_full_amount' => '75.00',
|
||||
'new_tuition_second_student_discount' => '50.00',
|
||||
'new_tuition_third_student_discount' => '50.00',
|
||||
'new_tuition_fourth_plus_discount' => '100.00',
|
||||
'new_tuition_second_student_discount' => '100.00',
|
||||
]);
|
||||
|
||||
$this->assertSame('125.00', $result['total']);
|
||||
$this->assertSame('0.00', $result['details'][3]['amount']);
|
||||
$this->assertSame('0.00', $result['details'][4]['amount']);
|
||||
$this->assertSame('75.00', $result['total']);
|
||||
$this->assertSame('75.00', $result['details'][0]['amount']);
|
||||
$this->assertSame('0.00', $result['details'][1]['amount']);
|
||||
$this->assertSame('0.00', $result['details'][2]['amount']);
|
||||
}
|
||||
|
||||
public function testYouthStudentsUseSeparateUnitPriceWithoutAffectingRegularDiscountOrder(): void
|
||||
public function testYouthStudentsUseTheSameFamilyTuitionRule(): void
|
||||
{
|
||||
$service = new NewTuitionCalculatorService();
|
||||
$result = $service->calculateFamilyTuition([
|
||||
@@ -61,19 +58,31 @@ class NewTuitionCalculatorServiceTest extends CIUnitTestCase
|
||||
['student_id' => 2, 'student_name' => 'Regular Two', 'grade_level' => '5'],
|
||||
], [
|
||||
'grade_fee' => 9,
|
||||
'new_tuition_full_amount' => '370.00',
|
||||
'new_tuition_youth_amount' => '200.00',
|
||||
'new_tuition_second_student_discount' => '150.00',
|
||||
'new_tuition_third_student_discount' => '150.00',
|
||||
'new_tuition_fourth_plus_discount' => '150.00',
|
||||
'new_tuition_full_amount' => '380.00',
|
||||
'new_tuition_second_student_discount' => '100.00',
|
||||
]);
|
||||
|
||||
$this->assertSame('790.00', $result['total']);
|
||||
$this->assertSame('new_first_student_full_amount', $result['details'][0]['rule']);
|
||||
$this->assertSame('370.00', $result['details'][0]['amount']);
|
||||
$this->assertSame('new_second_student_discount', $result['details'][1]['rule']);
|
||||
$this->assertSame('220.00', $result['details'][1]['amount']);
|
||||
$this->assertSame('new_youth_unit_price', $result['details'][2]['rule']);
|
||||
$this->assertSame('200.00', $result['details'][2]['amount']);
|
||||
$this->assertSame('940.00', $result['total']);
|
||||
$this->assertSame('380.00', $result['details'][0]['amount']);
|
||||
$this->assertSame('280.00', $result['details'][1]['amount']);
|
||||
$this->assertSame('280.00', $result['details'][2]['amount']);
|
||||
$this->assertSame('new_additional_student_discount', $result['details'][2]['rule']);
|
||||
}
|
||||
|
||||
public function testGradeStudentAndYouthStudentAreTwoFamilyStudents(): void
|
||||
{
|
||||
$service = new NewTuitionCalculatorService();
|
||||
$result = $service->calculateFamilyTuition([
|
||||
['student_id' => 1, 'student_name' => 'Grade Student', 'grade_level' => '4'],
|
||||
['student_id' => 2, 'student_name' => 'Youth Student', 'grade_level' => 'Youth 1'],
|
||||
], [
|
||||
'grade_fee' => 9,
|
||||
'new_tuition_full_amount' => '380.00',
|
||||
'new_tuition_second_student_discount' => '100.00',
|
||||
]);
|
||||
|
||||
$this->assertSame('660.00', $result['total']);
|
||||
$this->assertSame('380.00', $result['details'][0]['amount']);
|
||||
$this->assertSame('280.00', $result['details'][1]['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user