<?php 
/* 
 +-------------------------------------------------------------------------+ 
 |   Copyright (C) 2007-2008 by SixDegrees                                 | 
 |   [email protected]                                               | 
 |   http://www.sixdegrees.com.br/                                         | 
 |                                                                         | 
 |   Permission is hereby granted, free of charge, to any person obtaining | 
 |   a copy of this software and associated documentation files (the       | 
 |   "Software"), to deal in the Software without restriction, including   | 
 |   without limitation the rights to use, copy, modify, merge, publish,   | 
 |   distribute, sublicense, and/or sell copies of the Software, and to    | 
 |   permit persons to whom the Software is furnished to do so, subject to | 
 |   the following conditions:                                             | 
 |                                                                         | 
 |   The above copyright notice and this permission notice shall be        | 
 |   included in all copies or substantial portions of the Software.       | 
 |                                                                         | 
 |   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       | 
 |   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    | 
 |   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.| 
 |   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     | 
 |   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | 
 |   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 
 |   OTHER DEALINGS IN THE SOFTWARE.                                       | 
 +-------------------------------------------------------------------------+ 
 |   Author: Cesar D. Rodas <[email protected]>                      | 
 +-------------------------------------------------------------------------+ 
*/ 
 
/** 
 *  Testing. 
 *   
 *  One important thing, I don't know why "isSet" always returns 
 *  false... If anyone know please let me know. 
 *   
 *  Actually if element doesn't exist it will return a empty string. 
 */ 
  
require(dirname(__FILE__)."/parray.php"); 
 
$example_set = array(  
    1 => range(1,50), 
    'foo' => 'bar', 
    2 => array("another","array",1) 
); 
 
$parray = new parray("test.db"); 
if ( !$parray['create'] ) { 
    print "Creating Array. This should happend only the first time<br>\n"; 
    foreach( $example_set as $k => $v)  
        $parray[$k] = $v; 
    $parray['create'] = 1; 
    print "To test it well, please refresh the page (or re-run this script)<br>\n"; 
} 
print "<h1>Testing</h1>\n"; 
foreach( $example_set as $k => $v) { 
    print "Comparing $k..."; 
     
    $result =  is_array($example_set[$k]) ? count ( array_diff($example_set[$k],$parray[$k]) ) == 0 : $example_set[$k] == $parray[$k]; 
    if ( $result ) 
        print " OK<br>\n"; 
    else 
        die("failed"); 
} 
?>
 
 |