| 1 |
<?php
|
| 2 |
// $Id: simpletestauto.inc,v 1.3 2006/08/09 09:41:03 rokZlender Exp $
|
| 3 |
function simpletestauto_test_insert($node) {
|
| 4 |
db_query("INSERT INTO {simpletestauto_test} (nid, project, patch_url, version, tested) VALUES (%d, '%s', '%s', '%s', '%d')", $node->nid, $node->project, $node->patch_url,$node->version, $node->tested);
|
| 5 |
}
|
| 6 |
|
| 7 |
function simpletestauto_test_update($node) {
|
| 8 |
db_query("UPDATE {simpletestauto_test} SET project = '%s', patch_url = '%s', version = '%s', tested = '%d' WHERE nid = %d", $node->project, $node->patch_url, $node->version, $node->tested, $node->nid);
|
| 9 |
}
|
| 10 |
|
| 11 |
function simpletestauto_test_load($node) {
|
| 12 |
$test = db_fetch_object(db_query('SELECT * FROM {simpletestauto_test} WHERE nid = %d', $node->nid));
|
| 13 |
return $test;
|
| 14 |
}
|
| 15 |
|
| 16 |
function simpletestauto_test_delete($node) {
|
| 17 |
db_query('DELETE FROM {simpletestauto_test} WHERE nid = %d', $node->nid);
|
| 18 |
}
|
| 19 |
|
| 20 |
function simpletestauto_test_form(&$node) {
|
| 21 |
$form['title'] = array(
|
| 22 |
'#type' => 'textfield',
|
| 23 |
'#title' => t('Title'),
|
| 24 |
'#required' => TRUE,
|
| 25 |
'#default_value' => $node->title,
|
| 26 |
'#weight' => -5
|
| 27 |
);
|
| 28 |
$form['body_filter']['body'] = array(
|
| 29 |
'#type' => 'textarea',
|
| 30 |
'#title' => t('Body'),
|
| 31 |
'#default_value' => $node->body,
|
| 32 |
'#required' => FALSE
|
| 33 |
);
|
| 34 |
$form['body_filter']['filter'] = filter_form($node->format);
|
| 35 |
|
| 36 |
$form['project'] = array(
|
| 37 |
'#type' => 'textfield',
|
| 38 |
'#title' => t('Test project'),
|
| 39 |
'#default_value' => $node->project,
|
| 40 |
);
|
| 41 |
$form['patch_url'] = array(
|
| 42 |
'#type' => 'textfield',
|
| 43 |
'#title' => t('Patch url'),
|
| 44 |
'#default_value' => $node->patch_url,
|
| 45 |
);
|
| 46 |
$form['version'] = array(
|
| 47 |
'#type' => 'textfield',
|
| 48 |
'#title' => t('Project version'),
|
| 49 |
'#default_value' => $node->version,
|
| 50 |
);
|
| 51 |
|
| 52 |
return $form;
|
| 53 |
}
|
| 54 |
|
| 55 |
/**
|
| 56 |
* Implementation of hook_content().
|
| 57 |
*/
|
| 58 |
function simpletestauto_test_content($node, $teaser = false) {
|
| 59 |
return node_prepare($node, $teaser);
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
| 63 |
* Retunrs all patches that are not tested
|
| 64 |
* @return array of node ids of untested patches
|
| 65 |
*/
|
| 66 |
function get_untested_patches() {
|
| 67 |
$result = db_query("SELECT nid FROM {simpletestauto_test} WHERE tested = 0");
|
| 68 |
$nodes = array();
|
| 69 |
while($patch = db_fetch_object($result)) {
|
| 70 |
$nodes[] = $patch->nid;
|
| 71 |
}
|
| 72 |
return $nodes;
|
| 73 |
}
|
| 74 |
|
| 75 |
function simpletestauto_test_view(&$node, $teaser = false, $page = false) {
|
| 76 |
|
| 77 |
if (!$teaser && $page) {
|
| 78 |
$node = node_prepare($node, $teaser);
|
| 79 |
switch ($node->tested) {
|
| 80 |
case SIMPLETESTAUTO_PASS:
|
| 81 |
$status = t('PASSED');
|
| 82 |
break;
|
| 83 |
case SIMPLETESTAUTO_FAIL:
|
| 84 |
$status = t('FAILED');
|
| 85 |
break;
|
| 86 |
case SIMPLETESTAUTO_NOT_TESTED:
|
| 87 |
$status = t('NOT TESTED');
|
| 88 |
break;
|
| 89 |
case SIMPLETESTAUTO_SUBMITED:
|
| 90 |
$status = t('SUBMITED TO TEST SERVER');
|
| 91 |
break;
|
| 92 |
case SIMPLETESTAUTO_IN_PROGRESS:
|
| 93 |
$status = t('TESTING IN PROGRESS');
|
| 94 |
break;
|
| 95 |
}
|
| 96 |
$node->content['summary'] = array (
|
| 97 |
'#value' => theme('simpletestauto_summary',$node->project, $node->version, $node->patch_url, $status),
|
| 98 |
);
|
| 99 |
}
|
| 100 |
return $node;
|
| 101 |
}
|
| 102 |
|
| 103 |
function theme_simpletestauto_summary($project, $version, $patch_url, $status) {
|
| 104 |
|
| 105 |
$rows = array();
|
| 106 |
$rows[] = array('Project:', check_plain($project));
|
| 107 |
$rows[] = array('Version:', check_plain($version));
|
| 108 |
$rows[] = array(t('Patch url:'), l($patch_url, $patch_url));
|
| 109 |
$rows[] = array(t('Status:'), check_plain($status));
|
| 110 |
$output .= '<div class="summary">'. theme('table', array(), $rows) .'</div>';
|
| 111 |
return $output;
|
| 112 |
}
|
| 113 |
|
| 114 |
?>
|