/** * Test Getting Valid Movement By MovementId **/ public function testGetValidMovementByMovementId() { // 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/?movementId=' . $newMovement->getMovementId()); $this->assertSame($response->getStatusCode(), 200); $body = $response->getBody(); $movement = json_decode($body); $this->assertSame(200, $movement->status); }
/** * test inserting and grabbing a Movement with a null movementDate **/ public function testInsertValidMovementWithNullMovementDate() { // 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, null, $this->VALID_movementType, $this->VALID_price); $movement->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoMovement = Movement::getMovementByMovementId($this->getPDO(), $movement->getMovementId()); $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("movement")); $this->assertSame($pdoMovement->getFromLocationId(), $this->fromLocation->getLocationId()); $this->assertSame($pdoMovement->getToLocationId(), $this->toLocation->getLocationId()); $this->assertSame($pdoMovement->getProductId(), $this->product->getProductId()); $this->assertSame($pdoMovement->getUnitId(), $this->unitOfMeasure->getUnitId()); $this->assertSame($pdoMovement->getUserId(), $this->user->getUserId()); $this->assertSame($pdoMovement->getCost(), $this->VALID_cost); $this->assertInstanceOf('DateTime', $pdoMovement->getMovementDate()); $this->assertSame($pdoMovement->getMovementType(), $this->VALID_movementType); $this->assertSame($pdoMovement->getPrice(), $this->VALID_price); }