From 63dfdd32ff7fd4073dce9de26aa2f3eb32ec9acd Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 14 Feb 2019 14:58:11 -0800 Subject: [PATCH] isBbcode and isHtml() tests --- tests/unit/e107Test.php | 6 ++++-- tests/unit/e_parseTest.php | 43 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/tests/unit/e107Test.php b/tests/unit/e107Test.php index 931bc6cbe..23ef32852 100644 --- a/tests/unit/e107Test.php +++ b/tests/unit/e107Test.php @@ -932,12 +932,14 @@ */ public function testIsInstalled() { - $result = $this->e107::isInstalled('user'); + $obj = $this->e107; + + $result = $obj::isInstalled('user'); // var_dump($result); $this->assertTrue($result); - $result = $this->e107::isInstalled('news'); + $result = $obj::isInstalled('news'); // var_dump($result); $this->assertTrue($result); diff --git a/tests/unit/e_parseTest.php b/tests/unit/e_parseTest.php index 7648718be..0c468ab3f 100644 --- a/tests/unit/e_parseTest.php +++ b/tests/unit/e_parseTest.php @@ -514,17 +514,56 @@ TMP; { } +*/ + public function testIsBBcode() { + $tests = array( + 0 => array("My Simple Text", false), // input , expected result + 1 => array("
", false), + 2 => array("[b]Bbcode[/b]", true), + 3 => array("
[code]something[/code]
", false), + 4 => array("[code]<b>someting</b>[/code]", true), + 5 => array("[html]something[/html]", false), + 6 => array("http://something.com/index.php?what=ever", false) + ); + + + foreach($tests as $val) + { + list($input, $expected) = $val; + $actual = $this->tp->isBbcode($input); + + $this->assertEquals($expected, $actual, $input); + } } public function testIsHtml() { + $tests = array( + 0 => array("My Simple Text", false), // input , expected result + 1 => array("
", true), + 2 => array("[b]Bbcode[/b]", false), + 3 => array("
[code]something[/code]
", true), + 4 => array("[code]<b>someting</b>[/code]", false), + 5 => array("[html]something[/html]", true), + 6 => array("http://something.com/index.php?what=ever", false) + ); + + + foreach($tests as $val) + { + list($input, $expected) = $val; + $actual = $this->tp->isHtml($input); + + $this->assertEquals($expected, $actual, $input); + } + } - +/* public function testIsJSON() { @@ -560,7 +599,7 @@ TMP; $result = $tp->makeClickable($email, 'email', array('sub' => '[email]')); - $this->assertContains('[email]', $result); + $this->assertContains('[email]', $result); // -----