aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/includes
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2017-10-28 01:22:59 +0200
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2017-10-29 22:00:55 +0100
commit1be98d7b7fea30a929d27e7aa0b1412da3276b2c (patch)
tree7d7d5bbfbed65f89e6232235bf4b5534fe0fa03f /tests/unit/includes
parent66832c41e9fff481c20ca219b3cc0a4e53b8b551 (diff)
downloadvolse-hubzilla-1be98d7b7fea30a929d27e7aa0b1412da3276b2c.tar.gz
volse-hubzilla-1be98d7b7fea30a929d27e7aa0b1412da3276b2c.tar.bz2
volse-hubzilla-1be98d7b7fea30a929d27e7aa0b1412da3276b2c.zip
:white_check_mark: Some more work on unit tests.
Some small improvements for coverage report. Add more functions from include/text.php Update composer dev libraries for phpunit.
Diffstat (limited to 'tests/unit/includes')
-rw-r--r--tests/unit/includes/FeedutilsTest.php29
-rw-r--r--tests/unit/includes/TextTest.php40
2 files changed, 68 insertions, 1 deletions
diff --git a/tests/unit/includes/FeedutilsTest.php b/tests/unit/includes/FeedutilsTest.php
index d27df4939..e9826a73d 100644
--- a/tests/unit/includes/FeedutilsTest.php
+++ b/tests/unit/includes/FeedutilsTest.php
@@ -57,4 +57,33 @@ class FeedutilsTest extends UnitTestCase {
$this->assertXmlStringEqualsXmlString($a, atom_author('tag', 'nick', 'name', 'uri', 72, 72, 'png', 'http://photourl'));
}
+
+ /**
+ * @uses ::xmlify
+ */
+ public function test_atom_render_author() {
+ $xchan = [
+ 'xchan_addr' => 'chan@hub',
+ 'xchan_url' => 'http://hub',
+ 'xchan_name' => 'Chan',
+ 'xchan_photo_l' => 'http://hub/img',
+ 'xchan_photo_mimetype' => 'mimetype'
+ ];
+ // There is no input validation in atom_render_author
+ //$this->assertEquals('', atom_render_author('', $xchan));
+
+ $a = '<tag>
+ <as:object-type>http://activitystrea.ms/schema/1.0/person</as:object-type>
+ <id>http://hub</id>
+ <name>chan</name>
+ <uri>http://hub</uri>
+ <link rel="alternate" type="text/html" href="http://hub" />
+ <link rel="photo" type="mimetype" media:width="300" media:height="300" href="http://hub/img" />
+ <link rel="avatar" type="mimetype" media:width="300" media:height="300" href="http://hub/img" />
+ <poco:preferredUsername>chan</poco:preferredUsername>
+ <poco:displayName>Chan</poco:displayName>
+</tag>';
+
+ $this->assertXmlStringEqualsXmlString($a, atom_render_author('tag', $xchan));
+ }
}
diff --git a/tests/unit/includes/TextTest.php b/tests/unit/includes/TextTest.php
index acc490001..97fa64895 100644
--- a/tests/unit/includes/TextTest.php
+++ b/tests/unit/includes/TextTest.php
@@ -5,7 +5,7 @@ namespace Zotlabs\Tests\Unit\includes;
use Zotlabs\Tests\Unit\UnitTestCase;
/**
- * @brief Unit Test case for include/texter.php file.
+ * @brief Unit Test case for include/text.php file.
*
* @author ken restivo
*/
@@ -79,4 +79,42 @@ empty line above';
$this->assertEquals('<div>invalid position removed</div>', purify_html('<div style="top:10p">invalid position removed</div>', true));
}
+ /**
+ * @dataProvider notagsProvider
+ */
+ public function testNotags($string, $expected) {
+ $this->assertEquals($expected, notags($string));
+ }
+ public function notagsProvider() {
+ return [
+ 'empty string' => ['', ''],
+ 'simple tag' => ['<value>', '[value]'],
+ 'tag pair' => ['<b>text</b>', '[b]text[/b]'],
+ 'double angle bracket' => ['<<value', '[[value'],
+ 'HTML entity &gt;' => ['&gt;', '&gt;']
+ ];
+ }
+
+ /**
+ * @dataProvider sanitise_aclProvider
+ */
+ public function testSanitise_acl($string, $expected) {
+ sanitise_acl($string);
+ $this->assertEquals($expected, $string);
+ }
+ public function sanitise_aclProvider() {
+ return [
+ 'text' => ['value', '<value>'],
+ 'text with angle bracket' => ['<value>', '<[value]>'],
+ 'comma separated acls' => ['value1,value2', '<value1,value2>']
+ ];
+ }
+
+ public function testUnsetSanitise_acl() {
+ $empty = '';
+ sanitise_acl($empty);
+ $this->assertTrue(isset($empty)); // unset() not working? Would expect false
+ $this->assertEmpty($empty);
+ }
+
}