mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-18 17:34:11 +00:00
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.
28 lines
915 B
PHP
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());
|
|
}
|
|
}
|
|
}
|