mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 00:25:04 +00:00
Check consistency of block remaps
This commit is contained in:
@ -145,14 +145,26 @@ class BlockTest extends TestCase{
|
||||
|
||||
public function testConsistency() : void{
|
||||
$list = json_decode(file_get_contents(__DIR__ . '/block_factory_consistency_check.json'), true);
|
||||
$knownStates = $list["knownStates"];
|
||||
$remaps = $list["remaps"];
|
||||
|
||||
$states = $this->blockFactory->getAllKnownStates();
|
||||
foreach($states as $k => $state){
|
||||
self::assertArrayHasKey($k, $list, "New block state $k (" . $state->getName() . ") - consistency check may need regenerating");
|
||||
self::assertSame($list[$k], $state->getName());
|
||||
if($state->getFullId() !== $k){
|
||||
self::assertArrayHasKey($k, $remaps, "New remap of state $k (" . $state->getName() . ") - consistency check may need regenerating");
|
||||
self::assertSame($state->getFullId(), $remaps[$k], "Mismatched full IDs of remapped state $k");
|
||||
}else{
|
||||
self::assertArrayHasKey($k, $knownStates, "New block state $k (" . $state->getName() . ") - consistency check may need regenerating");
|
||||
self::assertSame($knownStates[$k], $state->getName());
|
||||
}
|
||||
}
|
||||
foreach($list as $k => $name){
|
||||
foreach($knownStates as $k => $name){
|
||||
self::assertArrayHasKey($k, $states, "Missing previously-known block state $k ($name)");
|
||||
self::assertSame($name, $states[$k]->getName());
|
||||
}
|
||||
foreach($remaps as $origin => $destination){
|
||||
self::assertArrayHasKey($origin, $states, "Missing previously-remapped state $origin");
|
||||
self::assertSame($destination, $states[$origin]->getFullId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user