Exemplo n.º 1
0
 /**
  * test when AuditTrail cannot be found with wrong Eid
  */
 function testFindAuditTrailwithEidNotFound()
 {
     //arange
     $AuditTrail = new AuditTrail();
     //act
     $result = $AuditTrail->where('eid', 'badeid')->get();
     //assert
     $this->assertEquals(0, $result->count());
 }
 /**
  * This function retrieves AuditTrails
  *
  * It receives as inputs Smsr-Id (Mandatory), EID (Mandatory) and AuditTrail identifier (Optional)
  * It searches in the audittrail model and retrieves the audittrail requested
  * Smsr-Id, EID and AuditTrail input paramater may include the 'all' wilcard
  * When Audittrail is omitted, it searches all audit trails in the scope of the SMSSRId and Eid.
  * The function returns a HTTP response object. It contains the either the result of the search or an eror code. 
  * 
  * @param string $smsrid
  * @param string $eid
  * @param string $audittrailid
  * @return response
  * 
  */
 public function getAuditTrail($SmsrId, $Eid, $AuditTrailId = null)
 {
     $AuditTrail = new AuditTrail();
     if ($SmsrId == 'all') {
         if ($Eid == 'all') {
             if ($AuditTrailId == null) {
                 //return all Audit Trails in base
                 $Result = $AuditTrail->all();
             } else {
                 //return Audit Trail with id from all smsr and all eis
                 $Result = $AuditTrail->find($AuditTrailId);
             }
         } else {
             if ($AuditTrailId == null) {
                 //return all Audit Trails with id for a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->get();
             } else {
                 //return a specific Audit Trail from a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->find($AuditTrailId);
             }
         }
     } else {
         if ($Eid == 'all') {
             if ($AuditTrailId == null) {
                 //return all Audit Trails in base
                 $Result = $AuditTrail->all();
             } else {
                 //return Audit Trail with id from all smsr and all eis
                 $Result = $AuditTrail->find($AuditTrailId);
             }
         } else {
             if ($AuditTrailId == null) {
                 //return all Audit Trails with id for a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->get();
             } else {
                 //return a specific Audit Trail from a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->find($AuditTrailId);
             }
         }
     }
     return response()->json($Result);
 }