@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Services\EducationGapCalculator;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EducationGapCalculatorTest extends TestCase
|
||||
{
|
||||
public function test_unknown_supply_is_not_zero_and_invalid_comparisons_are_not_gaps(): void
|
||||
{
|
||||
$calculator = new EducationGapCalculator;
|
||||
$this->assertSame(['state' => 'insufficient_data', 'people' => null], $calculator->observed(100, null, true, true));
|
||||
$this->assertSame(['state' => 'insufficient_data', 'people' => null], $calculator->observed(null, 10, true, true));
|
||||
$this->assertSame(['state' => 'incomparable', 'people' => null], $calculator->observed(100, 10, false, true));
|
||||
$this->assertSame(['state' => 'expired', 'people' => null], $calculator->observed(100, 10, true, false));
|
||||
}
|
||||
|
||||
public function test_comparable_people_produce_only_an_unvalidated_nonnegative_gap(): void
|
||||
{
|
||||
$calculator = new EducationGapCalculator;
|
||||
$this->assertSame(['state' => 'observed_unvalidated', 'people' => 60], $calculator->observed(100, 40, true, true));
|
||||
$this->assertSame(0, $calculator->observed(10, 40, true, true)['people']);
|
||||
$this->assertSame(10, $calculator->observed(10, 0, true, true)['people']);
|
||||
}
|
||||
|
||||
public function test_negative_quantities_are_rejected(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
(new EducationGapCalculator)->observed(10, -1, true, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user