aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Kampmann <programmer@nurfuerspam.de>2012-03-12 13:59:00 +0100
committerAlexander Kampmann <programmer@nurfuerspam.de>2012-03-12 13:59:00 +0100
commitbce3bfff38ad6f540dca39f6ed5b1d8cae19edb1 (patch)
tree7c93dc521b771408c7269e9af934ec809c665c10 /tests
parentf8042d04451905486fb766c520736f4060ae9a12 (diff)
downloadvolse-hubzilla-bce3bfff38ad6f540dca39f6ed5b1d8cae19edb1.tar.gz
volse-hubzilla-bce3bfff38ad6f540dca39f6ed5b1d8cae19edb1.tar.bz2
volse-hubzilla-bce3bfff38ad6f540dca39f6ed5b1d8cae19edb1.zip
get tags test improved
Diffstat (limited to 'tests')
-rw-r--r--tests/get_tags_test.php40
1 files changed, 37 insertions, 3 deletions
diff --git a/tests/get_tags_test.php b/tests/get_tags_test.php
index a458f0fbc..ee2daced1 100644
--- a/tests/get_tags_test.php
+++ b/tests/get_tags_test.php
@@ -8,11 +8,45 @@ require_once 'include/text.php';
require_once 'mod/item.php';
function q($sql) {
- return array(array('id'=>15, 'network'=>'stat', 'alias'=>'Mike', 'nick'=>'Mike', 'url'=>"http://justatest.de"));
+
+ $result=array(array('id'=>15,
+ 'attag'=>'', 'network'=>'dfrn',
+ 'name'=>'Mike Lastname', 'alias'=>'Mike',
+ 'nick'=>'Mike', 'url'=>"http://justatest.de"));
+
+ $args=func_get_args();
+ $str="";
+ foreach($args as $arg) {
+ $str.=", ".$arg;
+ }
+
+ //last parameter is always (in this test) uid, so, it should be 11
+ if($args[count($args)-1]!=11) {
+ throw new Exception("q from get_tags_test was used and uid was not 11. ");
+ }
+
+ if(2==count($args)) {
+ //first call in handle_body, id only
+ if($result[0]['id']===$args[1]) {
+ return $result;
+ }
+ throw new Exception($str);
+ //second call in handle_body, name
+ if($result[0]['name']===$args[1]) {
+ return $result;
+ }
+ }
+ throw new Exception($str);
+ //third call in handle_body, nick or attag
+ if($result[0]['nick']===$args[2] || $result[0]['attag']===$args[1]) {
+ return $result;
+ }
+// throw new Exception("Nothing fitted: ".$args[1].", ".$args[2]);
}
+
function dbesc($str) {
- echo $str;
+ return $str;
}
class GetTagsTest extends PHPUnit_Framework_TestCase {
@@ -39,7 +73,7 @@ class GetTagsTest extends PHPUnit_Framework_TestCase {
handle_body($text, $inform, $str_tags, 11, $tags[0]);
$this->assertEquals("@Mike", $tags[0]);
- $this->assertEquals($text, "hi @[url=http://justatest.de]Mike[/url]");
+ $this->assertEquals("hi @[url=http://justatest.de]Mike Lastname[/url]", $text);
}
/**