/**
  * Set up to create vendor, product, unitOfMeasure objects
  *
  **/
 public function setUp()
 {
     parent::setUp();
     $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]);
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
     $unitId = null;
     $quantity = 3.5;
     $unitCode = "ea";
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
 }
 public function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $name = "TruFork";
     $contactName = "Trevor Rigler";
     $email = "*****@*****.**";
     $phoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $name, $contactName, $email, $phoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bracelet for any occasion to use";
     $leadTime = 15;
     $sku = "457847";
     $title = "Bracelet-Green-Blue";
     $this->finishedProduct = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->finishedProduct->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "354";
     $title = "Bead-Green-Blue-Circular";
     $this->rawMaterial = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->rawMaterial->insert($this->getPDO());
 }
 public function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
     $locationId = null;
     $description = "Back Stock";
     $storageCode = 7;
     $this->location = new Location($locationId, $storageCode, $description);
     $this->location->insert($this->getPDO());
     $unitId = null;
     $unitCode = "pk";
     $quantity = 10.5;
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
 }
 public function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
     $alertId = null;
     $alertCode = "WM";
     $alertFrequency = "D2";
     $alertOperator = "L";
     $alertPoint = 100.514;
     $this->alertLevel = new AlertLevel($alertId, $alertCode, $alertFrequency, $alertPoint, $alertOperator);
     $this->alertLevel->insert($this->getPDO());
 }
 public function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
 }
示例#6
0
     } else {
         if (empty($vendorName) === false) {
             $reply->data = Vendor::getVendorByVendorName($pdo, $vendorName)->toArray();
         } else {
             $reply->data = Vendor::getAllVendors($pdo)->toArray();
         }
     }
     // post to a new Vendor
 } else {
     if ($method === "POST") {
         // convert POSTed JSON to an object
         verifyXsrf();
         $requestContent = file_get_contents("php://input");
         $requestObject = json_decode($requestContent);
         $vendor = new Vendor(null, $requestObject->contactName, $requestObject->vendorEmail, $requestObject->vendorName, $requestObject->vendorPhoneNumber);
         $vendor->insert($pdo);
         $reply->data = "Vendor created OK";
         // delete an existing Vendor
     } else {
         if ($method === "DELETE") {
             verifyXsrf();
             $vendor = Vendor::getVendorByVendorId($pdo, $vendorId);
             $vendor->delete($pdo);
             $reply->data = "Vendor deleted OK";
             // put to an existing Vendor
         } else {
             if ($method === "PUT") {
                 // convert PUTed JSON to an object
                 verifyXsrf();
                 $requestContent = file_get_contents("php://input");
                 $requestObject = json_decode($requestContent);
示例#7
0
 public function map_products_vendor($vendor_name)
 {
     $security_where = $_SESSION["do_crm_action_permission"]->get_user_where_condition('vendor', 11);
     $qry = "select * from `vendor` where `vendor_name` = ? " . $security_where;
     $stmt = $this->getDbConnection()->executeQuery($qry, array($vendor_name));
     if ($stmt->rowCount() > 0) {
         $data = $stmt->fetch();
         $idvendor = $data["idvendor"];
         return $idvendor;
     } else {
         if (strlen($vendor_name) > 0) {
             $do_vendor = new Vendor();
             $data = array("vendor_name" => CommonUtils::purify_input($vendor_name), "iduser" => $_SESSION["do_user"]->iduser, "added_on" => date("Y-m-d H:i:s"));
             $do_vendor->insert("vendor", $data);
             $idvendor = $do_vendor->getInsertId();
             $do_vendor->insert("vendor_address", array("idvendor" => $idvendor));
             $do_vendor->insert("vendor_custom_fld", array("idvendor" => $idvendor));
             $do_vendor->free();
             $do_data_history = new DataHistory();
             $do_data_history->add_history($idvendor, 11, 'add');
             $do_data_history->free();
             return $idvendor;
         }
     }
 }
 /**
  * Set up for Vendor as well as guzzle/cookies
  **/
 public final function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $this->vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $this->vendor->insert($this->getPDO());
     $locationId = null;
     $description = "Front Stock";
     $storageCode = 12;
     $this->location = new Location($locationId, $storageCode, $description);
     $this->location->insert($this->getPDO());
     $unitId = null;
     $unitCode = "pk";
     $quantity = 10.5;
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
     $alertCode = "78";
     $alertFrequency = "56";
     $alertPoint = 1.4;
     $alertOperator = "A";
     $this->alertLevel = new AlertLevel(null, $alertCode, $alertFrequency, $alertPoint, $alertOperator);
     $this->alertLevel->insert($this->getPDO());
     $notificationId = null;
     $alertId = $this->alertLevel->getAlertId();
     $emailStatus = false;
     $notificationDateTime = null;
     $notificationHandle = "unit test";
     $notificationContent = "place holder";
     $notificationDateTime = DateTime::createFromFormat("Y-m-d H:i:s", "1985-06-28 04:26:03");
     $this->notification = new Notification($notificationId, $alertId, $emailStatus, $notificationDateTime, $notificationHandle, $notificationContent);
     $this->notification->insert($this->getPDO());
     // create and insert a GuzzleHttp
     $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]);
 }
 /**
  * test ability to Put valid vendor
  **/
 public function testPutValidVendor()
 {
     // create a new vendor
     $newVendor = new Vendor(null, $this->VALID_contactName, $this->VALID_vendorEmail, $this->VALID_vendorName, $this->VALID_vendorPhoneNumber);
     $newVendor->insert($this->getPDO());
     // run a get request to establish session tokens
     $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/vendor/');
     // grab the data from guzzle and enforce the status' match our expectations
     $response = $this->guzzle->put('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/vendor/' . $newVendor->getVendorId(), ['headers' => ['X-XSRF-TOKEN' => $this->getXsrfToken()], 'json' => $newVendor]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $vendor = json_decode($body);
     echo $body . PHP_EOL;
     $this->assertSame(200, $vendor->status);
 }
 public function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
     $alertId = null;
     $alertCode = "33";
     $alertFrequency = "11";
     $alertLevel = "100.01";
     $alertOperator = "1";
     $this->alertLevel = new AlertLevel($alertId, $alertCode, $alertFrequency, $alertLevel, $alertOperator);
     $this->alertLevel->insert($this->getPDO());
     $productEnabled = true;
     $this->productAlert = new ProductAlert($this->alertLevel->getAlertId(), $this->product->getProductId(), $productEnabled);
     $this->productAlert->insert($this->getPDO());
     $this->VALID_notificationDateTime = DateTime::createFromFormat("Y-m-d H:i:s", "1985-06-28 04:26:03");
 }
示例#11
0
 /**
  * test grabbinbg all Vendors
  **/
 public function testGetAllValidVendors()
 {
     //count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("vendor");
     //create a new vendor and insert it into mySQL
     $vendor = new Vendor(null, $this->VALID_contactName, $this->VALID_vendorEmail, $this->VALID_vendorName, $this->VALID_vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoVendor = Vendor::getAllVendors($this->getPDO());
     foreach ($pdoVendor as $ven) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("vendor"));
         $this->assertSame($ven->getContactName(), $this->VALID_contactName);
         $this->assertSame($ven->getVendorEmail(), $this->VALID_vendorEmail);
         $this->assertSame($ven->getVendorName(), $this->VALID_vendorName);
         $this->assertSame($ven->getVendorPhoneNumber(), $this->VALID_vendorPhoneNumber);
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]);
     $this->VALID_movementDate = DateTime::createFromFormat("Y-m-d H:i:s", "2015-09-26 08:45:25");
     $this->INVALID_movementDate = DateTime::createFromFormat("Y-m-d H:i:s", "2015-14-26 06:25:25");
     $userId = null;
     $firstName = "Jim";
     $lastName = "Jim";
     $root = 1;
     $attention = "Urgent: ";
     $addressLineOne = "123 House St.";
     $addressLineTwo = "P.O Box. 9965";
     $city = "Tattoine";
     $state = "AK";
     $zipCode = "52467";
     $email = "*****@*****.**";
     $phoneNumber = "5052253231";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $hash = hash_pbkdf2("sha512", "password1234", $salt, 262144, 128);
     $this->user = new User($userId, $lastName, $firstName, $root, $attention, $addressLineOne, $addressLineTwo, $city, $state, $zipCode, $email, $phoneNumber, $salt, $hash);
     $this->user->insert($this->getPDO());
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
     $locationId = null;
     $description = "Back Stock";
     $storageCode = 13;
     $this->fromLocation = new Location($locationId, $storageCode, $description);
     $this->fromLocation->insert($this->getPDO());
     $locationId = null;
     $description = "Front Stock";
     $storageCode = 12;
     $this->toLocation = new Location($locationId, $storageCode, $description);
     $this->toLocation->insert($this->getPDO());
     $unitId = null;
     $unitCode = "pk";
     $quantity = 10.5;
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
 }