This commit is contained in:
2026-05-14 19:00:55 +02:00
parent 85ad36880c
commit 7f95b8a2ef
64 changed files with 2179 additions and 26 deletions
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace Tests\Unit;
use App\Services\StressCalculator;
use PHPUnit\Framework\TestCase;
class StressCalculatorTest extends TestCase
{
private StressCalculator $calculator;
protected function setUp(): void
{
parent::setUp();
$this->calculator = new StressCalculator();
}
public function test_calculate_score_sums_points_correctly(): void
{
$points = [100, 73, 50];
$this->assertEquals(223, $this->calculator->calculateScore($points));
}
public function test_calculate_score_returns_zero_for_empty_array(): void
{
$this->assertEquals(0, $this->calculator->calculateScore([]));
}
/**
* @dataProvider stressLevelProvider
*/
public function test_determine_level_returns_correct_label(int $score, string $expectedLevel): void
{
$this->assertEquals($expectedLevel, $this->calculator->determineLevel($score));
}
public static function stressLevelProvider(): array
{
return [
[350, StressCalculator::LEVEL_HIGH],
[300, StressCalculator::LEVEL_HIGH],
[299, StressCalculator::LEVEL_MODERATE],
[150, StressCalculator::LEVEL_MODERATE],
[149, StressCalculator::LEVEL_LOW],
[0, StressCalculator::LEVEL_LOW],
];
}
}