@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Services\Ai\HybridFusion;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AiHybridFusionTest extends TestCase
|
||||
{
|
||||
public function test_fusion_excludes_unauthorised_ids_and_does_not_double_count_duplicates(): void
|
||||
{
|
||||
$fusion = new HybridFusion;
|
||||
$ranking = $fusion->rank(['secret', 'a', 'a', 'b'], ['b', 'secret'], ['a', 'b']);
|
||||
$this->assertSame(['b', 'a'], array_column($ranking, 'id'));
|
||||
$this->assertEqualsWithDelta(1 / 62, $ranking[1]['score'], 0.000001);
|
||||
$this->assertSame([], $fusion->rank(['a'], ['b'], []));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_that_true_is_true()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user