Fixed potential crashes in type ID tests

if the constants had any non-stringable values, these would blow up.
this would still be fine in the sense that the tests would fail, but better that they fail gracefully if possible.
This commit is contained in:
Dylan K. Taylor 2025-01-06 22:48:22 +00:00
parent b6bd3ef30c
commit 20849d6268
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 10 additions and 2 deletions

View File

@ -35,8 +35,12 @@ class BlockTypeIdsTest extends TestCase{
$constants = $reflect->getConstants();
unset($constants['FIRST_UNUSED_BLOCK_ID']);
self::assertNotEmpty($constants, "We should never have zero type IDs");
self::assertSame($reflect->getConstant('FIRST_UNUSED_BLOCK_ID'), max($constants) + 1, "FIRST_UNUSED_BLOCK_ID must be one higher than the highest fixed type ID");
$max = max($constants);
self::assertIsInt($max, "Max type ID should always be an integer");
self::assertSame($reflect->getConstant('FIRST_UNUSED_BLOCK_ID'), $max + 1, "FIRST_UNUSED_BLOCK_ID must be one higher than the highest fixed type ID");
}
public function testNoDuplicates() : void{

View File

@ -35,8 +35,12 @@ class ItemTypeIdsTest extends TestCase{
$constants = $reflect->getConstants();
unset($constants['FIRST_UNUSED_ITEM_ID']);
self::assertNotEmpty($constants, "We should never have zero type IDs");
self::assertSame($reflect->getConstant('FIRST_UNUSED_ITEM_ID'), max($constants) + 1, "FIRST_UNUSED_ITEM_ID must be one higher than the highest fixed type ID");
$max = max($constants);
self::assertIsInt($max, "Max type ID should always be an integer");
self::assertSame($reflect->getConstant('FIRST_UNUSED_ITEM_ID'), $max + 1, "FIRST_UNUSED_ITEM_ID must be one higher than the highest fixed type ID");
}
public function testNoDuplicates() : void{