Add repo hygiene rules and ignore secrets
This commit is contained in:
17
server/tests/Unit/MultiplierTest.php
Normal file
17
server/tests/Unit/MultiplierTest.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit;
|
||||
|
||||
use App\Module\Economy\Service\EconomyService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class MultiplierTest extends TestCase
|
||||
{
|
||||
public function testMultiplierChain(): void
|
||||
{
|
||||
$result = EconomyService::multiplyBonuses([0.10, -0.15, 0.10, 0.02]);
|
||||
self::assertEquals(1.04907, $result, '', 0.0001);
|
||||
}
|
||||
}
|
||||
34
server/tests/Unit/PlanetGeneratorTest.php
Normal file
34
server/tests/Unit/PlanetGeneratorTest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit;
|
||||
|
||||
use App\Config\ConfigLoader;
|
||||
use App\Config\ConfigValidator;
|
||||
use App\Module\PlanetGenerator\Service\PlanetGenerator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class PlanetGeneratorTest extends TestCase
|
||||
{
|
||||
public function testIceConstraintsAndScore(): void
|
||||
{
|
||||
$loader = new ConfigLoader(new ConfigValidator(), dirname(__DIR__, 3) . '/config');
|
||||
$generator = new PlanetGenerator($loader);
|
||||
|
||||
$result = $generator->generate('ice', 'normal', 1234);
|
||||
$mods = $result['modifiers'];
|
||||
|
||||
self::assertGreaterThanOrEqual(0.5, $mods['water']);
|
||||
self::assertLessThanOrEqual(-0.6, $mods['energy']);
|
||||
self::assertGreaterThanOrEqual(-80, $result['temperature_c']);
|
||||
self::assertLessThanOrEqual(-10, $result['temperature_c']);
|
||||
|
||||
$config = $loader->planetClasses();
|
||||
$target = (float)$config['tiers']['normal']['target_score'];
|
||||
$epsilon = (float)$config['tiers']['normal']['epsilon'];
|
||||
$score = $generator->calculateScore($mods);
|
||||
|
||||
self::assertEquals($target, $score, '', $epsilon);
|
||||
}
|
||||
}
|
||||
30
server/tests/Unit/QueueSlotsTest.php
Normal file
30
server/tests/Unit/QueueSlotsTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit;
|
||||
|
||||
use App\Config\ConfigLoader;
|
||||
use App\Config\ConfigValidator;
|
||||
use App\Module\Blueprints\Service\BlueprintService;
|
||||
use App\Module\BuildQueue\Service\BuildQueueService;
|
||||
use App\Shared\Clock\FixedTimeProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class QueueSlotsTest extends TestCase
|
||||
{
|
||||
public function testQueueSlotsGrowWithBuildCenter(): void
|
||||
{
|
||||
$pdo = new \PDO('sqlite::memory:');
|
||||
$loader = new ConfigLoader(new ConfigValidator(), dirname(__DIR__, 3) . '/config');
|
||||
$blueprints = new BlueprintService($loader);
|
||||
$service = new BuildQueueService($pdo, $blueprints, new FixedTimeProvider(new \DateTimeImmutable('2026-02-03 00:00:00')));
|
||||
|
||||
$buildings = [
|
||||
'build_center' => ['count' => 2, 'level' => 0],
|
||||
];
|
||||
|
||||
$slots = $service->calculateQueueSlots($buildings, 0);
|
||||
self::assertSame(2, $slots);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user