added some tests
This commit is contained in:
parent
2e3116a11e
commit
f84c191f8d
26
build.xml
26
build.xml
|
@ -1,16 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project name="friendica" default="test">
|
<project name="friendica" default="test">
|
||||||
<!-- set up include directories, this is necessary for the tests to work -->
|
|
||||||
<php>
|
|
||||||
set_include_path(
|
|
||||||
get_include_path() . PATH_SEPARATOR
|
|
||||||
. 'include' . PATH_SEPARATOR
|
|
||||||
. 'library' . PATH_SEPARATOR
|
|
||||||
. 'library/phpsec' . PATH_SEPARATOR
|
|
||||||
. '.' );
|
|
||||||
</php>
|
|
||||||
|
|
||||||
<!-- ====================================================== -->
|
<!-- ====================================================== -->
|
||||||
<!-- Target: clean-test -->
|
<!-- Target: clean-test -->
|
||||||
<!-- deletes directories with old test reports -->
|
<!-- deletes directories with old test reports -->
|
||||||
|
@ -32,15 +22,16 @@
|
||||||
<!-- this target runs all test files -->
|
<!-- this target runs all test files -->
|
||||||
<!-- =================================== -->
|
<!-- =================================== -->
|
||||||
<target name="test" depends="prepare-test">
|
<target name="test" depends="prepare-test">
|
||||||
<coverage-setup database="./report/coverage-database">
|
<!-- coverage-setup database="./report/coverage-database">
|
||||||
<fileset dir=".">
|
<fileset dir=".">
|
||||||
<include name="**/*.php" />
|
<include name="**/*.php" />
|
||||||
<exclude name="*test.php"/>
|
<exclude name="*test.php"/>
|
||||||
<exclude name="./index.php"/>
|
<exclude name="index.php"/>
|
||||||
<exclude name="./library/**"/>
|
<exclude name="library/**"/>
|
||||||
<exclude name="doc/**"/>
|
<exclude name="doc/**"/>
|
||||||
|
<exclude name=".."/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</coverage-setup>
|
</coverage-setup -->
|
||||||
<phpunit printsummary="true">
|
<phpunit printsummary="true">
|
||||||
<batchtest>
|
<batchtest>
|
||||||
<fileset dir="tests">
|
<fileset dir="tests">
|
||||||
|
@ -50,9 +41,9 @@
|
||||||
<formatter type="xml" todir="report" outfile="testlog.xml" />
|
<formatter type="xml" todir="report" outfile="testlog.xml" />
|
||||||
</phpunit>
|
</phpunit>
|
||||||
<phpunitreport infile="report/testlog.xml" todir="report" />
|
<phpunitreport infile="report/testlog.xml" todir="report" />
|
||||||
<coverage-report outfile="report/coverage-database">
|
<!-- coverage-report outfile="report/coverage-database">
|
||||||
<report todir="report" styledir="/home/phing/etc" />
|
<report todir="report" styledir="/home/phing/etc" />
|
||||||
</coverage-report>
|
</coverage-report -->
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- ===================================================== -->
|
<!-- ===================================================== -->
|
||||||
|
@ -75,6 +66,9 @@
|
||||||
<docblox title="Friendica API" destdir="./doc/api">
|
<docblox title="Friendica API" destdir="./doc/api">
|
||||||
<fileset dir=".">
|
<fileset dir=".">
|
||||||
<include name="**/*.php" />
|
<include name="**/*.php" />
|
||||||
|
<include name="README"/>
|
||||||
|
<include name="INSTALL.txt"/>
|
||||||
|
<include name="LICENSE"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</docblox>
|
</docblox>
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -4,10 +4,20 @@
|
||||||
* @package test.util
|
* @package test.util
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once("include/template_processor.php");
|
||||||
require_once('include/text.php');
|
require_once('include/text.php');
|
||||||
|
|
||||||
class AntiXSSTest extends PHPUnit_Framework_TestCase {
|
class AntiXSSTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
|
public function setUp() {
|
||||||
|
set_include_path(
|
||||||
|
get_include_path() . PATH_SEPARATOR
|
||||||
|
. 'include' . PATH_SEPARATOR
|
||||||
|
. 'library' . PATH_SEPARATOR
|
||||||
|
. 'library/phpsec' . PATH_SEPARATOR
|
||||||
|
. '.' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test no tags
|
* test no tags
|
||||||
*/
|
*/
|
||||||
|
@ -180,6 +190,60 @@ class AntiXSSTest extends PHPUnit_Framework_TestCase {
|
||||||
/**
|
/**
|
||||||
* test get_tags
|
* test get_tags
|
||||||
*/
|
*/
|
||||||
|
public function testGetTagsShortPerson() {
|
||||||
|
$text="hi @Mike";
|
||||||
|
|
||||||
|
$tags=get_tags($text);
|
||||||
|
|
||||||
|
$this->assertEquals("@Mike", $tags[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetTagsShortTag() {
|
||||||
|
$text="This is a #test_case";
|
||||||
|
|
||||||
|
$tags=get_tags($text);
|
||||||
|
|
||||||
|
$this->assertEquals("#test_case", $tags[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetTagsShortTagAndPerson() {
|
||||||
|
$text="hi @Mike This is a #test_case";
|
||||||
|
|
||||||
|
$tags=get_tags($text);
|
||||||
|
|
||||||
|
$this->assertEquals("@Mike", $tags[0]);
|
||||||
|
$this->assertEquals("#test_case", $tags[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetTagsShortTagAndPersonSpecialChars() {
|
||||||
|
$text="hi @Mike, This is a #test_case.";
|
||||||
|
|
||||||
|
$tags=get_tags($text);
|
||||||
|
|
||||||
|
$this->assertEquals("@Mike", $tags[0]);
|
||||||
|
$this->assertEquals("#test_case", $tags[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetTagsPersonOnly() {
|
||||||
|
$text="@Mike I saw the Theme Dev group was created.";
|
||||||
|
|
||||||
|
$tags=get_tags($text);
|
||||||
|
|
||||||
|
$this->assertEquals("@Mike", $tags[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetTags2Persons1TagSpecialChars() {
|
||||||
|
$text="hi @Mike, I'm just writing #test_cases, so"
|
||||||
|
." so @somebody@friendica.com may change #things.";
|
||||||
|
|
||||||
|
$tags=get_tags($text);
|
||||||
|
|
||||||
|
$this->assertEquals("@Mike", $tags[0]);
|
||||||
|
$this->assertEquals("#test_cases", $tags[1]);
|
||||||
|
$this->assertEquals("@somebody@friendica.com", $tags[2]);
|
||||||
|
$this->assertEquals("#things", $tags[3]);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetTags() {
|
public function testGetTags() {
|
||||||
$text="hi @Mike, I'm just writing #test_cases, "
|
$text="hi @Mike, I'm just writing #test_cases, "
|
||||||
." so @somebody@friendica.com may change #things. Of course I "
|
." so @somebody@friendica.com may change #things. Of course I "
|
||||||
|
|
|
@ -26,7 +26,7 @@ echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
|
||||||
|
|
||||||
if($build != DB_UPDATE_VERSION) {
|
if($build != DB_UPDATE_VERSION) {
|
||||||
echo "Updating database...";
|
echo "Updating database...";
|
||||||
check_config();
|
check_config($a);
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user