PocketMine-MP/tests/phpunit/data/bedrock/blockstate/convert/BlockSerializerDeserializerTest.php
Dylan K. Taylor d17032dd8c
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.
2022-05-12 16:45:44 +01:00

28 lines
915 B
PHP

<?php
declare(strict_types=1);
namespace pocketmine\data\bedrock\blockstate\convert;
use PHPUnit\Framework\TestCase;
use pocketmine\block\BlockFactory;
final class BlockSerializerDeserializerTest extends TestCase{
private BlockStateToBlockObjectDeserializer $deserializer;
private BlockObjectToBlockStateSerializer $serializer;
public function setUp() : void{
$this->deserializer = new BlockStateToBlockObjectDeserializer();
$this->serializer = new BlockObjectToBlockStateSerializer();
}
public function testAllKnownBlockStatesSerializableAndDeserializable() : void{
foreach(BlockFactory::getInstance()->getAllKnownStates() as $block){
$blockStateData = $this->serializer->serializeBlock($block);
$newBlock = $this->deserializer->deserializeBlock($blockStateData);
self::assertSame($block->getFullId(), $newBlock->getFullId(), "Mismatch of blockstate for " . $block->getName());
}
}
}