PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Nachhatar Singh   Unique   test.php   Download  
File: test.php
Role: Unit test script
Content type: text/plain
Description: Test
Class: Unique
Create random text strings from sets of characters
Author: By
Last change:
Date: 11 years ago
Size: 3,605 bytes
 

Contents

Class file image Download
<?php

/**
 * Test uniqueness & randomness
 */

require('./libraries/class.Unique.php');

$check_total_each = 1000; // Number of strings to test.

?><html>
<head>
<title>Test uniqueness &amp; randomness</title>
<style type="text/css">
body { font-family: Tahoma, Geneva, sans-serif; margin: 50px; line-height: 3em; }
pre { background-color: #FFC; border: 1px solid #CCC; line-height: 2em; padding: 2em; }
h2 { margin-top: 2em; }
</style>
</head>
<body>
<h1>Test uniqueness &amp; randomness</h1>
<?php

/*
 * Numbers = TRUE;
 * Alphabets = TRUE;
 * Lowercase Alphabets = TRUE;
 * Uppercase Alphabets = TRUE;
 */
$unique = new Unique();
$mix_ids = array();
for (
$i = 0; $i < $check_total_each; $i++) {
   
$mix_ids[] = $unique->get();
}
echo
'<h2>Alpha (Both) + Numeric</h2>
<pre>
Total : '
, count($mix_ids), '
Unique : '
, count(array_unique($mix_ids)), '
Sample : '
, $unique->get(), '
</pre>'
;
unset(
$unique);

/*
 * Numbers = FALSE;
 * Alphabets = TRUE;
 * Lowercase Alphabets = TRUE;
 * Uppercase Alphabets = TRUE;
 */
$unique = new Unique(FALSE);
$mix_ids = array();
for (
$i = 0; $i < $check_total_each; $i++) {
   
$mix_ids[] = $unique->get();
}
echo
'<h2>Alpha (Both)</h2>
<pre>
Total : '
, count($mix_ids), '
Unique : '
, count(array_unique($mix_ids)), '
Sample : '
, $unique->get(), '
</pre>'
;
unset(
$unique);

/*
 * Numbers = FALSE;
 * Alphabets = TRUE;
 * Lowercase Alphabets = FALSE;
 * Uppercase Alphabets = TRUE;
 */
$unique = new Unique(FALSE, TRUE, FALSE);
$mix_ids = array();
for (
$i = 0; $i < $check_total_each; $i++) {
   
$mix_ids[] = $unique->get();
}
echo
'<h2>Alpha (Uppercase)</h2>
<pre>
Total : '
, count($mix_ids), '
Unique : '
, count(array_unique($mix_ids)), '
Sample : '
, $unique->get(), '
</pre>'
;
unset(
$unique);

/*
 * Numbers = FALSE;
 * Alphabets = TRUE;
 * Lowercase Alphabets = TRUE;
 * Uppercase Alphabets = FALSE;
 */
$unique = new Unique(FALSE, TRUE, TRUE, FALSE);
$mix_ids = array();
for (
$i = 0; $i < $check_total_each; $i++) {
   
$mix_ids[] = $unique->get();
}
echo
'<h2>Alpha (Lowercase)</h2>
<pre>
Total : '
, count($mix_ids), '
Unique : '
, count(array_unique($mix_ids)), '
Sample : '
, $unique->get(), '
</pre>'
;
unset(
$unique);

/*
 * Numbers = TRUE;
 * Alphabets = FALSE;
 * Lowercase Alphabets = FALSE;
 * Uppercase Alphabets = FALSE;
 */
$unique = new Unique(TRUE, FALSE);
$mix_ids = array();
for (
$i = 0; $i < $check_total_each; $i++) {
   
$mix_ids[] = $unique->get();
}
echo
'<h2>Numeric</h2>
<pre>
Total : '
, count($mix_ids), '
Unique : '
, count(array_unique($mix_ids)), '
Sample : '
, $unique->get(), '
</pre>'
;
unset(
$unique);

/*
 * Numbers = TRUE;
 * Alphabets = TRUE;
 * Lowercase Alphabets = TRUE;
 * Uppercase Alphabets = FALSE;
 */
$unique = new Unique(TRUE, TRUE, TRUE, FALSE);
$mix_ids = array();
for (
$i = 0; $i < $check_total_each; $i++) {
   
$mix_ids[] = $unique->get();
}
echo
'<h2>Alpha (Lowercase) + Numeric</h2>
<pre>
Total : '
, count($mix_ids), '
Unique : '
, count(array_unique($mix_ids)), '
Sample : '
, $unique->get(), '
</pre>'
;
unset(
$unique);

/*
 * Numbers = TRUE;
 * Alphabets = TRUE;
 * Lowercase Alphabets = FALSE;
 * Uppercase Alphabets = TRUE;
 */
$unique = new Unique(TRUE, TRUE, FALSE);
$mix_ids = array();
for (
$i = 0; $i < $check_total_each; $i++) {
   
$mix_ids[] = $unique->get();
}
echo
'<h2>Alpha (Uppercase) + Numeric</h2>
<pre>
Total : '
, count($mix_ids), '
Unique : '
, count(array_unique($mix_ids)), '
Sample : '
, $unique->get(), '
</pre>'
;
?>
</body>
</html>