Ejemplo n.º 1
0
 /**
  * Test Getting Valid Movement By ToLocationId
  **/
 public function testGetValidMovementByToLocationId()
 {
     // 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);
     $newMovement->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/movement/?toLocationId=' . $newMovement->getToLocationId());
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $movement = json_decode($body);
     $this->assertSame(200, $movement->status);
 }
Ejemplo n.º 2
0
 /**
  * test grabbing a Movement by fromLocationId & toLocationId
  **/
 public function testGetValidMovementByFromLocationIdAndToLocationId()
 {
     // 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());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoMovement = Movement::getMovementByFromLocationIdAndToLocationId($this->getPDO(), $movement->getFromLocationId(), $movement->getToLocationId());
     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);
     }
 }