LegacyStringToItemParserTest: do not rely on the presence of legacy ID and meta in the API

This commit is contained in:
Dylan K. Taylor 2022-06-30 16:39:50 +01:00
parent cab56b0479
commit f8547ad57c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -24,31 +24,31 @@ declare(strict_types=1);
namespace pocketmine\item;
use PHPUnit\Framework\TestCase;
use pocketmine\block\VanillaBlocks;
class LegacyStringToItemParserTest extends TestCase{
/**
* @return mixed[][]
* @phpstan-return list<array{string,int,int}>
* @phpstan-return list<array{string,Item}>
*/
public function itemFromStringProvider() : array{
return [
["dye:4", ItemIds::DYE, 4],
["351", ItemIds::DYE, 0],
["351:4", ItemIds::DYE, 4],
["stone:3", ItemIds::STONE, 3],
["minecraft:string", ItemIds::STRING, 0],
["diamond_pickaxe", ItemIds::DIAMOND_PICKAXE, 0]
["dye:4", VanillaItems::LAPIS_LAZULI()],
["351", VanillaItems::INK_SAC()],
["351:4", VanillaItems::LAPIS_LAZULI()],
["stone:3", VanillaBlocks::DIORITE()->asItem()],
["minecraft:string", VanillaItems::STRING()],
["diamond_pickaxe", VanillaItems::DIAMOND_PICKAXE()]
];
}
/**
* @dataProvider itemFromStringProvider
*/
public function testFromStringSingle(string $string, int $id, int $meta) : void{
public function testFromStringSingle(string $string, Item $expected) : void{
$item = LegacyStringToItemParser::getInstance()->parse($string);
self::assertEquals($id, $item->getId());
self::assertEquals($meta, $item->getMeta());
self::assertTrue($item->equals($expected));
}
}