/** * @test */ public function gettersShouldReturnTheAttributeValue() { $this->assertAttributeEquals($this->item->getId(), 'id', $this->item); $this->assertAttributeEquals($this->item->getDescription(), 'description', $this->item); $this->assertAttributeEquals($this->item->getAmount(), 'amount', $this->item); $this->assertAttributeEquals($this->item->getQuantity(), 'quantity', $this->item); $this->assertAttributeEquals($this->item->getShippingCost(), 'shippingCost', $this->item); $this->assertAttributeEquals($this->item->getWeight(), 'weight', $this->item); }
public function testNewItem() { $type = "test type"; $name = "test name"; $number = "test number"; $quantity = "test quantity"; $item = new Item($type, $name, $number, $quantity); $this->assertEquals($name, $item->getName()); $this->assertEquals($number, $item->getNumber()); $this->assertEquals($type, $item->getType()); $this->assertEquals($quantity, $item->getQuantity()); }
public function addItem(Item $item) { if (null === $this->items) { $this->items = array(); } $sku = $item->getSku(); if (array_key_exists($sku, $this->items)) { $quantity = $this->items[$sku]->getQuantity() + $item->getQuantity(); $this->items[$sku]->setQuantity($quantity); } else { $this->items[$sku] = $item; } }
break; case "getItemByNameWithPrice": $item = new Item(); print json_encode($item->getItemByNameWithPrice($_POST["idcustomer"], $_POST["name"])); break; case "getItemLowestCost": $item = new Item(); print $item->getLowestCost($_POST["iditem"]); break; case "getItemPrice": $item = new Item(); print $item->getPrice($_POST["idPriceList"], $_POST["iditem"]); break; case "getItemQuantity": $item = new Item(); print $item->getQuantity($_POST["iditem"]); break; case "saveInventory": $item = new Item(); $max = $_POST["max"]; $items = array(); for ($i = 0; $i <= $max; $i++) { if (isset($_POST["hidItem" . $i]) && $_POST["hidItem" . $i] != "") { //shouldn't be empty $items[] = array("iditem" => $_POST["hidItem" . $i], "itemName" => $_POST["txtItem" . $i], "system" => $_POST["hidSystem" . $i], "manual" => $_POST["txtManual" . $i], "virtualStock" => $_POST["virtualStock" . $i]); } } $response = $item->saveInventory($items); if ($response == "true") { header("Location: ../view/inventoryReconciliation.php?msg=The inventory was saved"); } else {