/**
  * test grabbing a Product by alertId
  **/
 public function testGetValidProductByAlertId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("alertLevel");
     // create a new alertLevel and insert to into mySQL
     $alertLevel = new AlertLevel(null, $this->VALID_alertCode, $this->VALID_alertFrequency, $this->VALID_alertPoint, $this->VALID_alertOperator);
     $alertLevel->insert($this->getPDO());
     // create a new productAlert and insert to into mySQL
     $productAlert = new productAlert($alertLevel->getAlertId(), $this->product->getProductId(), true);
     $productAlert->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProductArray = AlertLevel::getProductByAlertId($this->getPDO(), $alertLevel->getAlertId());
     for ($i = 0; $i < count($pdoProductArray); $i++) {
         if ($i === 0) {
             $this->assertSame($pdoProductArray[$i]->getAlertCode(), $this->VALID_alertCode);
             $this->assertSame($pdoProductArray[$i]->getAlertFrequency(), $this->VALID_alertFrequency);
             $this->assertSame($pdoProductArray[$i]->getAlertPoint(), $this->VALID_alertPoint);
             $this->assertSame($pdoProductArray[$i]->getAlertOperator(), $this->VALID_alertOperator);
         } 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 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 a Product by vendorId
  **/
 public function testGetValidProductByVendorId()
 {
     // 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());
     // grab the data from guzzle and enforce the status' match our expectations
     $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/product/?vendorId=' . $newProduct->getVendorId());
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     //		echo $body . PHP_EOL;
     $product = json_decode($body);
     $this->assertSame(200, $product->status);
 }
 /**
  * test grabbing an product by alert Id
  **/
 public function testGetValidNotificationsByAlertId()
 {
     // create a new notification and insert to into mySQL
     $notification = new Notification(null, $this->alertLevel->getAlertId(), $this->VALID_emailStatus, $this->VALID_notificationDateTime, $this->VALID_notificationHandle, $this->VALID_notificationContent);
     $notification->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProductArray = Notification::getProductByAlertId($this->getPDO(), $notification->getAlertId());
     for ($i = 0; $i < count($pdoProductArray); $i++) {
         if ($i === 0) {
             $this->assertSame($pdoProductArray[$i]->getAlertId(), $this->alertLevel->getAlertId());
             $this->assertSame($pdoProductArray[$i]->getEmailStatus(), $this->VALID_emailStatus);
             $this->assertEquals($pdoProductArray[$i]->getNotificationDateTime(), $this->VALID_notificationDateTime);
             $this->assertSame($pdoProductArray[$i]->getNotificationHandle(), $this->VALID_notificationHandle);
             $this->assertSame($pdoProductArray[$i]->getNotificationContent(), $this->VALID_notificationContent);
         } 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());
         }
     }
 }
Example #5
0
 /**
  * test grabbing a Product by vendorId
  **/
 public function testGetValidProductByVendorId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("product");
     // 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());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProducts = Product::getProductByVendorId($this->getPDO(), $product->getVendorId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("product"));
     foreach ($pdoProducts as $pdoProduct) {
         $this->assertSame($pdoProduct->getVendorId(), $this->vendor->getVendorId());
         $this->assertSame($pdoProduct->getDescription(), $this->VALID_description);
         $this->assertSame($pdoProduct->getLeadTime(), $this->VALID_leadTime);
         $this->assertSame($pdoProduct->getSku(), $this->VALID_sku);
         $this->assertSame($pdoProduct->getTitle(), $this->VALID_title);
     }
 }