[Cs-content-commits] SF.net SVN: cs-content:[439] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
|
From: <cra...@us...> - 2009-08-14 19:40:23
|
Revision: 439
http://cs-content.svn.sourceforge.net/cs-content/?rev=439&view=rev
Author: crazedsanity
Date: 2009-08-14 19:40:09 +0000 (Fri, 14 Aug 2009)
Log Message:
-----------
More tests of basic I/O, with fixes too.
/cs_fileSystem.class.php:
* move_file():
-- set the filename & destination to their absolute values so the
call to rename() works.
/tests/testOfCSFileSystem.php:
* test_basic_rw():
-- writes a big file (5000 lines) and then jumps around in the file,
picking random lines to see if the line content appears correct.
-- move a file (rename it) and make sure the resulting ls data
matches the previous ls (with slight modifications).
Modified Paths:
--------------
trunk/1.0/cs_fileSystem.class.php
trunk/1.0/tests/testOfCSFileSystem.php
Modified: trunk/1.0/cs_fileSystem.class.php
===================================================================
--- trunk/1.0/cs_fileSystem.class.php 2009-08-14 18:57:53 UTC (rev 438)
+++ trunk/1.0/cs_fileSystem.class.php 2009-08-14 19:40:09 UTC (rev 439)
@@ -885,6 +885,8 @@
if($this->is_readable($filename)) {
if($this->check_chroot($destination)) {
//do the move.
+ $filename = $this->filename2absolute($filename);
+ $destination = $this->filename2absolute($destination);
$retval = rename($filename, $destination);
}
else {
Modified: trunk/1.0/tests/testOfCSFileSystem.php
===================================================================
--- trunk/1.0/tests/testOfCSFileSystem.php 2009-08-14 18:57:53 UTC (rev 438)
+++ trunk/1.0/tests/testOfCSFileSystem.php 2009-08-14 19:40:09 UTC (rev 439)
@@ -148,13 +148,43 @@
//now make sure the contents of the file are as expected...
$this->assertEqual($myContent, $this->writer->read($appendTestFile));
- $this->writer->create_file('x.txt');
- $this->writer->write($myContent, 'x.txt');
+ unset($myContent,$finalFileLines);
- unset($myContent,$finalFileLines);
+ //randomly pull a line and make sure it starts with the right phrase.
+ $this->writer->openFile($appendTestFile, 'r');
+ $linesToTest = 100;
+
+ for($i=0;$i<$linesToTest;$i++) {
+ $randomLine = rand(0, $actualNum);
+
+ $this->writer->go_to_line($randomLine);
+ $lineContents = $this->writer->get_next_line();
+
+ $this->assertTrue(preg_match('/^line #'. $randomLine .' /', $lineContents));
+ }
+
+ $this->writer->go_to_last_line();
+ $this->writer->go_to_line(($this->writer->lineNum -2));//go back two lines because we're actually past the last line, gotta go 2 up so when we fetch "the next line", it is actually the last.
+ $lineContents = $this->writer->get_next_line();
+ $this->assertTrue(preg_match('/^line #'. ($this->writer->lineNum -1) .' /', $lineContents), " getting last line (#". $this->writer->lineNum ."), Line Contents::: ". $lineContents);
+
+ $this->writer->closeFile();
}
+ //now let's try moving a file.
+ $newName = "movedFile.txt";
+ $lsData = $this->writer->ls();
+ $this->assertTrue(isset($lsData[$appendTestFile]));
+ $this->writer->move_file($appendTestFile, $newName);
+ //change the array and make sure it is approximately the same.
+ $newLsData = $this->writer->ls();
+ $tmp = $lsData[$appendTestFile];
+ unset($lsData[$appendTestFile]);
+ $lsData[$newName] = $tmp;
+ $this->assertEqual($newLsData, $lsData);
+
+
//now delete the files.
foreach($this->writer->ls() as $file=>$garbage) {
$this->writer->rm($file);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|