]> git.mxchange.org Git - friendica.git/commitdiff
Remove old tests
authorPierre Rudloff <contact@rudloff.pro>
Mon, 9 Apr 2018 21:03:29 +0000 (23:03 +0200)
committerPierre Rudloff <contact@rudloff.pro>
Mon, 9 Apr 2018 21:03:29 +0000 (23:03 +0200)
Add tests for the BaseObject class

phpunit.xml
tests/BaseObjectTest.php [new file with mode: 0644]
tests/autoname_test.php [deleted file]
tests/contains_attribute_test.php [deleted file]
tests/expand_acl_test.php [deleted file]
tests/get_tags_test.php [deleted file]
tests/template_test.php [deleted file]
tests/xss_filter_test.php [deleted file]

index a589d345401989305887d820d6e8e3081ecb9cab..6a275ad3fcd4f0534f15a3b9dfb006f92668a034 100644 (file)
@@ -1,10 +1,8 @@
 <?xml version="1.0"?>
-<phpunit>
+<phpunit bootstrap="boot.php">
     <testsuites>
         <testsuite>
-            <directory suffix="_test.php">tests/</directory>
-                       <exclude>tests/template_test.php</exclude>
-                       <exclude>tests/get_tags_test.php</exclude>
+            <directory>tests/</directory>
         </testsuite>
     </testsuites>
 </phpunit>
diff --git a/tests/BaseObjectTest.php b/tests/BaseObjectTest.php
new file mode 100644 (file)
index 0000000..73eb472
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * BaseObjectTest class.
+ */
+
+namespace Friendica\Test;
+
+use Friendica\App;
+use Friendica\BaseObject;
+use PHPUnit_Framework_TestCase;
+
+/**
+ * Tests for the BaseObject class.
+ */
+class BaseObjectTest extends PHPUnit_Framework_TestCase
+{
+
+       /**
+        * Create variables used in tests.
+        */
+       protected function setUp()
+       {
+               $this->baseObject = new BaseObject();
+       }
+
+       /**
+        * Test the getApp() function.
+        * @return void
+        */
+       public function testGetApp()
+       {
+               $this->assertInstanceOf(App::class, $this->baseObject->getApp());
+       }
+
+       /**
+        * Test the setApp() function.
+        * @return void
+        */
+       public function testSetApp()
+       {
+               $app = new App(__DIR__.'/../');
+               $this->assertNull($this->baseObject->setApp($app));
+               $this->assertEquals($app, $this->baseObject->getApp());
+       }
+}
diff --git a/tests/autoname_test.php b/tests/autoname_test.php
deleted file mode 100644 (file)
index 03a7ebf..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
- * this file contains tests for the autoname function
- * 
- * @package test.util
- */
-
-/** required, it is the file under test */
-require_once('include/text.php');
-
-/**
- * TestCase for the autoname function
- * 
- * @author Alexander Kampmann
- * @package test.util
- */
-class AutonameTest extends PHPUnit_Framework_TestCase {
-       /**
-        *autonames should be random, even length
-        */
-       public function testAutonameEven() {
-               $autoname1=autoname(10);
-               $autoname2=autoname(10);
-       
-               $this->assertNotEquals($autoname1, $autoname2);
-       }
-       
-       /**
-        *autonames should be random, odd length
-        */
-       public function testAutonameOdd() {
-               $autoname1=autoname(9);
-               $autoname2=autoname(9);
-       
-               $this->assertNotEquals($autoname1, $autoname2);
-       }
-       
-       /**
-        * try to fail autonames
-        */
-       public function testAutonameNoLength() {
-               $autoname1=autoname(0);
-               $this->assertEquals(0, strlen($autoname1));
-       }
-       
-       /**
-        * try to fail it with invalid input
-        * 
-        * TODO: What's corect behaviour here? An exception?
-        */
-       public function testAutonameNegativeLength() {
-               $autoname1=autoname(-23);
-               $this->assertEquals(0, strlen($autoname1));
-       }
-       
-       //      public function testAutonameMaxLength() {
-       //              $autoname2=autoname(PHP_INT_MAX);
-       //              $this->assertEquals(PHP_INT_MAX, count($autoname2));
-       //      }
-       
-       /**
-        * test with a length, that may be too short
-        */
-       public function testAutonameLength1() {
-               $autoname1=autoname(1);
-               $this->assertEquals(1, count($autoname1));
-               
-               $autoname2=autoname(1);
-               $this->assertEquals(1, count($autoname2));
-
-               // The following test is problematic, with only 26 possibilities
-               // generating the same thing twice happens often aka
-               // birthday paradox
-//             $this->assertFalse($autoname1==$autoname2); 
-       }
-}
\ No newline at end of file
diff --git a/tests/contains_attribute_test.php b/tests/contains_attribute_test.php
deleted file mode 100644 (file)
index b0bb06a..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/**\r
- * this test tests the contains_attribute function\r
- *\r
- * @package test.util\r
- */\r
-\r
-/** required, it is the file under test */\r
-require_once('include/text.php');\r
-\r
-/**\r
- * TestCase for the contains_attribute function\r
- *\r
- * @author Alexander Kampmann\r
- * @package test.util\r
- */\r
-class ContainsAttributeTest extends PHPUnit_Framework_TestCase {
-       /**\r
-        * test attribute contains\r
-        */\r
-       public function testAttributeContains1() {\r
-               $testAttr="class1 notclass2 class3";\r
-               $this->assertTrue(attribute_contains($testAttr, "class3"));\r
-               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
-       }\r
-       \r
-       /**\r
-        * test attribute contains\r
-        */\r
-       public function testAttributeContains2() {\r
-               $testAttr="class1 not-class2 class3";\r
-               $this->assertTrue(attribute_contains($testAttr, "class3"));\r
-               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
-       }\r
-       
-       /**
-        * test with empty input
-        */\r
-       public function testAttributeContainsEmpty() {\r
-               $testAttr="";\r
-               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
-       }\r
-       
-       /**
-        * test input with special chars
-        */\r
-       public function testAttributeContainsSpecialChars() {\r
-               $testAttr="--... %\$รค() /(=?}";\r
-               $this->assertFalse(attribute_contains($testAttr, "class2"));\r
-       }
-}
\ No newline at end of file
diff --git a/tests/expand_acl_test.php b/tests/expand_acl_test.php
deleted file mode 100644 (file)
index 154bc92..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-/**
- * this test tests the expand_acl function
- *
- * @package test.util
- */
-
-/** required, it is the file under test */
-require_once('include/text.php');
-
-/**\r
- * TestCase for the expand_acl function\r
- *\r
- * @author Alexander Kampmann\r
- * @package test.util\r
- */\r
-class ExpandAclTest extends PHPUnit_Framework_TestCase {
-       
-       /**\r
-        * test expand_acl, perfect input\r
-        */\r
-       public function testExpandAclNormal() {\r
-               $text='<1><2><3>';\r
-               $this->assertEquals(array(1, 2, 3), expand_acl($text));\r
-       }\r
-       
-       /**
-        * test with a big number
-        */\r
-       public function testExpandAclBigNumber() {\r
-               $text='<1><'.PHP_INT_MAX.'><15>';\r
-               $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));\r
-       }\r
-       
-       /**
-        * test with a string in it. 
-        * 
-        * TODO: is this valid input? Otherwise: should there be an exception?
-        */\r
-       public function testExpandAclString() {\r
-               $text="<1><279012><tt>"; \r
-               $this->assertEquals(array(1, 279012), expand_acl($text));\r
-       }\r
-       
-       /**
-        * test with a ' ' in it. 
-        * 
-        * TODO: is this valid input? Otherwise: should there be an exception?
-        */\r
-       public function testExpandAclSpace() {\r
-               $text="<1><279 012><32>"; \r
-               $this->assertEquals(array(1, "279", "32"), expand_acl($text));\r
-       }\r
-       
-       /**
-        * test empty input
-        */\r
-       public function testExpandAclEmpty() {\r
-               $text=""; \r
-               $this->assertEquals(array(), expand_acl($text));\r
-       }\r
-       
-       /**
-        * test invalid input, no < at all
-        * 
-        * TODO: should there be an exception?
-        */\r
-       public function testExpandAclNoBrackets() {\r
-               $text="According to documentation, that's invalid. "; //should be invalid\r
-               $this->assertEquals(array(), expand_acl($text));\r
-       }\r
-       
-       /**\r
-        * test invalid input, just open <\r
-        *\r
-        * TODO: should there be an exception?\r
-        */\r
-       public function testExpandAclJustOneBracket1() {\r
-               $text="<Another invalid string"; //should be invalid\r
-               $this->assertEquals(array(), expand_acl($text));\r
-       }\r
-       
-       /**\r
-        * test invalid input, just close >\r
-        *\r
-        * TODO: should there be an exception?\r
-        */\r
-       public function testExpandAclJustOneBracket2() {\r
-               $text="Another invalid> string"; //should be invalid\r
-               $this->assertEquals(array(), expand_acl($text));\r
-       }\r
-       
-       /**\r
-        * test invalid input, just close >\r
-        *\r
-        * TODO: should there be an exception?\r
-        */\r
-       public function testExpandAclCloseOnly() {\r
-               $text="Another> invalid> string>"; //should be invalid\r
-               $this->assertEquals(array(), expand_acl($text));\r
-       }\r
-       
-       /**\r
-        * test invalid input, just open <\r
-        *\r
-        * TODO: should there be an exception?\r
-        */\r
-       public function testExpandAclOpenOnly() {\r
-               $text="<Another< invalid string<"; //should be invalid\r
-               $this->assertEquals(array(), expand_acl($text));\r
-       }\r
-       
-       /**\r
-        * test invalid input, open and close do not match\r
-        *\r
-        * TODO: should there be an exception?\r
-        */\r
-       public function testExpandAclNoMatching1() {\r
-               $text="<Another<> invalid <string>"; //should be invalid\r
-               $this->assertEquals(array(), expand_acl($text));\r
-       }\r
-       
-       /**\r
-        * test invalid input, open and close do not match\r
-        *\r
-        * TODO: should there be an exception?\r
-        */\r
-       public function testExpandAclNoMatching2() {\r
-               $text="<1>2><3>";\r
-// The angles are delimiters which aren't important
-// the important thing is the numeric content, this returns array(1,2,3) currently
-// we may wish to eliminate 2 from the results, though it isn't harmful
-// It would be a better test to figure out if there is any ACL input which can
-// produce this $text and fix that instead.
-//             $this->assertEquals(array(), expand_acl($text));\r
-       }
-       
-       /**\r
-        * test invalid input, empty <>\r
-        *\r
-        * TODO: should there be an exception? Or array(1, 3)\r
-        * (This should be array(1,3) - mike)
-        */\r
-       public function testExpandAclEmptyMatch() {\r
-               $text="<1><><3>";\r
-               $this->assertEquals(array(1,3), expand_acl($text));\r
-       }
-}
\ No newline at end of file
diff --git a/tests/get_tags_test.php b/tests/get_tags_test.php
deleted file mode 100644 (file)
index 79dcb36..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-<?php
-/**
- * This file contains the tests for get_tags and the tag handling in item.php
- * 
- * @package test.util
- */
-
-/**
- * required, because it contains the get_tags() function
- */
-require_once 'include/text.php';
-/**
- * required, because it contains the tag handling
- */
-require_once 'mod/item.php';
-
-/**
- * A class which can be used as replacement for an app if
- * only get_baseurl is used. 
- * 
- * @author Alexander Kampmann
- * @package test.util
- */
-class MockApp {
-       function get_baseurl() {
-               return "baseurl"; 
-       }
-}; 
-
-/**
- * the test should not rely on a database, 
- * so this is a replacement for the database access method q. 
- * 
- * It simulates the user with uid 11 has one contact, named Mike Lastname. 
- * 
- * @param string $sql
- */
-function q($sql) {
-       $result=array(array('id'=>15, 
-                       'attag'=>'', 'network'=>'dfrn', 
-                       'name'=>'Mike Lastname', 'alias'=>'Mike', 
-                       'nick'=>'Mike', 'url'=>"http://justatest.de")); 
-       
-       $args=func_get_args(); 
-
-       //last parameter is always (in this test) uid, so, it should be 11
-       if($args[count($args)-1]!=11) {
-               return; 
-       }
-       
-       
-       if(3==count($args)) {
-               //first call in handle_body, id only
-               if($result[0]['id']==$args[1]) {
-                       return $result; 
-               }
-               //second call in handle_body, name
-               if($result[0]['name']===$args[1]) {
-                       return $result;
-               }
-       }
-       //third call in handle_body, nick or attag
-       if($result[0]['nick']===$args[2] || $result[0]['attag']===$args[1]) {
-               return $result;
-       }
-}
-
-/**
- * replacement for dbesc. 
- * I don't want to test dbesc here, so
- * I just return the input. It won't be a problem, because 
- * the test does not use a real database. 
- * 
- * DON'T USE HAT FUNCTION OUTSIDE A TEST!
- * 
- * @param string $str
- * @return input
- */
-function dbesc($str) {
-       return $str; 
-}
-
-/**
- * TestCase for tag handling. 
- * 
- * @author alexander
- * @package test.util
- */
-class GetTagsTest extends PHPUnit_Framework_TestCase {
-       /** the mock to use as app */
-       private $a; 
-
-       /**
-        * initialize the test. That's a phpUnit function, 
-        * don't change its name.
-        */
-       public function setUp() {
-               $this->a=new MockApp(); 
-       }
-
-       /**
-        * test with one Person tag
-        */
-       public function testGetTagsShortPerson() {
-               $text="hi @Mike";
-
-               $tags=get_tags($text);
-
-               $inform=''; 
-               $str_tags='';
-               foreach($tags as $tag) {
-                       handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
-               }
-
-               //correct tags found?
-               $this->assertEquals(1, count($tags)); 
-               $this->assertTrue(in_array("@Mike", $tags));
-               
-               //correct output from handle_tag?
-               $this->assertEquals("cid:15", $inform); 
-               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
-               $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url]", $text);
-       }
-       
-       /**
-        * test with one Person tag. 
-        * There's a minor spelling mistake...
-        */
-       public function testGetTagsShortPersonSpelling() {
-               $text="hi @Mike.because";
-       
-               $tags=get_tags($text);
-       
-               //correct tags found?
-               $this->assertEquals(1, count($tags));
-               $this->assertTrue(in_array("@Mike.because", $tags));
-               
-               $inform='';
-               $str_tags='';
-               handle_tag($this->a, $text, $inform, $str_tags, 11, $tags[0]);
-       
-               // (mike) - This is a tricky case.
-               // we support mentions as in @mike@example.com - which contains a period.
-               // This shouldn't match anything unless you have a contact named "Mike.because".
-               // We may need another test for "@Mike. because" - which should return the contact
-               // as we ignore trailing periods in tags. 
-//             $this->assertEquals("cid:15", $inform); 
-//             $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
-//             $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url].because", $text);
-
-               $this->assertEquals("", $inform); 
-               $this->assertEquals("", $str_tags);
-
-       }
-       
-       /**
-        * test with two Person tags. 
-        * There's a minor spelling mistake...
-        */
-
-       public function testGetTagsPerson2Spelling() {
-               $text="hi @Mike@campino@friendica.eu";
-       
-               $tags=get_tags($text);
-
-// This construct is not supported. Results are indeterminate                  
-//             $this->assertEquals(2, count($tags)); 
-//             $this->assertTrue(in_array("@Mike", $tags));
-//             $this->assertTrue(in_array("@campino@friendica.eu", $tags));
-       }
-
-       /**
-        * Test with one hash tag.
-        */
-       public function testGetTagsShortTag() {
-               $text="This is a #test_case";
-
-               $tags=get_tags($text);
-
-               $this->assertEquals(1, count($tags));
-               $this->assertTrue(in_array("#test_case", $tags));
-       }
-
-       /**
-        * test with a person and a hash tag
-        */
-       public function testGetTagsShortTagAndPerson() {
-               $text="hi @Mike This is a #test_case";
-
-               $tags=get_tags($text);
-
-               $this->assertEquals(3, count($tags));
-               $this->assertTrue(in_array("@Mike", $tags));
-               $this->assertTrue(in_array("@Mike This", $tags));
-               $this->assertTrue(in_array("#test_case", $tags));
-
-               $inform='';
-               $str_tags='';
-               foreach($tags as $tag) {
-                       handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
-               }
-               
-               $this->assertEquals("cid:15", $inform); 
-               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url],#[url=baseurl/search?tag=test%20case]test case[/url]", $str_tags);
-               $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url] This is a #[url=baseurl/search?tag=test%20case]test case[/url]", $text); 
-               
-       }
-
-       /**
-        * test with a person, a hash tag and some special chars.
-        */
-       public function testGetTagsShortTagAndPersonSpecialChars() {
-               $text="hi @Mike, This is a #test_case.";
-
-               $tags=get_tags($text);
-
-               $this->assertEquals(2, count($tags));
-               $this->assertTrue(in_array("@Mike", $tags));
-               $this->assertTrue(in_array("#test_case", $tags));
-       }
-
-       /**
-        * Test with a person tag and text behind it.
-        */
-       public function testGetTagsPersonOnly() {
-               $text="@Test I saw the Theme Dev group was created.";
-
-               $tags=get_tags($text);
-
-               $this->assertEquals(2, count($tags));
-               $this->assertTrue(in_array("@Test I", $tags));
-               $this->assertTrue(in_array("@Test", $tags));
-       }
-
-       /**
-        * this test demonstrates strange behaviour by intval. 
-        * It makes the next test fail. 
-        */
-       public function testIntval() {
-               $this->assertEquals(15, intval("15 it")); 
-       }
-       
-       /**
-        * test a tag with an id in it
-        */
-       public function testIdTag() {
-               $text="Test with @mike+15 id tag"; 
-               
-               $tags=get_tags($text); 
-               
-               $this->assertEquals(2, count($tags)); 
-               $this->assertTrue(in_array("@mike+15", $tags));
-               
-               //happens right now, but it shouldn't be necessary
-               $this->assertTrue(in_array("@mike+15 id", $tags));
-               
-               $inform='';
-               $str_tags='';
-               foreach($tags as $tag) {
-                       handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
-               }
-               
-               $this->assertEquals("Test with @[url=http://justatest.de]Mike Lastname[/url] id tag", $text);
-               $this->assertEquals("@[url=http://justatest.de]Mike Lastname[/url]", $str_tags);
-               // this test may produce two cid:15 entries - which is OK because duplicates are pruned before delivery
-               $this->assertContains("cid:15",$inform);
-       }
-       
-       /**
-        * test with two persons and one special tag.
-        */
-       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(5, count($tags));
-               $this->assertTrue(in_array("@Mike", $tags));
-               $this->assertTrue(in_array("#test_cases", $tags));
-               $this->assertTrue(in_array("@somebody@friendica.com", $tags));
-               $this->assertTrue(in_array("@somebody@friendica.com may", $tags));
-               $this->assertTrue(in_array("#things", $tags));
-       }
-
-       /**
-        * test with a long text.
-        */
-       public function testGetTags() {
-               $text="hi @Mike, I'm just writing #test_cases, "
-               ." so @somebody@friendica.com may change #things. Of course I "
-               ."look for a lot of #pitfalls, like #tags at the end of a sentence "
-               ."@comment. I hope noone forgets about @fullstops.because that might"
-               ." break #things. @Mike@campino@friendica.eu is also #nice, isn't it? "
-               ."Now, add a @first_last tag. ";
-               
-               $tags=get_tags($text);
-
-               $this->assertTrue(in_array("@Mike", $tags));
-               $this->assertTrue(in_array("#test_cases", $tags));
-               $this->assertTrue(in_array("@somebody@friendica.com", $tags));
-               $this->assertTrue(in_array("#things", $tags));
-               $this->assertTrue(in_array("#pitfalls", $tags));
-               $this->assertTrue(in_array("#tags", $tags));
-               $this->assertTrue(in_array("@comment", $tags));
-               $this->assertTrue(in_array("@fullstops.because", $tags));
-               $this->assertTrue(in_array("#things", $tags));
-               $this->assertTrue(in_array("@Mike", $tags));
-               $this->assertTrue(in_array("#nice", $tags));
-               $this->assertTrue(in_array("@first_last", $tags));
-               
-               //right now, none of the is matched (unsupported)
-//             $this->assertFalse(in_array("@Mike@campino@friendica.eu", $tags));
-//             $this->assertTrue(in_array("@campino@friendica.eu", $tags));
-//             $this->assertTrue(in_array("@campino@friendica.eu is", $tags));
-       }
-
-       /**
-        * test with an empty string
-        */
-       public function testGetTagsEmpty() {
-               $tags=get_tags("");
-               $this->assertEquals(0, count($tags));
-       }
-}
diff --git a/tests/template_test.php b/tests/template_test.php
deleted file mode 100644 (file)
index 1f9f805..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-<?php
-/**\r
- * this file contains tests for the template engine\r
- *\r
- * @package test.util\r
- */\r
-\r
-/** required, it is the file under test */\r
-require_once('include/template_processor.php');
-require_once('include/text.php');
-
-class TemplateMockApp {
-       public $theme_info=array();
-}
-
-if(!function_exists('current_theme')) {
-function current_theme() {\r
-       return 'clean';\r
-}
-}
-
-if(!function_exists('x')) {
-function x($s,$k = NULL) {
-       return false;
-}
-}
-
-if(!function_exists('get_app')) {
-function get_app() {
-       return new TemplateMockApp();
-}
-}
-
-/**\r
- * TestCase for the template engine\r
- *\r
- * @author Alexander Kampmann\r
- * @package test.util\r
- */\r
-class TemplateTest extends PHPUnit_Framework_TestCase {
-
-       public function setUp() {
-               global $t;
-               $t=new Template;
-       }
-
-       public function testListToShort() {
-               @list($first, $second)=array('first');
-
-               $this->assertTrue(is_null($second));
-       }
-
-       public function testSimpleVariableString() {
-               $tpl='Hello $name!';
-
-               $text=replace_macros($tpl, array('$name'=>'Anna'));
-
-               $this->assertEquals('Hello Anna!', $text);
-       }
-
-       public function testSimpleVariableInt() {\r
-               $tpl='There are $num new messages!';\r
-\r
-               $text=replace_macros($tpl, array('$num'=>172));\r
-\r
-               $this->assertEquals('There are 172 new messages!', $text);\r
-       }
-
-       public function testConditionalElse() {\r
-               $tpl='There{{ if $num!=1 }} are $num new messages{{ else }} is 1 new message{{ endif }}!';\r
-\r
-               $text1=replace_macros($tpl, array('$num'=>1));
-               $text22=replace_macros($tpl, array('$num'=>22));\r
-\r
-               $this->assertEquals('There is 1 new message!', $text1);
-               $this->assertEquals('There are 22 new messages!', $text22);\r
-       }
-
-       public function testConditionalNoElse() {\r
-               $tpl='{{ if $num!=0 }}There are $num new messages!{{ endif }}';\r
-\r
-               $text0=replace_macros($tpl, array('$num'=>0));\r
-               $text22=replace_macros($tpl, array('$num'=>22));\r
-\r
-               $this->assertEquals('', $text0);\r
-               $this->assertEquals('There are 22 new messages!', $text22);\r
-       }
-
-       public function testConditionalFail() {\r
-               $tpl='There {{ if $num!=1 }} are $num new messages{{ else }} is 1 new message{{ endif }}!';\r
-\r
-               $text1=replace_macros($tpl, array());\r
-\r
-               //$this->assertEquals('There is 1 new message!', $text1);\r
-       }
-
-       public function testSimpleFor() {\r
-               $tpl='{{ for $messages as $message }} $message {{ endfor }}';\r
-\r
-               $text=replace_macros($tpl, array('$messages'=>array('message 1', 'message 2')));\r
-\r
-               $this->assertEquals(' message 1  message 2 ', $text);\r
-       }
-
-       public function testFor() {\r
-               $tpl='{{ for $messages as $message }} from: $message.from to $message.to {{ endfor }}';\r
-\r
-               $text=replace_macros($tpl, array('$messages'=>array(array('from'=>'Mike', 'to'=>'Alex'), array('from'=>'Alex', 'to'=>'Mike'))));\r
-\r
-               $this->assertEquals(' from: Mike to Alex  from: Alex to Mike ', $text);\r
-       }
-       
-       public function testKeyedFor() {\r
-               $tpl='{{ for $messages as $from=>$to }} from: $from to $to {{ endfor }}';\r
-       \r
-               $text=replace_macros($tpl, array('$messages'=>array('Mike'=>'Alex', 'Sven'=>'Mike')));\r
-       \r
-               $this->assertEquals(' from: Mike to Alex  from: Sven to Mike ', $text);\r
-       }
-
-       public function testForEmpty() {\r
-               $tpl='messages: {{for $messages as $message}} from: $message.from to $message.to  {{ endfor }}';\r
-\r
-               $text=replace_macros($tpl, array('$messages'=>array()));\r
-\r
-               $this->assertEquals('messages: ', $text);\r
-       }
-
-       public function testForWrongType() {\r
-               $tpl='messages: {{for $messages as $message}} from: $message.from to $message.to  {{ endfor }}';\r
-\r
-               $text=replace_macros($tpl, array('$messages'=>11));\r
-\r
-               $this->assertEquals('messages: ', $text);\r
-       }
-
-       public function testForConditional() {\r
-               $tpl='new messages: {{for $messages as $message}}{{ if $message.new }} $message.text{{endif}}{{ endfor }}';\r
-\r
-               $text=replace_macros($tpl, array('$messages'=>array(
-                               array('new'=>true, 'text'=>'new message'),
-                               array('new'=>false, 'text'=>'old message'))));\r
-\r
-               $this->assertEquals('new messages:  new message', $text);\r
-       }
-       
-       public function testConditionalFor() {\r
-               $tpl='{{ if $enabled }}new messages:{{for $messages as $message}} $message.text{{ endfor }}{{endif}}';\r
-       \r
-               $text=replace_macros($tpl, array('$enabled'=>true, 
-                               '$messages'=>array(\r
-                               array('new'=>true, 'text'=>'new message'),\r
-                               array('new'=>false, 'text'=>'old message'))));\r
-       \r
-               $this->assertEquals('new messages: new message old message', $text);\r
-       }
-
-       public function testFantasy() {\r
-               $tpl='Fantasy: {{fantasy $messages}}';\r
-\r
-               $text=replace_macros($tpl, array('$messages'=>'no no'));\r
-\r
-               $this->assertEquals('Fantasy: {{fantasy no no}}', $text);\r
-       }
-
-       public function testInc() {\r
-               $tpl='{{inc field_input.tpl with $field=$myvar}}{{ endinc }}';\r
-\r
-               $text=replace_macros($tpl, array('$myvar'=>array('myfield', 'label', 'value', 'help')));\r
-\r
-               $this->assertEquals("   \n"
-                               ."      <div class='field input'>\n"
-                               ."              <label for='id_myfield'>label</label>\n"
-                               ."              <input name='myfield' id='id_myfield' value=\"value\">\n"
-                               ."              <span class='field_help'>help</span>\n"
-                               ."      </div>\n", $text);\r
-       }
-
-       public function testIncNoVar() {\r
-               $tpl='{{inc field_input.tpl }}{{ endinc }}';\r
-\r
-               $text=replace_macros($tpl, array('$field'=>array('myfield', 'label', 'value', 'help')));\r
-\r
-               $this->assertEquals("   \n      <div class='field input'>\n             <label for='id_myfield'>label</label>\n"\r
-                               ."              <input name='myfield' id='id_myfield' value=\"value\">\n"\r
-                               ."              <span class='field_help'>help</span>\n"\r
-                               ."      </div>\n", $text);\r
-       }
-       
-       public function testDoubleUse() {\r
-               $tpl='Hello $name! {{ if $enabled }} I love you! {{ endif }}';\r
-       \r
-               $text=replace_macros($tpl, array('$name'=>'Anna', '$enabled'=>false));\r
-       \r
-               $this->assertEquals('Hello Anna! ', $text);
-               
-               $tpl='Hey $name! {{ if $enabled }} I hate you! {{ endif }}';\r
-               \r
-               $text=replace_macros($tpl, array('$name'=>'Max', '$enabled'=>true));\r
-               \r
-               $this->assertEquals('Hey Max!  I hate you! ', $text);\r
-       }
-       
-       public function testIncDouble() {\r
-               $tpl='{{inc field_input.tpl with $field=$var1}}{{ endinc }}'
-               .'{{inc field_input.tpl with $field=$var2}}{{ endinc }}';\r
-       \r
-               $text=replace_macros($tpl, array('$var1'=>array('myfield', 'label', 'value', 'help'), 
-                               '$var2'=>array('myfield2', 'label2', 'value2', 'help2')));\r
-               \r
-               $this->assertEquals("   \n"\r
-                               ."      <div class='field input'>\n"\r
-                               ."              <label for='id_myfield'>label</label>\n"\r
-                               ."              <input name='myfield' id='id_myfield' value=\"value\">\n"\r
-                               ."              <span class='field_help'>help</span>\n"\r
-                               ."      </div>\n"
-                               ."      \n"
-                               ."      <div class='field input'>\n"
-                               ."              <label for='id_myfield2'>label2</label>\n"
-                               ."              <input name='myfield2' id='id_myfield2' value=\"value2\">\n"
-                               ."              <span class='field_help'>help2</span>\n"
-                               ."      </div>\n", $text);\r
-       }
-}
\ No newline at end of file
diff --git a/tests/xss_filter_test.php b/tests/xss_filter_test.php
deleted file mode 100644 (file)
index 5bc8e0a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * tests several functions which are used to prevent xss attacks
- *
- * @package test.util
- */
-
-require_once('include/text.php');
-
-class AntiXSSTest extends PHPUnit_Framework_TestCase {
-
-       /**
-        * test, that tags are escaped
-        */
-       public function testEscapeTags() {
-               $invalidstring='<submit type="button" onclick="alert(\'failed!\');" />';
-
-               $validstring=notags($invalidstring);
-               $escapedString=escape_tags($invalidstring);
-
-               $this->assertEquals('[submit type="button" onclick="alert(\'failed!\');" /]', $validstring);
-               $this->assertEquals("&lt;submit type=&quot;button&quot; onclick=&quot;alert('failed!');&quot; /&gt;", $escapedString);
-       }
-
-       /**
-        *xmlify and unxmlify
-        */
-       public function testXmlify() {
-               $text="<tag>I want to break\n this!11!<?hard?></tag>";
-               $xml=xmlify($text);
-               $retext=unxmlify($text);
-
-               $this->assertEquals($text, $retext);
-       }
-
-       /**
-        * xmlify and put in a document
-        */
-       public function testXmlifyDocument() {
-               $tag="<tag>I want to break</tag>";
-               $xml=xmlify($tag);
-               $text='<text>'.$xml.'</text>';
-
-               $xml_parser=xml_parser_create();
-               //should be possible to parse it
-               $values=array(); $index=array();
-               $this->assertEquals(1, xml_parse_into_struct($xml_parser, $text, $values, $index));
-
-               $this->assertEquals(array('TEXT'=>array(0)),
-                               $index);
-               $this->assertEquals(array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),
-                               $values);
-
-               xml_parser_free($xml_parser);
-       }
-
-       /**
-        * test hex2bin and reverse
-        */
-       public function testHex2Bin() {
-               $this->assertEquals(-3, hex2bin(bin2hex(-3)));
-               $this->assertEquals(0, hex2bin(bin2hex(0)));
-               $this->assertEquals(12, hex2bin(bin2hex(12)));
-               $this->assertEquals(PHP_INT_MAX, hex2bin(bin2hex(PHP_INT_MAX)));
-       }
-
-       //function qp, quick and dirty??
-       //get_mentions
-       //get_contact_block, bis Zeile 538
-}