Update of /cvsroot/dynapi/dynapi3x/test/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10083/scripts

Added Files:
        config.php create_tables.sql displayTest.php editTest.php 
        saveTest.php showResults.php storeResult.php testForm.php 
Log Message:
Initial version

--- NEW FILE ---
<?php

$test_database_server="mysql-d.sourceforge.net";
$test_database_name="dynapi";
$test_database_user="dynapi";
$test_database_password="a58SiNIi";

?>

--- NEW FILE ---
-- 
-- Table structure for table `testresult`
-- 

CREATE TABLE `testresult` (
  `id` int(11) NOT NULL auto_increment,
  `testcase_name` varchar(64) NOT NULL,
  `testcase_date` timestamp NULL default NULL,
  `dynapi_version` varchar(128) default NULL,
  `passed` tinyint(4) default NULL,
  `comments` text,
  `user_agent` varchar(128) default NULL,
  `test_date` timestamp NOT NULL,
  `tester` varchar(64) default NULL,
  PRIMARY KEY  (`id`)
);

--- NEW FILE ---

<head>
<title>DynAPI - Test Suite</title>
</head>

<frameset cols="30%, 70%">
<?php
$name = $_REQUEST['name'];

echo "<frame src=\"testForm.php?";
echo "name=", urlencode($name);
echo "\"/>\n";
echo "<frame src=\"../" . $name . ".html\"/>\n";

?>
</frameset>

--- NEW FILE ---
<html xmlns="http://www.w3.org/1999/xhtml";>
 <head>
  <title>DynAPI - Test Suite</title>
 </head>
<?php
$name = $_REQUEST['name'];
if ($name) {
  $code_filename = "../" . $name . ".html";
  if (file_exists($code_filename))
    $test_code = file_get_contents($code_filename);
  $result_filename = "../" . $name . ".txt";
  if (file_exists($result_filename))
    $expected_result = file_get_contents($result_filename);
}
?>
 <body>
   <p>
     <a href="../index.php">Top</a>
   </p>
   <form action="saveTest.php" method="post">
     <b>Test name:</b> max length <code>64 bytes</code>, allowed chars 
<code>a-zA-Z0-9._-</code>
     <br/>
     <input type="text" name="name" size="64" maxlength="64" 
value="<?=$name?>"/>
     <br/>
     <br/>

     <b>Test code:</b> max length <code>10KB</code>
     <br/>
     <textarea name="test_code" cols="64" 
rows="15"><?=htmlspecialchars($test_code)?></textarea>
     <br/>
     <br/>

     <b>Expected results:</b> max length <code>2KB</code>
     <br/>
     <textarea name="expected_result" cols="64" 
rows="10"><?=$expected_result?></textarea>
     <br/>
     <br/>
     <br/>
     <input type="submit" value="Save"/>
   </form>
 </body>
</html>

--- NEW FILE ---
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>

  <head>
    <title>DynAPI - Test Suite</title>
  </head>
  <body>

<?php

echo "<p><a href=\"../index.php\">Top</a></p>\n";

$name = $_REQUEST["name"];
$expected_result = $_REQUEST["expected_result"];
$test_code = $_REQUEST["test_code"];

if ($name == "") {
  die("<p>Name is required (<a 
href=\"javascript:history.back()\">back</a>).</p>\n");
}
if (strlen($name) > 64) {
  die("<p>Name too long, max length = 64 bytes (<a 
href=\"javascript:history.back()\">back</a>).</p>\n");
}
if (!preg_match('/^[a-zA-Z0-9\._-]+$/i', $name)) {
  die('<p>Bad name: $name (<a 
href=\"javascript:history.back()\">back</a>).</p>\n"</p>\n');
}

if ($test_code == "") {
  die("<p>Test code is required (<a 
href=\"javascript:history.back()\">back</a>).</p>\n");
}
if (strlen($test_code) > (1024 * 10)) {
  die("<p>Test code too long, max length = 10KB (<a 
href=\"javascript:history.back()\">back</a>).</p>\n");
}

if ($expected_result == "") {
  die("<p>Expected result is required (<a 
href=\"javascript:history.back()\">back</a>).</p>\n");
}
if (strlen($expected_result) > (1024 * 2)) {
  die("<p>Expected result too long, max length = 2KB (<a 
href=\"javascript:history.back()\">back</a>).</p>\n");
}

$code_filename = "../" . $name . ".html";
$result_filename = "../" . $name . ".txt";

$handle = fopen($code_filename, "w+");
$rv1 = fwrite($handle, $test_code);
fclose($handle);

$handle = fopen($result_filename, "w+");
$rv2 = fwrite($handle, $expected_result);
fclose($handle);

printf("<p>Code: %d bytes, result: %d bytes</p>\n", $rv1, $rv2);

?>

  </body>
</html>

--- NEW FILE ---
<html>
<head>
<title>DynAPI - Test Suite</title>
</head>

<body>
<?php

require("config.php");

$name = $_REQUEST['name'];

$test_database_connection = mysql_connect("$test_database_server",
                                          "$test_database_user",
                                          "$test_database_password")
  or die("Could not connect to database: " . mysql_error());

mysql_select_db("$test_database_name")
  or die("Could not select database $test_database_name");

// Performing SQL query
$query = "SELECT dynapi_version, testcase_date, passed, comments, user_agent, 
test_date, tester  FROM testresult WHERE testcase_name = '" . $name . "' ORDER 
BY id";

$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num_rows = mysql_num_rows($result);

echo "<p><a href=\"../index.php\">Top</a></p>\n";
echo "<p>Previous test results for <b>$name</b></p>\n";
// List test cases in a table
echo "<table border=\"1\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo " <th>DynAPI Version</th>\n";
echo " <th>Testcase created</th>\n";
echo " <th>Passed</th>\n";
echo " <th>Comments</th>\n";
echo " <th>User agent</th>\n";
echo " <th>Test Date</th>\n";
echo " <th>Tester</th>\n";
echo "</tr>\n";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  if ($line["passed"])
    $style = "";
  else
    $style = "style=\"background-color:pink;\"";
  echo "<tr $style>\n";
  echo " <td>" . $line["dynapi_version"] . "</td>\n";
  echo " <td>" . $line["testcase_date"] . "</td>\n";
  echo " <td>" . ($line["passed"] ? "<font color=\"green\">Yes</font>" : "<font 
color=\"red\">No</font>") . "</td>\n";
  echo " <td>" . $line["comments"] . "</td>\n";
  echo " <td>" . $line["user_agent"] . "</td>\n";
  echo " <td>" . $line["test_date"] . "</td>\n";
  echo " <td>" . $line["tester"] . "</td>\n";
  echo "</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($test_database_connection);
?>
</body>
</html>

--- NEW FILE ---
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>

  <head>
    <title>DynAPI - Test Suite</title>
  </head>
  <body>

<?php

echo "<a href=\"../index.php\">Top</a>\n";

$name = $_REQUEST['name'];
$passfail = $_REQUEST['passfail'];
$comments = $_REQUEST['comments'];
$tester = $_REQUEST['tester'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$dynapiVersion = getDynAPIVersion();
$now = date("YmdHis");
$fileMod = stat("../" . $name . ".html");
$fileMod = strftime("%Y-%m-%d %H:%M:%S", $fileMod[9]);

if ($passfail!='P' and $passfail!='F'){
  die("<p>You must select either pass or fail (<a 
href=\"javascript:history.back()\">back</a>).</p>\n");
}

if ($passfail=='P'){
     $passfail=1;
}
else{
  $passfail=0;
}

require("config.php");
$test_database_connection = mysql_connect("$test_database_server",
                                          "$test_database_user",
                                          "$test_database_password")
  or die("Could not connect to database: " . mysql_error());

mysql_select_db("$test_database_name")
  or die("Could not select database $test_database_name");

$query = "INSERT INTO testresult (testcase_name, dynapi_version, testcase_date, 
passed, comments, user_agent, test_date, tester) VALUES ('$name', 
'dynapi$version', '$fileMod', $passfail, '$comments', '$agent', '$now', 
'$tester')";
mysql_query($query) or die('Query failed: ' . mysql_error());

printf("<p>Records stored: %d</p>\n", mysql_affected_rows());

mysql_close($test_database_connection);

function getDynAPIVersion() {
  $major = 0;
  $minor = 0;
  $revision = 0;
  $handle = fopen("../../src/version.xml", "r");
  while (!feof($handle)) {
    $line = fgets($handle, 4096);
    preg_match("/<major>([^<]+)/", $line, $matches);
    if (count($matches) > 1)
      $major = $matches[1];
    preg_match("/<minor>([^<]+)/", $line, $matches);
    if (count($matches) > 1)
      $minor = $matches[1];
    preg_match("/<revision>([^<]+)/", $line, $matches);
    if (count($matches) > 1)
      $revision = $matches[1];
  }
  fclose($handle);

  return $major . "." . $minor . "." . $revision;
}
?>

  </body>
</html>

--- NEW FILE ---
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>

  <head>
    <title>DynAPI - Test Suite</title>
  </head>
  <body>

    <form action="storeResult.php" target="_top">

<?php

$name = $_REQUEST['name'];

require("config.php");


$fileMod = stat("../" . $name . ".html");
$fileMod = strftime("%Y-%m-%d %H:%M:%S", $fileMod[9]);


echo "<a href=\"../index.php\" target=\"_TOP\">Top</a>\n";

echo "<table>\n";

echo " <tr>\n";
echo "  <td align=\"right\">Test Name:</td>\n";
echo "  <td>" . $name . "</td>\n";
echo " </tr>\n";

echo " <tr>\n";
echo "  <td align=\"right\">Last modified:</td>\n";
echo "  <td>" . $fileMod . "</td>\n";
echo " </tr>\n";

echo "</table>\n";

echo "<h4>Expected result:</h4>\n";
echo file_get_contents("../" . $name . ".txt");
echo "</p>\n";

echo "<h4>Observed result:</h4>\n";

echo "<input type=\"radio\" name=\"passfail\" value=\"P\"\">Pass</input>";
echo "<input type=\"radio\" name=\"passfail\" value=\"F\"\">Fail</input>";
echo "<br/>\n";

echo "Testers name: ";
echo "<input type=\"text\" name=\"tester\"/>\n";
echo "<br/>\n";

echo "Comments / observations:";
echo "<br/>\n";
echo "<textarea name=\"comments\" rows=\"10\" cols=\"32\"></textarea>\n";
echo "<br/>\n";

echo "<input type=\"submit\" value=\"Save test result\"/>\n";
echo "<input type=\"hidden\" name=\"name\" value=\"" . $name . "\"/>\n";

?>
    </form>

  </body>
</html>



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Dynapi-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dynapi-cvs

Reply via email to