/** * SchedulePIREPTest::testPIREPRejected() * * @return void */ public function testPIREPRejected() { $this->resetPilot(); $sched = $this->findSchedule(); Config::Set('PIREP_CHECK_DUPLICATE', false); Config::Set('EMAIL_SEND_PIREP', false); # Update this schedule to only pay per-hour SchedulesData::editScheduleFields($sched->id, array('payforflight' => 0)); $sched = $this->findSchedule(); $this->assertEquals(0, $sched->payforflight, 'Pay per-flight set to 0'); $pirep_test = array('pilotid' => $this->samplePilotID, 'code' => $sched->code, 'flightnum' => $sched->flightnum, 'route' => $sched->route, 'depicao' => $sched->depicao, 'arricao' => $sched->arricao, 'aircraft' => $sched->aircraft, 'flighttime' => $sched->flighttime, 'submitdate' => 'NOW()', 'fuelused' => 6000, 'source' => 'unittest', 'comment' => 'Test Flight'); # Update Pilot Pay to be set to zero PilotData::updateProfile($this->samplePilotID, array('totalpay' => 0)); $pilot_data = PilotData::getPilotData($this->samplePilotID); $this->assertEquals($pilot_data->totalpay, 0, 'Reset Pilot Pay to 0'); # File the flight report $pirepid = PIREPData::fileReport($pirep_test); $this->assertGreaterThan(0, $pirepid, PIREPData::$lasterror); $pirepdata = PIREPData::findPIREPS(array('p.pirepid' => $pirepid)); $this->assertGreaterThan(0, count($pirepdata), 'No PIREPs returned'); # Work on one... $pirepdata = $pirepdata[0]; # Verify the little bits of this PIREP.... $this->assertEquals(PILOT_PAY_HOURLY, $pirepdata->paytype, 'PIREP Pay Type'); $this->assertEquals($pilot_data->payrate, $pirepdata->pilotpay, 'PIREP Pay Amount'); # Check the pilot pay $pilot_data = PilotData::getPilotData($this->samplePilotID); $this->assertEquals(0, $pilot_data->totalpay, 'Check pilot pay after PIREP FILE'); # Reject the PIREP and then check the pilot pay $status = PIREPData::changePIREPStatus($pirepdata->pirepid, PIREP_REJECTED); $pirepdata = PIREPData::findPIREPS(array('p.pirepid' => $pirepid)); $this->assertEquals(PIREP_REJECTED, $pirepdata[0]->accepted, 'changePIREPStatus to ACCEPTED'); $pirepdata = $pirepdata[0]; # Check the schedule flown count: $post_accept = $this->findSchedule(); $this->assertEquals($sched->timesflown, $post_accept->timesflown, "Schedule increment count"); $post_pilot_data = PilotData::getPilotData($this->samplePilotID); $this->assertEquals(0, $post_pilot_data->totalpay, 'Check pilot pay after PIREP REJECT'); $this->assertEquals($pilot_data->totalflights, $post_pilot_data->totalflights, 'Total Flights'); # Delete the PIREP PIREPData::deletePIREP($pirepid); # Verify delete $data = PIREPData::findPIREPS(array('p.pirepid' => $pirepid)); $this->assertEmpty($data, 'PIREPDdata::deletePIREP()'); }