mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 05:15:13 +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;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use pocketmine\block\VanillaBlocks;
|
||||||
|
|
||||||
class LegacyStringToItemParserTest extends TestCase{
|
class LegacyStringToItemParserTest extends TestCase{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
* @phpstan-return list<array{string,int,int}>
|
* @phpstan-return list<array{string,Item}>
|
||||||
*/
|
*/
|
||||||
public function itemFromStringProvider() : array{
|
public function itemFromStringProvider() : array{
|
||||||
return [
|
return [
|
||||||
["dye:4", ItemIds::DYE, 4],
|
["dye:4", VanillaItems::LAPIS_LAZULI()],
|
||||||
["351", ItemIds::DYE, 0],
|
["351", VanillaItems::INK_SAC()],
|
||||||
["351:4", ItemIds::DYE, 4],
|
["351:4", VanillaItems::LAPIS_LAZULI()],
|
||||||
["stone:3", ItemIds::STONE, 3],
|
["stone:3", VanillaBlocks::DIORITE()->asItem()],
|
||||||
["minecraft:string", ItemIds::STRING, 0],
|
["minecraft:string", VanillaItems::STRING()],
|
||||||
["diamond_pickaxe", ItemIds::DIAMOND_PICKAXE, 0]
|
["diamond_pickaxe", VanillaItems::DIAMOND_PICKAXE()]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider itemFromStringProvider
|
* @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);
|
$item = LegacyStringToItemParser::getInstance()->parse($string);
|
||||||
|
|
||||||
self::assertEquals($id, $item->getId());
|
self::assertTrue($item->equals($expected));
|
||||||
self::assertEquals($meta, $item->getMeta());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user