From b0c76f4db5b7c963644eda184af5966303a3ddd0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 6 Jul 2022 23:28:08 +0100 Subject: [PATCH] Fixed botched unit tests --- tests/phpunit/block/BlockTest.php | 11 ++++++++++- tests/phpunit/block/regenerate_consistency_check.php | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/block/BlockTest.php b/tests/phpunit/block/BlockTest.php index 3b8d704d9..c5df95c40 100644 --- a/tests/phpunit/block/BlockTest.php +++ b/tests/phpunit/block/BlockTest.php @@ -110,7 +110,16 @@ class BlockTest extends TestCase{ if(!is_array($list)){ throw new \pocketmine\utils\AssumptionFailedError("Old table should be array{knownStates: array, stateDataBits: int}"); } - $knownStates = $list["knownStates"]; + $knownStates = []; + /** + * @var string $name + * @var int[] $stateIds + */ + foreach($list["knownStates"] as $name => $stateIds){ + foreach($stateIds as $stateId){ + $knownStates[$stateId] = $name; + } + } $oldStateDataSize = $list["stateDataBits"]; self::assertSame($oldStateDataSize, Block::INTERNAL_STATE_DATA_BITS, "Changed number of state data bits - consistency check probably need regenerating"); diff --git a/tests/phpunit/block/regenerate_consistency_check.php b/tests/phpunit/block/regenerate_consistency_check.php index 206e76ba5..0db6d3382 100644 --- a/tests/phpunit/block/regenerate_consistency_check.php +++ b/tests/phpunit/block/regenerate_consistency_check.php @@ -46,6 +46,10 @@ if(file_exists($oldTablePath)){ throw new \pocketmine\utils\AssumptionFailedError("Old table should be array{knownStates: array, stateDataBits: int}"); } $old = []; + /** + * @var string $name + * @var int[] $stateIds + */ foreach($oldTable["knownStates"] as $name => $stateIds){ foreach($stateIds as $stateId){ $old[$stateId] = $name;