41 lines
1.5 KiB
PHP
41 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
use App\Game\ConfigLint;
|
||
|
|
|
||
|
|
it('finds no locks in the default config', function () {
|
||
|
|
expect(ConfigLint::check(gameConfig()))->toBe([]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('finds no locks in the dev world', function () {
|
||
|
|
expect(ConfigLint::check(gameConfig(['world' => ['speed' => 100]])))->toBe([]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('reports a farm whose workers eat more than it makes', function () {
|
||
|
|
$config = gameConfig(['buildings' => ['farm' => ['workers' => ['base' => 40]]]]);
|
||
|
|
|
||
|
|
expect(ConfigLint::check($config))->toContain('[farm] level 0 feeds fewer people than it needs as workers.');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('reports a storage level that its predecessor cannot pay for', function () {
|
||
|
|
$config = gameConfig(['buildings' => ['storage' => ['cost' => ['wood' => 2000]]]]);
|
||
|
|
|
||
|
|
expect(ConfigLint::check($config))->toContain('[storage] level 1 costs more than level 0 holds.');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('reports requirement cycles and unknown requirements', function () {
|
||
|
|
$config = gameConfig(['buildings' => [
|
||
|
|
'wall' => ['requires' => ['rally_point' => 1]],
|
||
|
|
'rally_point' => ['requires' => ['wall' => 1, 'castle' => 1]],
|
||
|
|
]]);
|
||
|
|
|
||
|
|
expect(ConfigLint::check($config))
|
||
|
|
->toContain('[rally_point] requires unknown type [castle].')
|
||
|
|
->toContain('Requirement cycle through [wall].');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('reports start buildings that do not fit the grid', function () {
|
||
|
|
$config = gameConfig(['world' => ['village' => ['grid' => [3, 3]]]]);
|
||
|
|
|
||
|
|
expect(ConfigLint::check($config))->toContain('Start building [storage] does not fit the 3x3 grid.');
|
||
|
|
});
|