testsuite finished
This commit is contained in:
parent
af61a38b4b
commit
b5cc4d0a38
3 changed files with 123 additions and 6 deletions
11
Changes.md
11
Changes.md
|
@ -1,8 +1,17 @@
|
|||
2006/04/28 David Saez <david@ols.es>
|
||||
2006/04/29 David Saez <david@ols.es>
|
||||
- improved .edu handler
|
||||
- testsuite finished
|
||||
|
||||
2006/04/28 David Saez <david@ols.es>
|
||||
- fixed special non handled domains support
|
||||
- added not supported domain .cy
|
||||
- fixed typo in test.txt
|
||||
- fixed directi handler detection
|
||||
- testsuit finished
|
||||
- improved whois.parser
|
||||
- fixed joker handler
|
||||
- minor fix to namejuice handler
|
||||
- fixed krnic handler
|
||||
|
||||
2006/04/08 David Saez <david@ols.es>
|
||||
- Added handler for .eu
|
||||
|
|
117
testsuite.php
117
testsuite.php
|
@ -26,10 +26,8 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
include('whois.main.php');
|
||||
// Read domain list to test
|
||||
|
||||
$whois = new Whois();
|
||||
|
||||
$lines = file('./test.txt');
|
||||
$domains = array();
|
||||
|
||||
|
@ -49,12 +47,121 @@ foreach ($lines as $key => $line)
|
|||
if ($parts[$i]!='')
|
||||
$domains[] = $parts[$i];
|
||||
}
|
||||
|
||||
// Load previous results
|
||||
|
||||
$fp = fopen('testsuite.txt','rt');
|
||||
|
||||
if (!$fp)
|
||||
$results = array();
|
||||
else
|
||||
{
|
||||
$results = unserialize(fgets($fp));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// Test domains
|
||||
|
||||
include('whois.main.php');
|
||||
|
||||
$whois = new Whois();
|
||||
|
||||
set_file_buffer(STDIN, 0);
|
||||
|
||||
foreach ($domains as $key => $domain)
|
||||
{
|
||||
echo "\nTesting $domain ---------------------------------\n";
|
||||
$result = $whois->Lookup($domain);
|
||||
print_r($result);
|
||||
$result = $whois->Lookup($domain);
|
||||
|
||||
unset($result['rawdata']);
|
||||
|
||||
if (!isset($results[$domain]))
|
||||
{
|
||||
print_r($result);
|
||||
$res = get_answer("Add result for $domain");
|
||||
|
||||
if ($res)
|
||||
{
|
||||
// Add as it is
|
||||
unset($result['regrinfo']['disclaimer']);
|
||||
$results[$domain] = $result;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compare with previous result
|
||||
unset($result['regrinfo']['disclaimer']);
|
||||
unset($results[$domain]['regrinfo']['disclaimer']);
|
||||
|
||||
$diff = array_diff_assoc_recursive($result,$results[$domain]);
|
||||
|
||||
if (is_array($diff))
|
||||
{
|
||||
print_r($diff);
|
||||
$res = get_answer("Accept differences for $domain");
|
||||
|
||||
if ($res)
|
||||
{
|
||||
// Add as it is
|
||||
$results[$domain] = $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
echo "Handler for domain $domain gives same results as before ...\n";
|
||||
}
|
||||
}
|
||||
|
||||
$fp = fopen('testsuite.txt','wt');
|
||||
fputs($fp, serialize($results));
|
||||
fclose($fp);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
function get_answer($question)
|
||||
{
|
||||
echo "\n------ $question ? (y/n/a) ";
|
||||
|
||||
while (true)
|
||||
{
|
||||
$res = trim(fgetc(STDIN));
|
||||
|
||||
if ($res=='a') exit();
|
||||
|
||||
if ($res=='y') return true;
|
||||
if ($res=='n') return false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
function array_diff_assoc_recursive($array1, $array2)
|
||||
{
|
||||
foreach($array1 as $key => $value)
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
if (!is_array($array2[$key]))
|
||||
{
|
||||
$difference[$key] = array( 'previous' => $array2[$key], 'actual' => $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_diff = array_diff_assoc_recursive($value, $array2[$key]);
|
||||
|
||||
if ($new_diff != false)
|
||||
{
|
||||
$difference[$key] = $new_diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif(!isset($array2[$key]) || $array2[$key] != $value)
|
||||
{
|
||||
$difference[$key] = array( 'previous' => $array2[$key], 'actual' => $value);
|
||||
}
|
||||
}
|
||||
|
||||
return !isset($difference) ? false : $difference;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
1
testsuite.txt
Normal file
1
testsuite.txt
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue