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 +++++++++++++++++++++++++++++++++++ tests/unit/includes/FeedutilsText.php | 55 -------------------------------- tests/unit/includes/LanguageTest.php | 5 ++- 3 files changed, 62 insertions(+), 58 deletions(-) create mode 100644 tests/unit/includes/FeedutilsTest.php delete mode 100644 tests/unit/includes/FeedutilsText.php (limited to 'tests') 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')); + } +} diff --git a/tests/unit/includes/FeedutilsText.php b/tests/unit/includes/FeedutilsText.php deleted file mode 100644 index 932a1b3a1..000000000 --- a/tests/unit/includes/FeedutilsText.php +++ /dev/null @@ -1,55 +0,0 @@ -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' - ]]]; - $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' - }*/ - - 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')); - } -} diff --git a/tests/unit/includes/LanguageTest.php b/tests/unit/includes/LanguageTest.php index 789dbe80b..8bf9ca766 100644 --- a/tests/unit/includes/LanguageTest.php +++ b/tests/unit/includes/LanguageTest.php @@ -52,7 +52,6 @@ class LanguageTest extends UnitTestCase { // Can not unit test detect_language(), therefore test the used library // only for now to find regressions on library updates. - require_once('library/langdet/Text/LanguageDetect.php'); $l = new Text_LanguageDetect; // return 2-letter ISO 639-1 (en) language code $l->setNameMode(2); @@ -71,8 +70,8 @@ class LanguageTest extends UnitTestCase { ], 'English' => [ 'English is a West Germanic language that was first spoken in early medieval England and is now a global lingua franca.[4][5] Named after the Angles, one of the Germanic tribes that migrated to England, it ultimately derives its name from the Anglia (Angeln) peninsula in the Baltic Sea. It is closely related to the Frisian languages, but its vocabulary has been significantly influenced by other Germanic languages, particularly Norse (a North Germanic language), as well as by Latin and Romance languages, especially French.', - 'da', // nearly impossible to find a wikipedia article which is detected as english - 0.000367 // minimum confidence is checked in detect_language(), but that is not yet unit testable + 'en', + 0.078422 ], 'German' => [ 'Deutschland ist ein Bundesstaat in Mitteleuropa. Er besteht aus 16 Ländern und ist als freiheitlich-demokratischer und sozialer Rechtsstaat verfasst. Die Bundesrepublik Deutschland stellt die jüngste Ausprägung des deutschen Nationalstaates dar. Mit rund 82,8 Millionen Einwohnern (31. Dezember 2016) zählt Deutschland zu den dicht besiedelten Flächenstaaten.', -- cgit v1.2.3