本文整理匯總了PHP中Inventory::addItem方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inventory::addItem方法的具體用法?PHP Inventory::addItem怎麽用?PHP Inventory::addItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inventory
的用法示例。
在下文中一共展示了Inventory::addItem方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAddItem
/** @depends testConstruct
* @depends testConstructItem */
public function testAddItem()
{
$inv = new Inventory(1000, 1);
$inv->addItem(new InventoryItem(1000, "abc", null, 1, 2, 3, 4, 10));
$this->assertEquals(1, count($inv->items));
$item = $inv->items[0];
$this->assertEquals("abc", $item->productId);
$this->assertEquals(null, $item->attrSetInstId);
$this->assertEquals(1, $item->qty);
$this->assertEquals(2, $item->lostQty);
$this->assertEquals(3, $item->defectQty);
$this->assertEquals(4, $item->missingQty);
$this->assertEquals(10, $item->unitValue);
}
示例2: testCreateGuessMissingNoStock
/** @depends testCreateFull */
public function testCreateGuessMissingNoStock()
{
$item = new InventoryItem(null, $this->products[0]->id, null, 1, 2, 3, null, 5);
$inv = new Inventory(stdtimefstr("2001-01-01 00:00:00"), $this->locations[0]->id);
$inv->addItem($item);
$srv = new InventoriesService();
$id = $srv->create($inv);
$this->assertNotEquals(false, $id, "Creation failed");
$pdo = PDOBuilder::getPDO();
$stmt = $pdo->prepare("SELECT * FROM STOCK_INVENTORYITEM");
$this->assertNotEquals(false, $stmt->execute(), "Query failed");
if ($row = $stmt->fetch()) {
$this->assertEquals(0, $row["MISSINGQTY"]);
$this->markTestIncomplete("Check unit value");
} else {
$this->assertTrue(false, "No inventory item found after creation");
}
}
示例3: testRemoveItem
/**
* @covers rvilbrandt\gamebook\Model\Gamebook\Inventory::removeItem
*/
public function testRemoveItem()
{
$this->object->addItem("test", new Inventory\Item());
$this->assertNull($this->object->removeItem("test"));
$this->assertFalse($this->object->hasItem("test"));
}