diff options
author | Dominik Eckelmann <deckelmann@gmail.com> | 2012-04-01 18:31:34 +0200 |
---|---|---|
committer | Dominik Eckelmann <deckelmann@gmail.com> | 2012-04-01 18:31:34 +0200 |
commit | 739071715cb5267191e4a5b5824fbc28a2fa3ef4 (patch) | |
tree | 5ed3ca4228d2475656047c07c8be4456e50de55c | |
parent | 9d421a3d3c1411a47d49f43cfc1f798f6a96ab8c (diff) | |
download | rpg-739071715cb5267191e4a5b5824fbc28a2fa3ef4.tar.gz rpg-739071715cb5267191e4a5b5824fbc28a2fa3ef4.tar.bz2 |
added first phpunit test
-rw-r--r-- | _testing/README | 15 | ||||
-rw-r--r-- | _testing/unittest.xml | 11 | ||||
-rw-r--r-- | _testing/unittests/bootstrap.php | 9 | ||||
-rw-r--r-- | _testing/unittests/inc/common_cleanText.test.php | 28 |
4 files changed, 63 insertions, 0 deletions
diff --git a/_testing/README b/_testing/README new file mode 100644 index 000000000..02f00fd5d --- /dev/null +++ b/_testing/README @@ -0,0 +1,15 @@ +====== DokuWiki test suite ====== + + +===== Unit Tests ===== + +==== Requirements ==== + * PHP Unit 3.7 + +Installation: +The easiest way to install phpunit is via pear: + pear config-set auto_discover 1 + pear install pear.phpunit.de/PHPUnit + +==== Run unit tests ==== + phpunit -c _testing/unittest.xml
\ No newline at end of file diff --git a/_testing/unittest.xml b/_testing/unittest.xml new file mode 100644 index 000000000..e0058eaca --- /dev/null +++ b/_testing/unittest.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit + bootstrap="unittests/bootstrap.php"> + + <testsuites> + <testsuite> + <directory suffix=".test.php">unittests/</directory> + </testsuite> + </testsuites> + +</phpunit>
\ No newline at end of file diff --git a/_testing/unittests/bootstrap.php b/_testing/unittests/bootstrap.php new file mode 100644 index 000000000..27ca1635e --- /dev/null +++ b/_testing/unittests/bootstrap.php @@ -0,0 +1,9 @@ +<?php + +define('DOKU_UNITTEST',true); +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +define('DOKU_CONF',realpath(dirname(__FILE__).'/../../conf').'/'); + +error_reporting(E_ALL); +set_time_limit(600); +ini_set('memory_limit','128M'); diff --git a/_testing/unittests/inc/common_cleanText.test.php b/_testing/unittests/inc/common_cleanText.test.php new file mode 100644 index 000000000..da0663c5d --- /dev/null +++ b/_testing/unittests/inc/common_cleanText.test.php @@ -0,0 +1,28 @@ +<?php + +require_once DOKU_INC . 'inc/init.php'; +require_once DOKU_INC . 'inc/common.php'; + +class common_clientIP_test extends PHPUnit_Framework_TestCase { + + function test_unix(){ + $unix = 'one + two + + three'; + + $this->assertEquals($unix,cleanText($unix)); + } + + function test_win(){ + $unix = "one\ntwo\nthree"; + $win = "one\r\ntwo\r\nthree"; + + $this->assertEquals(bin2hex($unix), '6f6e650a74776f0a7468726565'); + $this->assertEquals(bin2hex($win), '6f6e650d0a74776f0d0a7468726565'); + $this->assertNotEquals($unix, $win); + $this->assertEquals($unix, cleanText($win)); + } +} + +//Setup VIM: ex: et ts=4 : |