mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Replace usages of ItemFactory in tests with VanillaItems
This commit is contained in:
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\item;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\item\enchantment\EnchantmentInstance;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
|
||||
@ -33,14 +34,14 @@ class ItemTest extends TestCase{
|
||||
private $item;
|
||||
|
||||
public function setUp() : void{
|
||||
$this->item = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD);
|
||||
$this->item = VanillaItems::DIAMOND_SWORD();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for issue #1145 (items aren't considered equal after NBT serializing and deserializing
|
||||
*/
|
||||
public function testItemEquals() : void{
|
||||
$item = ItemFactory::getInstance()->get(ItemIds::STONE)->setCustomName("HI");
|
||||
$item = VanillaBlocks::STONE()->asItem()->setCustomName("HI");
|
||||
$item2 = Item::nbtDeserialize($item->nbtSerialize());
|
||||
self::assertTrue($item2->equals($item));
|
||||
self::assertTrue($item->equals($item2));
|
||||
@ -50,7 +51,7 @@ class ItemTest extends TestCase{
|
||||
* Test that same items without NBT are considered equal
|
||||
*/
|
||||
public function testItemEqualsNoNbt() : void{
|
||||
$item1 = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD);
|
||||
$item1 = VanillaItems::DIAMOND_SWORD();
|
||||
$item2 = clone $item1;
|
||||
self::assertTrue($item1->equals($item2));
|
||||
}
|
||||
@ -62,7 +63,7 @@ class ItemTest extends TestCase{
|
||||
public function testItemPersistsDisplayProperties() : void{
|
||||
$lore = ["Line A", "Line B"];
|
||||
$name = "HI";
|
||||
$item = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD);
|
||||
$item = VanillaItems::DIAMOND_SWORD();
|
||||
$item->setCustomName($name);
|
||||
$item->setLore($lore);
|
||||
$item = Item::nbtDeserialize($item->nbtSerialize());
|
||||
|
Reference in New Issue
Block a user