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();
     $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]);
     $this->VALID_notificationDateTime = DateTime::createFromFormat("Y-m-d H:i:s", "2015-09-26 08:45:25");
     $this->INVALID_notificationDateTime = DateTime::createFromFormat("Y-m-d H:i:s", "2015-14-26 06:25:25");
     $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());
     $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());
     $alertId1 = $this->alertLevel->getAlertId();
     $productId1 = $this->product->getProductId();
     $alertEnabled = true;
     $this->productAlert = new ProductAlert($alertId1, $productId1, $alertEnabled);
     $this->productAlert->insert($this->getPDO());
 }
Пример #3
0
 /**
  * create dependent objects before running each test
  **/
 public 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 = "1985-06-28 04:26:03";
     $notificationHandle = "unit test";
     $notificationContent = "place holder";
     $this->notification = new Notification($notificationId, $alertId, $emailStatus, $notificationDateTime, $notificationHandle, $notificationContent);
     $this->notification->insert($this->getPDO());
 }
 /**
  * test ability to Put valid AlertLevel
  **/
 public function testPutValidAlertLevel()
 {
     // create a new AlertLevel
     $newAlertLevel = new AlertLevel(null, $this->VALID_alertCode, $this->VALID_alertFrequency, $this->VALID_alertPoint, $this->VALID_alertOperator);
     $newAlertLevel->insert($this->getPDO());
     // run a get request to establish session tokens
     $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/alert-level/');
     // 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/alert-level/' . $newAlertLevel->getAlertId(), ['headers' => ['X-XSRF-TOKEN' => $this->getXsrfToken()], 'json' => $newAlertLevel]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $alertLevel = json_decode($body);
     $this->assertSame(200, $alertLevel->status);
 }
Пример #5
0
     } else {
         if (empty($alertCode) === false) {
             $reply->data = AlertLevel::getAlertLevelByAlertCode($pdo, $alertCode)->toArray();
         } else {
             $reply->data = AlertLevel::getAllAlertLevels($pdo)->toArray();
         }
     }
     // post a new AlertLevel
 } else {
     if ($method === "POST") {
         // convert POSTed JSON to an object
         verifyXsrf();
         $requestContent = file_get_contents("php://input");
         $requestObject = json_decode($requestContent);
         $alertLevel = new AlertLevel($alertId, $requestObject->alertCode, $requestObject->alertFrequency, $requestObject->alertPoint, $requestObject->alertOperator);
         $alertLevel->insert($pdo);
         $reply->data = "AlertLevel created OK";
         // delete an existing AlertLevel
     } else {
         if ($method === "DELETE") {
             verifyXsrf();
             $alertLevel = AlertLevel::getAlertLevelByAlertId($pdo, $alertId);
             $alertLevel->delete($pdo);
             $reply->data = "AlertLevel deleted OK";
             // put to an existing AlertLevel
         } else {
             if ($method === "PUT") {
                 // convert PUTed JSON to an object
                 verifyXsrf();
                 $requestContent = file_get_contents("php://input");
                 $requestObject = json_decode($requestContent);
Пример #6
0
 /**
  * test grabbing all AlertLevels
  **/
 public function testGetValidAllAlertLevels()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("alertLevel");
     // create a new alert level 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());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoAlertLevel = AlertLevel::getAllAlertLevels($this->getPDO());
     foreach ($pdoAlertLevel as $al) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("alertLevel"));
         $this->assertSame($al->getAlertCode(), $this->VALID_alertCode);
         $this->assertSame($al->getAlertFrequency(), $this->VALID_alertFrequency);
         $this->assertSame($al->getAlertPoint(), $this->VALID_alertPoint);
         $this->assertSame($al->getAlertOperator(), $this->VALID_alertOperator);
     }
 }