From 8e4c5db766ce23d05b8507991b04fece743147de Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Wed, 25 Oct 2017 01:57:18 +0200 Subject: :arrow_up: Update Text_LanguageDetect. Update from v0.3.0 (2012) to v1.0.0 (2017) which should remove some warnings and improve PHP7 support. Using composer to handle this PEAR library now. Fix a problem in FeedutilsTest. --- tests/unit/includes/FeedutilsTest.php | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/unit/includes/FeedutilsTest.php (limited to 'tests/unit/includes/FeedutilsTest.php') diff --git a/tests/unit/includes/FeedutilsTest.php b/tests/unit/includes/FeedutilsTest.php new file mode 100644 index 000000000..d27df4939 --- /dev/null +++ b/tests/unit/includes/FeedutilsTest.php @@ -0,0 +1,60 @@ +assertEquals('id', normalise_id('id')); + $this->assertEquals('id', normalise_id('X-ZOT:id')); + $this->assertEquals('id id2', normalise_id('X-ZOT:id X-ZOT:id2')); + $this->assertEmpty(normalise_id('')); + } + + public function test_encode_rel_links() { + // invalid params return empty array + $this->assertEquals([], encode_rel_links('string')); + $this->assertEquals([], encode_rel_links([])); + + $b = ['attribs' => ['' => [ + 'rel' => 'rel_value', + 'type' => 'type_value', + 'href' => 'href_value', + 'length' => 'length_value', + 'title' => 'title_value' + ]]]; + $blink1 = ['link1' => $b]; + $bresult[] = $b['attribs']['']; + $this->assertEquals($bresult, encode_rel_links($blink1)); + } + +/* public function test_encode_rel_links_fail() { + $a = [ 'key' => 'value']; + $this->assertFalse(encode_rel_links($a)); + //Illegal string offset 'attribs' + }*/ + + /** + * @uses ::xmlify + */ + public function test_atom_author() { + $this->assertEquals('', atom_author('', 'nick', 'name', 'uri', 72, 72, 'png', 'photourl')); + + $a = ' + uri + nick + uri + + + nick + name +'; + + $this->assertXmlStringEqualsXmlString($a, atom_author('tag', 'nick', 'name', 'uri', 72, 72, 'png', 'http://photourl')); + } +} -- cgit v1.2.3 From 1be98d7b7fea30a929d27e7aa0b1412da3276b2c Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sat, 28 Oct 2017 01:22:59 +0200 Subject: :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. --- tests/unit/includes/FeedutilsTest.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/unit/includes/FeedutilsTest.php') 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 = ' + http://activitystrea.ms/schema/1.0/person + http://hub + chan + http://hub + + + + chan + Chan +'; + + $this->assertXmlStringEqualsXmlString($a, atom_render_author('tag', $xchan)); + } } -- cgit v1.2.3