Пример #1
0
 function testBuildUserNote()
 {
     $this->startCodeCoverage();
     $buildusernote = new BuildUserNote();
     $buildusernote->BuildId = 0;
     ob_start();
     $result = $buildusernote->Insert();
     $output = ob_get_contents();
     ob_end_clean();
     if ($result) {
         $this->fail("Insert() should return false when BuildId is 0");
         return 1;
     }
     if (strpos($output, "BuildUserNote::Insert(): BuildId is not set") === false) {
         $this->fail("'BuildId is not set' not found from Insert()");
         return 1;
     }
     $buildusernote->BuildId = 1;
     $buildusernote->UserId = 0;
     ob_start();
     $result = $buildusernote->Insert();
     $output = ob_get_contents();
     ob_end_clean();
     if ($result) {
         $this->fail("Insert() should return false when UserId is 0");
         return 1;
     }
     if (strpos($output, "BuildUserNote::Insert(): UserId is not set") === false) {
         $this->fail("'UserId is not set' not found from Insert()");
         return 1;
     }
     $buildusernote->UserId = 1;
     if ($buildusernote->Insert()) {
         $this->fail("Insert() should return false but returned true");
         return 1;
     }
     $buildusernote->Note = 'test';
     if ($buildusernote->Insert()) {
         $this->fail("Insert() should return false but returned true");
         return 1;
     }
     $buildusernote->TimeStamp = '2010-10-10 10:10:10';
     if ($buildusernote->Insert()) {
         $this->fail("Insert() should return false but returned true");
         return 1;
     }
     $buildusernote->Status = 1;
     if (!$buildusernote->Insert()) {
         $this->fail("Insert() returned false when it should be true.\n");
         return 1;
     }
     $this->pass("Passed");
     $this->stopCodeCoverage();
     return 0;
 }
Пример #2
0
 public function testBuildUserNote()
 {
     $this->startCodeCoverage();
     $buildusernote = new BuildUserNote();
     $result = $buildusernote->Insert();
     if ($result) {
         $this->fail('Insert() should return false when BuildId is 0');
         return 1;
     }
     $log_contents = file_get_contents($this->logfilename);
     if (strpos($log_contents, 'BuildId is not set') === false) {
         $this->fail("'BuildId is not set' not found from Insert()");
         return 1;
     }
     $buildusernote->BuildId = 1;
     $result = $buildusernote->Insert();
     if ($result) {
         $this->fail('Insert() should return false when UserId is 0');
         return 1;
     }
     $log_contents = file_get_contents($this->logfilename);
     if (strpos($log_contents, 'UserId is not set') === false) {
         $this->fail("'UserId is not set' not found from Insert()");
         return 1;
     }
     $buildusernote->UserId = 1;
     if ($buildusernote->Insert()) {
         $this->fail('Insert() should return false but returned true');
         return 1;
     }
     $buildusernote->Note = 'test';
     if ($buildusernote->Insert()) {
         $this->fail('Insert() should return false but returned true');
         return 1;
     }
     $buildusernote->TimeStamp = '2010-10-10 10:10:10';
     if ($buildusernote->Insert()) {
         $this->fail('Insert() should return false but returned true');
         return 1;
     }
     $buildusernote->Status = 1;
     if (!$buildusernote->Insert()) {
         $this->fail("Insert() returned false when it should be true.\n");
         return 1;
     }
 }
Пример #3
0
    http_response_code(401);
    return;
}
// Check that all of our required parameters were specified.
if (!isset($_REQUEST['buildid']) || !is_numeric($_REQUEST['buildid'])) {
    $response['error'] = 'Build lookup error';
    echo json_encode($response);
    http_response_code(400);
    return;
}
$buildid = $_REQUEST['buildid'];
if (!isset($_REQUEST['AddNote']) || !isset($_REQUEST['Status']) || strlen($_REQUEST['AddNote']) < 1 || strlen($_REQUEST['Status']) < 1) {
    $response['error'] = 'No note specified';
    echo json_encode($response);
    http_response_code(400);
    return;
}
// Add the note.
$userNote = new BuildUserNote();
$userNote->BuildId = $buildid;
$userNote->UserId = $userid;
$userNote->Note = $_REQUEST['AddNote'];
$userNote->Status = $_REQUEST['Status'];
$userNote->TimeStamp = gmdate(FMT_DATETIME);
if (!$userNote->Insert()) {
    $response['error'] = 'Error adding note';
    echo json_encode($response);
    http_response_code(400);
}
$response['note'] = $userNote->marshal();
echo json_encode(cast_data_for_JSON($response));