Skip to content

Commit

Permalink
added first phpunit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dom-mel committed Apr 1, 2012
1 parent 9d421a3 commit 7390717
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
15 changes: 15 additions & 0 deletions _testing/README
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions _testing/unittest.xml
Original file line number Diff line number Diff line change
@@ -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>
9 changes: 9 additions & 0 deletions _testing/unittests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -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');
28 changes: 28 additions & 0 deletions _testing/unittests/inc/common_cleanText.test.php
Original file line number Diff line number Diff line change
@@ -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 :

0 comments on commit 7390717

Please sign in to comment.