/**
  * Test Posting Valid Movement
  **/
 public function testPostValidMovement()
 {
     // create a new Movement
     $newMovement = new Movement(null, $this->fromLocation->getLocationId(), $this->toLocation->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $this->user->getUserId(), $this->VALID_cost, $this->VALID_movementDate, $this->VALID_movementType, $this->VALID_price);
     // run a get request to establish session tokens
     $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/movement/?page=0');
     // grab the data from guzzle and enforce the status' match our expectations
     $response = $this->guzzle->post('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/movement/', ['headers' => ['X-XSRF-TOKEN' => $this->getXsrfToken()], 'json' => $newMovement]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $movement = json_decode($body);
     $this->assertSame(200, $movement->status);
 }
 /**
  * Test grabbing Valid UnitOfMeasure by productId
  **/
 public function testGetValidUnitOfMeasureByProductId()
 {
     // create a new Product
     $newProduct = new Product(null, $this->vendor->getVendorId(), $this->VALID_description, $this->VALID_leadTime, $this->VALID_sku, $this->VALID_title);
     $newProduct->insert($this->getPDO());
     // create a new ProductLocation
     $quantity = 1.5;
     $newProductLocation = new ProductLocation($this->location->getLocationId(), $newProduct->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity);
     $newProductLocation->insert($this->getPDO());
     // grab the data from guzzle
     $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/product/?productId=' . $newProduct->getProductId() . "&getUnitOfMeasure=true");
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $product = json_decode($body);
     $this->assertSame(200, $product->status);
 }
 /**
  * test grabbing a ProductLocation by productId
  **/
 public function testGetValidProductLocationByProductId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("productLocation");
     // create a new ProductLocation and insert to into mySQL
     $productLocation = new ProductLocation($this->location->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $this->VALID_quantity);
     $productLocation->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProductLocation = ProductLocation::getProductLocationByProductId($this->getPDO(), $this->product->getProductId());
     foreach ($pdoProductLocation as $pdoPL) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("productLocation"));
         $this->assertSame($pdoPL->getLocationId(), $this->location->getLocationId());
         $this->assertSame($pdoPL->getUnitId(), $this->unitOfMeasure->getUnitId());
         $this->assertSame($pdoPL->getQuantity(), $this->VALID_quantity);
     }
 }
 /**
  * test grabbing a Movement by movementType
  **/
 public function testGetValidAllMovements()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("movement");
     // create a new Movement and insert to into mySQL
     $movement = new Movement(null, $this->fromLocation->getLocationId(), $this->toLocation->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $this->user->getUserId(), $this->VALID_cost, $this->VALID_movementDate, $this->VALID_movementType, $this->VALID_price);
     $movement->insert($this->getPDO());
     $page = 1;
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoMovement = Movement::getAllMovements($this->getPDO(), $page);
     foreach ($pdoMovement as $pdoM) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("movement"));
         $this->assertSame($pdoM->getFromLocationId(), $this->fromLocation->getLocationId());
         $this->assertSame($pdoM->getToLocationId(), $this->toLocation->getLocationId());
         $this->assertSame($pdoM->getProductId(), $this->product->getProductId());
         $this->assertSame($pdoM->getUnitId(), $this->unitOfMeasure->getUnitId());
         $this->assertSame($pdoM->getUserId(), $this->user->getUserId());
         $this->assertSame($pdoM->getCost(), $this->VALID_cost);
         $this->assertEquals($pdoM->getMovementDate(), $this->VALID_movementDate);
         $this->assertSame($pdoM->getMovementType(), $this->VALID_movementType);
         $this->assertSame($pdoM->getPrice(), $this->VALID_price);
     }
 }
 /**
  * test ability to Put valid location
  **/
 public function testPutValidLocation()
 {
     // create a new Location
     $newLocation = new Location(null, $this->VALID_storageCode, $this->VALID_description);
     $newLocation->insert($this->getPDO());
     // run a get request to establish session tokens
     $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/location/');
     // 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/location/' . $newLocation->getLocationId(), ['headers' => ['X-XSRF-TOKEN' => $this->getXsrfToken()], 'json' => $newLocation]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $location = json_decode($body);
     $this->assertSame(200, $location->status);
 }
Beispiel #6
0
 private function history()
 {
     $current_location = new Location($this->getLocationId());
     $current_location->build();
     db_insert('location_history')->fields(array('locationid' => $current_location->getLocationId(), 'name' => $current_location->getName(), 'address' => $current_location->getAddress(), 'address2' => $current_location->getAddress2(), 'city' => $current_location->getCity(), 'state' => $current_location->getState(), 'zip' => $current_location->getZip(), 'saved_userid' => $current_location->getSavedUserID(), 'saved_datetime' => $current_location->getSavedDateTime(), 'history_userid' => $this->getSavedUserID(), 'history_datetime' => $this->getSavedDateTime()))->execute();
 }
 /**
  * test grabbing location by productId
  **/
 public function testGetValidProductByLocationId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("location");
     // create a new location and insert to into mySQL
     $location = new Location(null, $this->VALID_storageCode, $this->VALID_description);
     $location->insert($this->getPDO());
     $quantity = 5.9;
     // create a new location and insert to into mySQL
     $productLocation = new productLocation($location->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity);
     $productLocation->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProductArray = Location::getProductByLocationId($this->getPDO(), $location->getLocationId());
     for ($i = 0; $i < count($pdoProductArray); $i++) {
         if ($i === 0) {
             $this->assertSame($pdoProductArray[$i]->getStorageCode(), $this->VALID_storageCode);
             $this->assertSame($pdoProductArray[$i]->getDescription(), $this->VALID_description);
         } else {
             $this->assertSame($pdoProductArray[$i]->getProductId(), $this->product->getProductId());
             $this->assertSame($pdoProductArray[$i]->getVendorId(), $this->product->getVendorId());
             $this->assertSame($pdoProductArray[$i]->getDescription(), $this->product->getDescription());
             $this->assertSame($pdoProductArray[$i]->getSku(), $this->product->getSku());
             $this->assertSame($pdoProductArray[$i]->getTitle(), $this->product->getTitle());
         }
     }
 }
 /**
  * test grabbing unit of measure by the product id
  **/
 public function testGetValidUnitOfMeasurementByProductId()
 {
     // create a new product and insert to into mySQL
     $product = new Product(null, $this->vendor->getVendorId(), $this->VALID_description, $this->VALID_leadTime, $this->VALID_sku, $this->VALID_title);
     $product->insert($this->getPDO());
     $quantity = 5.9;
     // create a new product and insert to into mySQL
     $productLocation = new ProductLocation($this->location->getLocationId(), $product->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity);
     $productLocation->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoUnitOfMeasureArray = Product::getUnitOfMeasureByProductId($this->getPDO(), $product->getProductId());
     for ($i = 0; $i < count($pdoUnitOfMeasureArray); $i++) {
         if ($i === 0) {
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getVendorId(), $this->vendor->getVendorId());
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getDescription(), $this->VALID_description);
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getLeadTime(), $this->VALID_leadTime);
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getSku(), $this->VALID_sku);
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getTitle(), $this->VALID_title);
         } else {
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getUnitId(), $this->unitOfMeasure->getUnitId());
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getUnitCode(), $this->unitOfMeasure->getUnitCode());
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getQuantity(), $this->unitOfMeasure->getQuantity());
         }
     }
 }
 public function update(Location $loc)
 {
     $query = "UPDATE `location` SET `location_name`='" . $loc->getLocationName() . "',`location_city`='" . $loc->getLocationCity() . "',`longitude`='" . $loc->getLongitude() . "',`latitude`='" . $loc->getLatitude() . "',`altitude`='" . $loc->getAltitude() . "' WHERE `idlocation`='" . $loc->getLocationId() . "'";
     $this->con->openConnection();
     $this->con->executeRawQuery($query);
     $this->con->closeConnection();
 }