/** Initializes and configures OnlineFileBrowser.
*
diff -Naur OFBUnitTests/README.txt OFBUnitTests_20070910/README.txt
--- OFBUnitTests/README.txt 2007-09-04 17:23:58.000000000 +0200
+++ OFBUnitTests_20070910/README.txt 2007-09-09 21:31:11.000000000 +0200
@@ -1,4 +1,4 @@
-Table of Contents Last Update: 2007-09-05
+Table of Contents Last Update: 2007-09-10
=================
* Requirements
* OFB Installation
@@ -8,6 +8,20 @@
+Introduction
+============
+This directory contains PHPUnit3 test cases for Online File Browser 0.1.7.2.
+<quote>
+PHPUnit is a member of the xUnit family of testing frameworks and
+provides both a framework that makes the writing of tests easy as well
+as the functionality to easily run the tests and analyse their results.
+</quote>
+(see http://www.phpunit.de/\)
+
+This code is mainly targeted to developers.
+
+
+
Requirements
============
1. Proper OFB installation as described in section 'OFB Installation'.
@@ -20,12 +34,13 @@
OFB Installation
================
1. Download and extract OFB
-2. Create uploads folder
+2. Follow instructions in INSTALL.
+3. Create uploads folder
mkdir $OFB_HOME/uploads
-2. Adjust conf/system.properties:
+4. Adjust conf/system.properties:
browser.root=uploads
authentication.enforce=false
-3. Set permissions:
+5. Set permissions:
chown -R $HTTPD_USER:$HTTPD_GROUP $OFB_HOME/logs/
chown -R $HTTPD_USER:$HTTPD_GROUP $OFB_HOME/uploads/
chown -R $HTTPD_USER:$HTTPD_GROUP $OFB_HOME/tpl/default/cache/
@@ -39,23 +54,25 @@
$OFB_HOME/tests (You will need to create the directory tests/ first).
Hello,
Here are two additional tests (see TestCase BrowserTests/DeleteItemTest.php) for the test infrastructure I posted some days ago.
If you need the full tar package, please send me an email (farad@users.sourceforge.net).
Regards, Mick.
Patch file:
diff -Naur OFBUnitTests/BrowserTests/AllBrowserTests.php OFBUnitTests_20070910/BrowserTests/AllBrowserTests.php
--- OFBUnitTests/BrowserTests/AllBrowserTests.php 2007-09-04 17:14:27.000000000 +0200
+++ OFBUnitTests_20070910/BrowserTests/AllBrowserTests.php 2007-09-09 21:44:20.884299104 +0200
@@ -3,6 +3,7 @@
// Browser Tests
require_once 'BasicTest.php';
require_once 'MakeDirTest.php';
+require_once 'DeleteItemTest.php';
/** Suite with all Browser tests.
*
@@ -18,6 +19,7 @@
$suite = new OfbTestSuite('OFB');
$suite->addTest(new OfbTestSuite('BasicTest'));
$suite->addTest(new OfbTestSuite('MakeDirTest'));
+ $suite->addTest(new OfbTestSuite('DeleteItemTest'));
return $suite;
}
diff -Naur OFBUnitTests/BrowserTests/DeleteItemTest.php OFBUnitTests_20070910/BrowserTests/DeleteItemTest.php
--- OFBUnitTests/BrowserTests/DeleteItemTest.php 1970-01-01 01:00:00.000000000 +0100
+++ OFBUnitTests_20070910/BrowserTests/DeleteItemTest.php 2007-09-09 22:09:26.111469792 +0200
@@ -0,0 +1,49 @@
+<?php
+
+/** Tests for the function Browser.php::deleteItem(.)
+ *
+ * @author Mick Faraday (farad@users.sourceforge.net)
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+class DeleteItemTest extends OfbTestCase {
+ private $test1 = 'test1';
+ private $test2 = 'test2';
+ private $test21 = 'test2/test21';
+ private $test22 = 'test2/test22';
+
+
+ protected function setUp() {
+ $this->_filebrowser->makeDir($this->test1);
+ $this->_filebrowser->makeDir($this->test2);
+ $this->_filebrowser->makeDir($this->test21);
+ $this->_filebrowser->makeDir($this->test22);
+ }
+
+ protected function tearDown() {
+ $this->deleteAllItems();
+ }
+
+ /** Removes empty directory.
+ *
+ */
+ public function testRemoveEmptyDir() {
+ $this->_filebrowser->deleteItem($this->test1);
+
+ // check dir
+ $dir = $this->_filebrowser->basepath . '/' . $this->test1;
+ $exists = file_exists($dir);
+ $this->assertFalse($exists);
+ }
+
+ /** Removes non-empty directory.
+ *
+ */
+ public function testRemoveNonEmptyDir() {
+ $this->_filebrowser->deleteItem($this->test2);
+
+ // check dir
+ $exists = file_exists($this->_filebrowser->basepath . '/' . $this->test2);
+ $this->assertFalse($exists);
+ }
+}
+?>
\ No newline at end of file
diff -Naur OFBUnitTests/Common/OfbTestCase.php OFBUnitTests_20070910/Common/OfbTestCase.php
--- OFBUnitTests/Common/OfbTestCase.php 2007-09-04 17:13:48.000000000 +0200
+++ OFBUnitTests_20070910/Common/OfbTestCase.php 2007-09-09 22:19:51.310425104 +0200
@@ -20,6 +20,16 @@
$this->setUpOfb();
$this->_filebrowser = new Browser();
}
+
+ /** Deletes all items in uploads directory.
+ *
+ */
+ protected function deleteAllItems() {
+ $entries = $this->_filebrowser->getEntries('.');
+ foreach ($entries as $entry) {
+ $this->_filebrowser->deleteItem($entry->name);
+ }
+ }
/** Initializes and configures OnlineFileBrowser.
*
diff -Naur OFBUnitTests/README.txt OFBUnitTests_20070910/README.txt
--- OFBUnitTests/README.txt 2007-09-04 17:23:58.000000000 +0200
+++ OFBUnitTests_20070910/README.txt 2007-09-09 21:31:11.000000000 +0200
@@ -1,4 +1,4 @@
-Table of Contents Last Update: 2007-09-05
+Table of Contents Last Update: 2007-09-10
=================
* Requirements
* OFB Installation
@@ -8,6 +8,20 @@
+Introduction
+============
+This directory contains PHPUnit3 test cases for Online File Browser 0.1.7.2.
+<quote>
+PHPUnit is a member of the xUnit family of testing frameworks and
+provides both a framework that makes the writing of tests easy as well
+as the functionality to easily run the tests and analyse their results.
+</quote>
+(see http://www.phpunit.de/\)
+
+This code is mainly targeted to developers.
+
+
+
Requirements
============
1. Proper OFB installation as described in section 'OFB Installation'.
@@ -20,12 +34,13 @@
OFB Installation
================
1. Download and extract OFB
-2. Create uploads folder
+2. Follow instructions in INSTALL.
+3. Create uploads folder
mkdir $OFB_HOME/uploads
-2. Adjust conf/system.properties:
+4. Adjust conf/system.properties:
browser.root=uploads
authentication.enforce=false
-3. Set permissions:
+5. Set permissions:
chown -R $HTTPD_USER:$HTTPD_GROUP $OFB_HOME/logs/
chown -R $HTTPD_USER:$HTTPD_GROUP $OFB_HOME/uploads/
chown -R $HTTPD_USER:$HTTPD_GROUP $OFB_HOME/tpl/default/cache/
@@ -39,23 +54,25 @@
$OFB_HOME/tests (You will need to create the directory tests/ first).
Sample directory structure:
+
/opt/lampp/htdocs
- filebrowser-0.1.7.2/ # $OFB_HOME
- class/
- conf/
- ...
- tests/
- OFBUnitTests/ # $OFBUT_HOME
+|- filebrowser-0.1.7.2/ # $OFB_HOME
+| |- class/
+| |- conf/
+| |- ...
+| |- tests/
+| | |- OFBUnitTests/ # $OFBUT_HOME
Running all Tests
=================
-user#> cd $OFBUNITTESTS_HOME
+user#> cd $OFBUT_HOME
user#> phpunit AllTests.php
The last line of the output should be:
OK (xyz tests)
+where xyz is the number of tests.
diff -Naur OFBUnitTests/RELEASENOTES.txt OFBUnitTests_20070910/RELEASENOTES.txt
--- OFBUnitTests/RELEASENOTES.txt 1970-01-01 01:00:00.000000000 +0100
+++ OFBUnitTests_20070910/RELEASENOTES.txt 2007-09-09 22:27:31.313494008 +0200
@@ -0,0 +1,19 @@
+RELEASENOTES Last Update: 2007-09-10
+
+
+OFBUnitTests 20070905
+================================================================================
+* infrastructure for tests implemented
+* Common/OfbTestCase.php and Common/OfbTestSuite.php implemented
+* 2 test suites implemented
+ (see AllTests.php and BrowserTests/AllBrowserTests.php)
+* 2 test cases implemented
+ (see BasicTest.php and MakeDirTest.php in BrowserTests/)
+
+
+OFBUnitTests 20070910
+================================================================================
+* 1 test case implemented
+ (see BrowserTests/DeleteItemTest.php)
+* Common/OfbTestCase.php enhanced
+ (see function deleteAllItems())