bb = $this->make('e_bbcode'); } catch(Exception $e) { $this->assertTrue(false, $e->getMessage()); } $this->bb->__construct(); } /* public function testSetClass() { } public function testResizeWidth() { } public function testGetContent() { } */ public function testHtmltoBBcode() { $text = '

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Paragraph.

Column 1Column 2
link
'; $result = $this->bb->htmltoBbcode($text); $expected = strip_tags($result); $this->assertSame($expected, $result); } public function testImgToBBcode() { $tests = [ 0 => [ 'html' => '

test

', 'expected' =>'

[img title=test]{e_MEDIA_IMAGE}2021-10/test.jpg[/img]

' ], /* 1 => [ 'html' => '

test

', 'expected' =>'

[img title=test]{e_MEDIA_IMAGE}2021-10/test.jpg[/img]

' ],*/ ]; foreach($tests as $count => $t) { $actual = $this->bb->imgToBBcode($t['html']); $this->assertSame($t['expected'], $actual, 'Test '.$count.' failed'); } } /* public function testResizeHeight() { } public function testRenderButtons() { } public function testProcessTag() { } */ public function testParseBBCodes() { $codes = array ( '_br' => array ( ), 'b' => array ( ), 'alert' => array ( 'warning' => array('input'=>'Warning Message', 'expected'=>"
Warning Message
"), ), 'block' => array ( ), 'code' => array ( ), 'glyph' => array ( ), 'h' => array ( ), 'img' => array ( ), 'nobr' => array ( ), 'p' => array ( ), 'video' => array ( ), 'youtube' => array ( ), 'blockquote' => array ( ), 'br' => array ( ), 'center' => array ( ), 'color' => array ( ), 'email' => array ( ), 'file' => array ( ), 'flash' => array ( ), 'hide' => array ( ), 'html' => array ( ), 'i' => array ( ), 'index.html' => array ( ), 'justify' => array ( ), 'left' => array ( ), 'link' => array ( // [bbcode=xxxxxx] param [bbcode]xxxxxx[/bbode] expected output 'http://mysite.com external' => array('input'=>'http://mysite.com', 'expected'=>"http://mysite.com"), 'http://mysite.com rel=external' => array('input'=>'http://mysite.com', 'expected'=>"http://mysite.com"), 'external' => array('input'=>'http://mysite.com', 'expected'=>"http://mysite.com"), 'mailto:myemail@email.com' => array('input'=>'My Name', 'expected'=>"My Name"), 'external=http://mysite.com' => array('input'=>'http://mysite.com', 'expected'=>"http://mysite.com"), ), 'list' => array ( ), 'quote' => array ( 'Ted' => array('input'=>'Quoted Message', 'expected'=>'

Quoted Message

Ted
'), ), 'right' => array ( ), 'sanitised' => array ( ), 'size' => array ( ), 'spoiler' => array ( ), 'stream' => array ( ), 'table' => array ( ), 'tbody' => array ( ), 'td' => array ( ), 'textarea' => array ( ), 'th' => array ( ), 'time' => array ( ), 'tr' => array ( ), 'u' => array ( ), 'url' => array ( ), ); $ret = []; foreach($codes as $bbcode=>$var) { if(empty($var)) { $input = '['.$bbcode.']http://mysite.com[/'.$bbcode.']'; $result = $this->bb->parseBBCodes($input, true); // parsing to check for PHP errors. // $this->assertNotEmpty($result, $input." was empty."); continue; } foreach($var as $parms=>$p) { $input2 = '['.$bbcode.'='.$parms.']'.$p['input'].'[/'.$bbcode.']'; $result2 = $this->bb->parseBBCodes($input2); $this->assertEquals($p['expected'], $result2); } } } /* public function testClearClass() { } public function testGetClass() { } public function testGetMode() { } */ }