phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: filemanager/tests benchmark_dav.php,NONE,1.1.2.1


From: Jonathon Sim <address@hidden>
Subject: [Phpgroupware-cvs] CVS: filemanager/tests benchmark_dav.php,NONE,1.1.2.1 test.php,NONE,1.1.2.1 test_dav.php,NONE,1.1.2.1
Date: Sun, 29 Jun 2003 20:02:04 -0400

Update of /cvsroot/phpgroupware/filemanager/tests
In directory subversions:/tmp/cvs-serv12957/tests

Added Files:
      Tag: Version-0_9_16-branch
        benchmark_dav.php test.php test_dav.php 
Log Message:
Unit tests (mainly of the features of the VFS classes in the API, but stored 
here for ease-of-access).  Backported from CVS HEAD to help test the 0.9.16 
release.

--- NEW FILE ---
<?php


$phpgw_info["flags"] = array("currentapp" => "filemanager",
                                "noheader" => False,
                                "noappheader" => False,
                                "enable_vfs_class" => True);

include("../../header.inc.php");

  function getmicrotime()
  { 
    list($usec, $sec) = explode(" ",microtime()); 
    return ((float)$usec + (float)$sec); 
   } 
   
        function stats($array)
        {
                $mean = array_sum($array)/count($array);
                $a = 0;
                foreach ($array as $value)
                {
                        $a += ($value - $mean)*($value - $mean);
                }
                $std = sqrt($a/count($array));
                $error = $std/sqrt(count($array));
                echo "mean time: $mean error: +-$error";
        }
    echo '<b>Benchmarking vfs::ls</b><br>';
    $times = array(); 
        $phpgw->vfs->cd();
        for ($i=0;$i<20; $i++)
        {
                $phpgw->vfs->dav_client->cached_props = array();
                $time1 = getmicrotime();
                $result = $phpgw->vfs->ls (array ('string' => ''));
                $time = getmicrotime() - $time1;
                $times[] = $time;
                echo "run $i: $time<br>";
                //sleep(1);
                flush();
        }
        stats($times);
        
        echo '<br><b>Benchmarking dav_client::get_properties</b><br>';
    $times = array(); 
        $phpgw->vfs->cd();
        for ($i=0;$i<20; $i++)
        {
                $phpgw->vfs->dav_client->cached_props = array();
                $time1 = getmicrotime();
                $result = $phpgw->vfs->dav_client->get_properties('/home/sim');
                $time = getmicrotime() - $time1;
                $times[] = $time;
                echo "run $i: $time<br>";
                flush();
        }
        stats($times);


?>

--- NEW FILE ---
<?php

$phpgw_info["flags"] = array("currentapp" => "filemanager",
                                "noheader" => False,
                                "noappheader" => False,
                                "enable_vfs_class" => True);

include("../header.inc.php");

/*
        General format for output is:
        sequence number - function - current directory - input[...] - what 
output should be - what output was
*/

html_break (1);
html_text_italic (PHP_OS . " - " . $phpgw_info["server"]["db_type"] . " - " . 
PHP_VERSION . " - " . $phpgw->vfs->basedir);
html_break (1);

$sep = SEP;
$user = $phpgw->vfs->working_lid;
$homedir = $phpgw->vfs->fakebase . "/" . $user;
$realhomedir = preg_replace ("|/|", $sep, $homedir);
$filesdir = $phpgw->vfs->basedir;
$currentapp = $phpgw_info["flags"]["currentapp"];

###
# start of getabsolutepath tests

$sequence_num = 1;
$phpgw->vfs->cd ();
$io = array ("" => "$homedir", "dir" => "$homedir/dir", "dir/file" => 
"$homedir/dir/file", "dir/dir2" => "$homedir/dir/dir2", "dir/dir2/file" => 
"$homedir/dir/dir2/file", "address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"$homedir/address@hidden&*()-_=+/|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $o - 
$ao";
        }
}

$sequence_num = 2;
$cd = "test";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_NONE)
        )
);
$io = array ("" => "/test", "dir" => "/test/dir", "dir/file" => 
"/test/dir/file", "dir/dir2" => "/test/dir/dir2", "dir/dir2/file" => 
"/test/dir/dir2/file", "address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"/test/address@hidden&*()-_=+/|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $o - 
$ao";
        }
}

$sequence_num = 3;
$cd = "test/test2/test3";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_NONE)
        )
);
$io = array ("" => "/test/test2/test3", "dir" => "/test/test2/test3/dir", 
"dir/file" => "/test/test2/test3/dir/file", "dir/dir2" => 
"/test/test2/test3/dir/dir2", "dir/dir2/file" => 
"/test/test2/test3/dir/dir2/file", "address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"/test/test2/test3/address@hidden&*()-_=+/|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $o - 
$ao";
        }
}

/* Actually means cd to home directory */
$sequence_num = 4;
$cd = "";
$phpgw->vfs->cd (array(
                'string'        => $cd
        )
);
$relatives = array (RELATIVE_USER);
$io = array ("" => "$homedir", "dir" => "$homedir/dir", "dir/file" => 
"$homedir/dir/file", "address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"$homedir/address@hidden&*()-_=+/|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives))) != $o)
        {
                echo '<br><b>HERE</b>';
                echo "<br>$sequence_num - getabsolutepath - $cd - $i - 
$relatives[0] - $o - $ao";
        }
}

/* $cd shouldn't affect this test, but we'll set it anyways */
$sequence_num = 5;
$cd = "test2/test4";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_NONE)
        )
);
$relatives = array (RELATIVE_NONE);
$io = array ("" => "", "dir" => "dir", "dir/file" => "dir/file", 
"address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"address@hidden&*()-_=+/|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't 
matter) - $i - $relatives[0] - $o - $ao";
        }
}

/* $cd shouldn't affect this test, but we'll set it anyways */
$sequence_num = 6;
$cd = "test3/test5";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_NONE)
        )
);
$relatives = array (RELATIVE_USER_APP);
$io = array ("" => "$homedir/.$currentapp", "dir" => 
"$homedir/.$currentapp/dir", "dir/dir2" => "$homedir/.$currentapp/dir/dir2", 
"dir/file" => "$homedir/.$currentapp/dir/file", "dir/dir2/dir3/file" => 
"$homedir/.$currentapp/dir/dir2/dir3/file", 
"address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"$homedir/.$currentapp/address@hidden&*()-_=+/|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't 
matter) - $i - $relatives[0] - $o - $ao";
        }
}

/* $cd shouldn't affect this test, but we'll set it anyways */
$sequence_num = 7;
$cd = "test4/test6";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_NONE)
        )
);
$relatives = array (RELATIVE_ROOT);
$io = array ("" => "", "dir" => "/dir", "/dir/dir2/dir3" => "/dir/dir2/dir3", 
"dir/file" => "/dir/file", "dir/dir2/dir3" => "/dir/dir2/dir3", 
"address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"/address@hidden&*()-_=+/|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't 
matter) - $i - $relatives[0] - $o - $ao";
        }
}

/* Now a few to test the VFS_REAL capabilities */
$sequence_num = 8;
$cd = "";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_NONE)
        )
);
$relatives = array (RELATIVE_ROOT|VFS_REAL);
$io = array ("" => "$filesdir", "dir" => "$filesdir$sep" . "dir", 
"dir/dir2/dir3" => "$filesdir$sep" . "dir$sep" . "dir2$sep" . "dir3", 
"dir/file" => "$filesdir$sep" . "dir$sep" . "file", "dir/dir2/dir3/file" => 
"$filesdir$sep" . "dir$sep" . "dir2$sep" . "dir3$sep" . "file", 
"address@hidden&*()-_=+/|[{]};:'\",<.>?" => "$filesdir$sep" . 
"address@hidden&*()-_=+$sep" . "|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives, 'fake' =>False))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't 
matter) - $i - $relatives[0] - $o - $ao";
        }
}

$sequence_num = 9;
$cd = "test5/test7";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_NONE)
        )
);
$relatives = array (RELATIVE_USER|VFS_REAL);
$io = array ("" => "$filesdir$realhomedir", "dir" => 
"$filesdir$realhomedir$sep" . "dir", "dir/dir2/dir3" => 
"$filesdir$realhomedir$sep" . "dir$sep" . "dir2$sep" . "dir3", "dir/file" => 
"$filesdir$realhomedir$sep" . "dir$sep" . "file", "dir/dir2/dir3/file" => 
"$filesdir$realhomedir$sep" . "dir$sep" . "dir2$sep" . "dir3$sep" . "file", 
"address@hidden&*()-_=+/|[{]};:'\",<.>?" => "$filesdir$realhomedir$sep" . 
"address@hidden&*()-_=+$sep" . "|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives, 'fake' => False))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't 
matter) - $i - $relatives[0] - $o - $ao";
        }
}

$sequence_num = 10;
$cd = "test6/test8";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_USER)
        )
);
/* RELATIVE_CURRENT should be implied */
$relatives = array (VFS_REAL);
$io = array ("" => "$filesdir$realhomedir$sep$cd", "dir" => 
"$filesdir$realhomedir$sep$cd$sep" . "dir", "dir/dir2/dir3" => 
"$filesdir$realhomedir$sep$cd$sep" . "dir$sep" . "dir2$sep" . "dir3", 
"dir/file" => "$filesdir$realhomedir$sep$cd$sep" . "dir$sep" . "file", 
"dir/dir2/dir3/file" => "$filesdir$realhomedir$sep$cd$sep" . "dir$sep" . 
"dir2$sep" . "dir3$sep" . "file", "address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"$filesdir$realhomedir$sep$cd$sep" . "address@hidden&*()-_=+$sep" . 
"|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives, 'fake' => False))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd - $i - 
$relatives[0] - $o - $ao";
        }
}

$sequence_num = 11;
$cd = "test7/test9";
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array (RELATIVE_USER)
        )
);
$relatives = array (RELATIVE_USER_APP|VFS_REAL);
$io = array ("" => "$filesdir$realhomedir$sep.$currentapp", "dir" => 
"$filesdir$realhomedir$sep.$currentapp$sep" . "dir", "dir/dir2/dir3" => 
"$filesdir$realhomedir$sep.$currentapp$sep" . "dir$sep" . "dir2$sep" . "dir3", 
"dir/file" => "$filesdir$realhomedir$sep.$currentapp$sep" . "dir$sep" . "file", 
"dir/dir2/dir3/file" => "$filesdir$realhomedir$sep.$currentapp$sep" . "dir$sep" 
. "dir2$sep" . "dir3$sep" . "file", "address@hidden&*()-_=+/|[{]};:'\",<.>?" => 
"address@hidden&*()-_=+$sep" . "|[{]};:'\",<.>?");

while (list ($i, $o) = each ($io))
{
        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' 
=> $relatives, 'fake' => False))) != $o)
        {
                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't 
matter) - $i - $relatives[0] - $o - $ao";
        }
}

# end of getabsolutepath tests
###

###
# start of path_parts tests

/* Just for convienience
$io = array ("" => array ("fake_full_path" => "", "fake_leading_dirs" => "", 
"fake_extra_path" => "", "fake_name" => "", "real_full_path" => "", 
"real_leading_dirs" => "", "real_extra_path" => "", "real_name" => ""));
address@hidden&*()-_=+/|[{]};:'\",<.>?
*/

$sequence_num = 12;
$cd = "test8/test10";
$relatives[0] = RELATIVE_USER;
$phpgw->vfs->cd (array(
                'string'        => $cd,
                'relative'      => False,
                'relatives'     => array ($relatives[0])
        )
);
$subhome = substr ($homedir, 1);
$io = array ("" => array ("fake_full_path" => "$homedir/$cd", 
"fake_leading_dirs" => "$homedir/test8", "fake_extra_path" => "$subhome/test8", 
"fake_name" => "test10", "real_full_path" => "$filesdir$homedir/$cd", 
"real_leading_dirs" => "$filesdir$homedir/test8", "real_extra_path" => 
"$subhome/test8", "real_name" => "test10"), "dir2/file" => array 
("fake_full_path" => "$homedir/$cd/dir2/file", "fake_leading_dirs" => 
"$homedir/$cd/dir2", "fake_extra_path" => "$subhome/$cd/dir2", "fake_name" => 
"file", "real_full_path" => "$filesdir$homedir/$cd/dir2/file", 
"real_leading_dirs" => "$filesdir$homedir/$cd/dir2", "real_extra_path" => 
"$subhome/$cd/dir2", "real_name" => "file"), 
"address@hidden&*()-_=+/|[{]};:'\",<.>?" => array ("fake_full_path" => 
"$homedir/$cd/address@hidden&*()-_=+/|[{]};:'\",<.>?", "fake_leading_dirs" => 
"$homedir/$cd/address@hidden&*()-_=+", "fake_extra_path" => 
"$subhome/$cd/address@hidden&*()-_=+", "fake_name" => "|[{]};:'\",<.>?", 
"real_full_path" => 
"$filesdir$homedir/$cd/address@hidden&*()-_=+/|[{]};:'\",<.>?", 
"real_leading_dirs" => "$filesdir$homedir/$cd/address@hidden&*()-_=+", 
"real_extra_path" => "$subhome/$cd/address@hidden&*()-_=+", "real_name" => 
"|[{]};:'\",<.>?"));

while (list ($i, $o) = each ($io))
{
        $ao = $phpgw->vfs->path_parts (array ('string' => $i));
        while (list ($key, $value) = each ($o))
        {
                if ($ao->$key != $o[$key])
                {
                        echo "<br>$sequence_num - path_parts - $cd - $i - 
$relatives[0] - $key - $o[$key] - $ao[$key]";
                }
        }
}

# end of path_parts tests
###

$phpgw->vfs->cd ();

html_break (2);
html_text_bold ("The less output, the better.  Please file errors as a " . 
html_link ("https://sourceforge.net/tracker/?group_id=7305&atid=107305";, "bug 
report", True, False) .  ". Be sure to include the system information line at 
the top, and anything special about your setup.  Thanks!");

html_page_close ();

?>

--- NEW FILE ---
<?php
function ok($string){
/*      html_table_row_begin();
        html_table_col_begin();*/
        echo "<h3>$string ";
/*      html_table_col_end();
        html_table_col_begin();*/
        echo  " OK</h3>";
/*      html_table_col_end();
        html_table_row_end();*/
}
function fail($string){
/*      html_table_row_begin();
        html_table_col_begin();*/
        echo "<h3>$string ";
/*      html_table_col_end();
        html_table_col_begin();*/
        echo " <b>FAILED!</b></h3>";
/*      html_table_col_end();
        html_table_row_end(); */
}

$phpgw_info["flags"] = array("currentapp" => "filemanager",
                                "noheader" => False,
                                "noappheader" => False,
                                "enable_vfs_class" => True);

include("../../header.inc.php");

html_text('VFS_DAV tests:');
html_break (1);
html_text_italic (PHP_OS . " - " . $phpgw_info["server"]["db_type"] . " - " . 
PHP_VERSION . " - " . $phpgw->vfs->basedir);
html_break (1);
//html_table_begin();


$sep = SEP;
$user = $phpgw->vfs->working_lid;
$homedir = $phpgw->vfs->fakebase . "/" . $user;
$realhomedir = preg_replace ("|/|", $sep, $homedir);
$filesdir = $phpgw->vfs->basedir;
$currentapp = $phpgw_info["flags"]["currentapp"];
$time1 = time();

echo ' override locks : ';print_r($phpgw->vfs->override_locks);
        ###
        # write test

        $phpgw->vfs->cd ();
        $testfile = 'sdhdsjjkldggfsbhgbnirooaqojsdkljajklvagbytoi-test';
        $teststring = 'delete me' ;
        if (!$result = $phpgw->vfs->write (array ('string' => $testfile,
                'content' => $teststring
                ))) 
        {
                fail( __LINE__." failed writing file!");
        }
        else
        {
        ok("write");
        }

#read
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->read (array ('string' => $testfile, 'noview' => 
true     ));
        if (!$result==$teststring) 
        {
                fail( __LINE__." failed reading file!");
        }
        else
        {
        ok(" read");
        }
        
        ###
        # ls test

        $result1 = $phpgw->vfs->ls (array ('string' => $testfile        ));

        if (!count($result1)) 
        {
                fail(__LINE__." failed listing file!");
        }
        else
        {
        ok(" ls : known file");
        }
//list the parent dir

        $result = $phpgw->vfs->ls (array ('string' => ''));
        foreach ($result as $file)
        {
                if ($testfile == $file['name'])
                {
                        $found = true;
                        break;
                }
        }
        if (!$found) 
        {
                fail(__LINE__." failed listing file!");
        }
        else
        {
                ok(" ls : parent");
        }
        $found = false;
        foreach ($result as $file)
        {
                if ($result1[0]['directory'] == $file['full_name'])
                {
                        $found = true;
                        break;
                }
        }
        if ($found) 
        {
                fail(__LINE__." parent is present in its own listing!");
        }
        else
        {
                ok(" ls : parent self reference");
        }
# getsize 
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->get_size (array ('string' => $testfile   ));
        $len = strlen($teststring);
        if (!($result== $len)) 
        {
                fail(__LINE__." failed getting size of file result $result 
strlen $len");
        }
        else
        {
        ok("get_size");
        }
        
#filetype
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->file_type(array ('string' => $testfile   ));
        $len = strlen($teststring);
        if (!($result== 'application/octet-stream')) 
        {
                fail(__LINE__." failed getting file type $result");
        }
        else
        {
        ok("file_type");
        }


#file_exists
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->file_exists(array ('string' => $testfile ));
        if (!$result) 
        {
                fail(__LINE__." file_exist failed: $result");
        }
        else
        {
        ok("file_exists");
        }

#lock
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->lock (array ('string' => $testfile       ));
        if (!$result) 
        {
                fail(__LINE__."failed locking file!");
        }
        else
        {
        ok(" lock");
        }
        
        
                $ls_array = $GLOBALS['phpgw']->vfs->ls (array (
                                'string'        => $testfile,
                                'relatives'     => array (RELATIVE_ALL),
                                'checksubdirs'  => False
                        )
                );
        if (!count($ls_array[0]['locks'])) 
        {
                fail(__LINE__."after locking file no locks exist!");
        }
        else
        {
        ok(" lock: after locking lock exists.");
        }
                $lock = end($ls_array[0]['locks']);
                $tokens = end($lock['lock_tokens']);
                $token = $tokens['name'];
        //write should now fail
        $result = $phpgw->vfs->write (array ('string' => $testfile,
                'content' => 'delete me' 
                ));
        if ($result) 
        {
                fail(__LINE__."I can write a supposidly locked file!");
        }
        else
        {
        ok("lock: after locking write fails");
        }
        
        $phpgw->vfs->add_lock_override(array ('string' => $testfile));
        $result = $phpgw->vfs->write (array ('string' => $testfile,
                'content' => 'delete me' 
                ));
        if (!$result) 
        {
                fail(__LINE__."I cant write a locked file after overriding the 
lock!");
        }
        else
        {
        ok("lock: after lock override write succeeds");
        }
###
# unlock test
        
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->unlock (array ('string' => $testfile     ), 
$token);
        if (!$result) 
        {
                fail( __LINE__."failed unlocking file!");
        }
        else
        {
                OK("unlock");
        }

#server side copy
        
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->cp(array ('from' => $testfile,
                                'to' => $testfile.'2',
                                'relatives'     => array (RELATIVE_ALL, 
RELATIVE_ALL)
                                ));
        if (!$result) 
        {
                fail(__LINE__." failed copying! returned: $result");
        }
        else
        {
                ok("server-side copy");
        }
        $result = $phpgw->vfs->file_exists(array ('string' => $testfile.'2'
                                ));
        if (!$result) 
        {
                fail(__LINE__." after copy, target doesnt exist!");
        }
        else
        {
                ok("server-side copy : test for target");
        }
        $result = $phpgw->vfs->read (array ('string' => "$testfile".'2', 
                'noview' => true,
                'relatives'     => array (RELATIVE_ALL)
                        ));
        if (!$result==$teststring) 
        {
                fail( __LINE__."after copy, read returned '$result' not 
'$teststring' ");
        }
        else
        {
        ok(" server-side copy: read target");
        }
        $result = $phpgw->vfs->delete(array ('string' => $testfile.'2'
                                ));

        if (!$result) 
        {
                fail(__LINE__." failed copying! delete copied file returned: 
$result");
        }
        else
        {
                ok("server-side copy : delete target");
        }

#remote -> local copy   
        $phpgw->vfs->cd ();
        echo "<pre>";
        $result = $phpgw->vfs->cp(array ('from' => $testfile,
                                'to' => "/tmp/$testfile".'2',
                                'relatives'     => array (RELATIVE_ALL, 
RELATIVE_NONE | VFS_REAL)
                                ));
        echo "</pre>";
        if (!$result) 
        {
                fail(__LINE__." failed remote->local copying! returned: 
$result");
        }
        else
        {
                ok("remote->local copy");
        }
        echo "<pre>";
        $result = $phpgw->vfs->file_exists(array ('string' => 
"/tmp/$testfile".'2',
        'relatives'     => array (RELATIVE_NONE | VFS_REAL)
                                ));
        echo "</pre>";
        if (!$result) 
        {
                fail(__LINE__." after remote->local copy, target doesnt 
exist!");
        }
        else
        {
                ok("remote->local copy : test for target");
        }
        $phpgw->vfs->cd ();
        echo "<pre>";
        $result = $phpgw->vfs->read (array ('string' => "/tmp/$testfile".'2', 
                'noview' => true,
                'relatives'     => array (RELATIVE_NONE | VFS_REAL)
                        ));
        echo "</pre>";
        if (!$result==$teststring) 
        {
                fail( __LINE__."after remote->local copy, returned $result");
        }
        else
        {
        ok(" remote->local copy: read target");
        }
        echo "<pre>";   
        $result = $phpgw->vfs->delete(array ('string' => "/tmp/$testfile".'2',
        'relatives'     => array (RELATIVE_NONE | VFS_REAL)
                                ));
        echo "</pre>";
        if (!$result) 
        {
                fail(__LINE__." failed copying! delete copied file returned: 
$result");
        }
        else
        {
                ok("remote->local copy : delete target");
        }
        
#move
        $phpgw->vfs->cd ();
        echo "<pre>";
        $result = $phpgw->vfs->mv(array ('from' => $testfile,
                                'to' => $testfile.'2',
                                'relatives'     => array (RELATIVE_ALL, 
RELATIVE_ALL)
                                ));
        echo "</pre>";
        if (!$result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("server-side move");
        }
        $result = $phpgw->vfs->file_exists(array ('string' => $testfile,
                                ));
        if ($result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("server-side move : test for source");
        }
        $result = $phpgw->vfs->file_exists(array ('string' => $testfile.'2',
                                ));
        if (!$result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("server-side move : test for target");
        }
        echo "<pre>";
        $result = $phpgw->vfs->read (array ('string' => $testfile.'2', 
                'noview' => true,
                'relatives'     => array (RELATIVE_ALL)
                        ));
        echo "</pre>";
        if (!$result==$teststring) 
        {
                fail( __LINE__."after move, read returned '$result' not 
'$teststring' ");
        }
        else
        {
        ok(" server-side move: read target");
        }       
        
        echo "<pre>";   
        $result = $phpgw->vfs->mv(array ('from' => $testfile.'2',
                                'to' => $testfile,
                                'relatives'     => array (RELATIVE_ALL, 
RELATIVE_ALL)
                                ));
        echo "</pre>";
        if (!$result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("server-side move : move back");
        }

#remote->local move
        echo "<pre>";
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->mv(array ('from' => $testfile,
                                'to' => '/tmp/'.$testfile.'2',
                                'relatives'     => array (RELATIVE_ALL, 
RELATIVE_NONE | VFS_REAL)
                                ));
        echo "</pre>";
        if (!$result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("remote->local move");
        }
        $result = $phpgw->vfs->file_exists(array ('string' => $testfile,
                                ));
        if ($result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("remote->local move : test for source");
        }
        $result = $phpgw->vfs->file_exists(array ('string' => 
'/tmp/'.$testfile.'2',
                                 'relatives' => array(RELATIVE_NONE | VFS_REAL)
                                 ));
        if (!$result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("remote->local move : test for target");
        }
        
        $result = $phpgw->vfs->read (array ('string' => '/tmp/'.$testfile.'2', 
                'noview' => true,
                'relatives' => array(RELATIVE_NONE | VFS_REAL)
                        ));
        if (!$result==$teststring) 
        {
                fail( __LINE__."after move, read returned '$result' not 
'$teststring' ");
        }
        else
        {
        ok("remote->local move: read target");
        }       
        
        echo "<pre>";
        $result = $phpgw->vfs->mv(array ('from' => '/tmp/'.$testfile.'2',
                                'to' => $testfile,
                                'relatives'     => array (RELATIVE_NONE | 
VFS_REAL, RELATIVE_ALL)
                                ));
        echo "</pre>";
        if (!$result) 
        {
                fail(__LINE__." failed moving! returned: $result");
        }
        else
        {
                ok("server-side move : move back");
        }


###
# delete test
        
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->delete(array ('string' => $testfile      ));
        if (!$result) 
        {
                fail(__LINE__."failed deleting file! returned: $result");
        }
        else
        {
                ok("delete");
        }

###
# mkdir test
        
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->mkdir(array ('string' => $testfile       ));
        if (!$result) 
        {
                fail(__LINE__."failed creating collection! returned: $result");
        }
        else
        {
                ok("mkdir");
        }

        $result = $phpgw->vfs->write (array ('string' => 
$testfile.'/'.$testfile.'2',
                'content' => $teststring
                ));
                
        if (!$result) 
        {
                fail( __LINE__." failed writing file into new dir!");
        }
        else
        {
        ok("mkdir : write into dir");
        }
###
# rm dir test
        
        $phpgw->vfs->cd ();
        $result = $phpgw->vfs->rm(array ('string' => $testfile  ));
        if (!$result) 
        {
                fail(__LINE__." failed deleting collection! returned: $result");
        }
        else
        {
                ok("delete dir");
        }
        
        //html_table_end();
        $time = time() - $time1;
        html_text("Done in $time s");
        html_page_close ();

?>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]