mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Tests: verify that ItemTypeIds/BlockTypeIds constants match their corresponding VanillaItems/VanillaBlocks registrations
This commit is contained in:
parent
64c1776910
commit
ab8386ed5a
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_unique;
|
||||
use function max;
|
||||
|
||||
@ -43,4 +44,14 @@ class BlockTypeIdsTest extends TestCase{
|
||||
|
||||
self::assertSameSize($idTable, array_unique($idTable), "Every BlockTypeID must be unique");
|
||||
}
|
||||
|
||||
public function testVanillaBlocksParity() : void{
|
||||
$reflect = new \ReflectionClass(BlockTypeIds::class);
|
||||
|
||||
foreach(Utils::stringifyKeys(VanillaBlocks::getAll()) as $name => $block){
|
||||
$expected = $block->getTypeId();
|
||||
$actual = $reflect->getConstant($name);
|
||||
self::assertSame($expected, $actual, "VanillaBlocks::$name() does not match BlockTypeIds::$name");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\item;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_unique;
|
||||
use function max;
|
||||
|
||||
@ -43,4 +44,17 @@ class ItemTypeIdsTest extends TestCase{
|
||||
|
||||
self::assertSameSize($idTable, array_unique($idTable), "Every ItemTypeID must be unique");
|
||||
}
|
||||
|
||||
public function testVanillaItemsParity() : void{
|
||||
$reflect = new \ReflectionClass(ItemTypeIds::class);
|
||||
|
||||
foreach(Utils::stringifyKeys(VanillaItems::getAll()) as $name => $item){
|
||||
if($item instanceof ItemBlock){
|
||||
continue;
|
||||
}
|
||||
$expected = $item->getTypeId();
|
||||
$actual = $reflect->getConstant($name);
|
||||
self::assertSame($expected, $actual, "VanillaItems::$name() type ID does not match ItemTypeIds::$name");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user