mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
LegacyStringToItemParserTest: do not rely on the presence of legacy ID and meta in the API
This commit is contained in:
parent
cab56b0479
commit
f8547ad57c
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user