예제 #1
0
 /** @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);
 }
 /** @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
0
 /**
  * @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"));
 }