mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Test all known blockstates, not just the ones found in VanillaBlocks
VanillaBlocks isn't guaranteed to be a complete record. For example, I've considered moving chemistry blocks to a separate EducationBlocks registry. In such a case, the blocks are still expected to serialize correctly, but they won't be in VanillaBlocks.
This commit is contained in:
parent
4c03aabe0f
commit
d17032dd8c
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\data\bedrock\blockstate\convert;
|
namespace pocketmine\data\bedrock\blockstate\convert;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\block\VanillaBlocks;
|
use pocketmine\block\BlockFactory;
|
||||||
|
|
||||||
final class BlockSerializerDeserializerTest extends TestCase{
|
final class BlockSerializerDeserializerTest extends TestCase{
|
||||||
private BlockStateToBlockObjectDeserializer $deserializer;
|
private BlockStateToBlockObjectDeserializer $deserializer;
|
||||||
@ -16,12 +16,12 @@ final class BlockSerializerDeserializerTest extends TestCase{
|
|||||||
$this->serializer = new BlockObjectToBlockStateSerializer();
|
$this->serializer = new BlockObjectToBlockStateSerializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAllVanillaBlocksSerializableAndDeserializable() : void{
|
public function testAllKnownBlockStatesSerializableAndDeserializable() : void{
|
||||||
foreach(VanillaBlocks::getAll() as $block){
|
foreach(BlockFactory::getInstance()->getAllKnownStates() as $block){
|
||||||
$blockStateData = $this->serializer->serializeBlock($block);
|
$blockStateData = $this->serializer->serializeBlock($block);
|
||||||
$newBlock = $this->deserializer->deserializeBlock($blockStateData);
|
$newBlock = $this->deserializer->deserializeBlock($blockStateData);
|
||||||
|
|
||||||
self::assertSame($block->getFullId(), $newBlock->getFullId());
|
self::assertSame($block->getFullId(), $newBlock->getFullId(), "Mismatch of blockstate for " . $block->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user