ItemFactory: Check the bounds of durability, instead of trying to catch exceptions

This commit is contained in:
Dylan K. Taylor
2021-04-16 21:30:48 +01:00
parent da51f106de
commit 01c3668375
2 changed files with 8 additions and 4 deletions

View File

@ -48,4 +48,9 @@ class ItemFactoryTest extends TestCase{
/** @var Sword $i2 */
self::assertSame(1, $i2->getDamage());
}
public function testGetDurableItemWithTooLargeDurability() : void{
self::assertInstanceOf(Sword::class, ItemFactory::getInstance()->get(ItemIds::WOODEN_SWORD, ToolTier::WOOD()->getMaxDurability()));
self::assertInstanceOf(Item::class, ItemFactory::getInstance()->get(ItemIds::WOODEN_SWORD, ToolTier::WOOD()->getMaxDurability() + 1));
}
}