public function testBase() { $text = ' Это [b]пример[/b] работы парсера [url=https://github.com/Gemorroj/xBBCode]xBBCode[/url]. [php]$str = "Hello github!"; echo str_replace("github", "world", $str); [/] ссылка http://github.com/Gemorroj/xBBCode картинка [img]https://0.gravatar.com/avatar/ee4c19dc191da0b322d7cfbb29ae36dc[/img] :) http://www.youtube.com/watch?v=qH5IQbpu9NU '; $result = '<br /> Это <strong class="bb">пример</strong> работы парсера <a class="bb" href="https://github.com/Gemorroj/xBBCode">xBBCode</a>.<br /> <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><code class="bb_code"><span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">"Hello github!"</span><span style="color: #339933;">;</span><br /> <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">"github"</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">"world"</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span><br /> </code></div><br /> ссылка <a href="http://github.com/Gemorroj/xBBCode" target="_blank">http://github.com/Gemorroj/xBBCode</a><br /> картинка <img class="bb" src="https://0.gravatar.com/avatar/ee4c19dc191da0b322d7cfbb29ae36dc" alt="" /><br /> <img src="/resources/images/smiles/2.gif" alt="Well" /><br /> <a href="http://www.youtube.com/watch?v=qH5IQbpu9NU" target="_blank">http://www.youtube.com/watch?v=qH5IQbpu9NU</a><br /> '; $xbbcode = new Xbbcode(); $xbbcode->setKeywordLinks(true); $xbbcode->setAutoLinks(true); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [bdo=ltr]xBBCode[/bdo].'; $result = 'test <bdo class="bb" dir="ltr">xBBCode</bdo>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [nobb][p]xBBCode[/p][/nobb].'; $result = 'test [p]xBBCode[/p].'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [font=verdana]xBBCode[/font].'; $result = 'test <font class="bb" face="verdana">xBBCode</font>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [font color=green]xBBCode[/font].'; $result = 'test <font class="bb" color="green">xBBCode</font>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [align=justify]xBBCode[/align].'; $result = 'test <div class="bb" align="justify">xBBCode</div>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [bbcode]xBBCode [b]strong[/b] string [/bbcode].'; $result = 'test <code class="bb bb_code">xBBCode <span class="bb_tag"><span class="bb_bracket">[</span><span class="bb_tagname">b</span><span class="bb_bracket">]</span></span>strong<span class="bb_tag"><span class="bb_bracket">[</span><span class="bb_slash">/</span><span class="bb_tagname">b</span><span class="bb_bracket">]</span></span> string </code>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [acronym=test]xBBCode[/acronym].'; $result = 'test <acronym class="bb" title="test">xBBCode</acronym>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [table]xBBCode[/table].'; $result = 'test <table class="bb">xBBCode</table>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [email]xBBCode@xBBCode.xBBCode[/email].'; $result = 'test <a class="bb" href="mailto:xBBCode@xBBCode.xBBCode">xBBCode@xBBCode.xBBCode</a>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [img alt="lenin"]https://2.gravatar.com/avatar/ee4c19dc191da0b322d7cfbb29ae36dc[/img] xBBCode.'; $result = 'test <img class="bb" src="https://2.gravatar.com/avatar/ee4c19dc191da0b322d7cfbb29ae36dc" alt="lenin" /> xBBCode.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTagFail() { $text = 'test [caption]xBBCode[/caption].'; $result = 'test [caption]xBBCode[/caption].'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [br]xBBCode.'; $result = 'test <br class="bb" />xBBCode.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [address]xBBCode[/address].'; $result = 'test <address class="bb">xBBCode</address>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [b]xBBCode[/b].'; $result = 'test <strong class="bb">xBBCode</strong>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTagPhpKeywords() { $text = 'test [php]function_exists("function_exists");[/php].'; $result = 'test <div class="bb_code"><div class="bb_code_header"><span class="bb_code_lang">PHP</span></div><code class="bb_code"><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">"function_exists"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span></code></div>.'; $xbbcode = new Xbbcode(); $xbbcode->setKeywordLinks(true); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [quote]xBBCode[/quote].'; $result = 'test <blockquote class="bb bb_quote">xBBCode</blockquote>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); $text = 'test [quote=test]xBBCode[/quote].'; $result = 'test <blockquote class="bb bb_quote"><div class="bb_quote_author">test:</div>xBBCode</blockquote>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [google]xBBCode[/google].'; $result = 'test <a class="bb" href="//www.google.com/search?q=xBBCode">xBBCode</a>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); $text = 'test [google=xBBCode]search[/google].'; $result = 'test <a class="bb" href="//www.google.com/search?q=xBBCode">search</a>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [youtube]http://www.youtube.com/watch?v=qH5IQbpu9NU[/youtube].'; $result = 'test <iframe class="bb" frameborder="0" allowfullscreen="allowfullscreen" width="560" height="315" src="//www.youtube.com/embed/qH5IQbpu9NU"></iframe>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); $text = 'test [youtube]qH5IQbpu9NU[/youtube].'; $result = 'test <iframe class="bb" frameborder="0" allowfullscreen="allowfullscreen" width="560" height="315" src="//www.youtube.com/embed/qH5IQbpu9NU"></iframe>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [yandex]xBBCode[/yandex].'; $result = 'test <a class="bb" href="//yandex.com/yandsearch?text=xBBCode">xBBCode</a>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); $text = 'test [yandex=xBBCode]search[/yandex].'; $result = 'test <a class="bb" href="//yandex.com/yandsearch?text=xBBCode">search</a>.'; $xbbcode = new Xbbcode(); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }
public function testTag() { $text = 'test [url=https://github.com/Gemorroj/xBBCode]xBBCode[/url].'; $result = 'test <a class="bb" href="https://github.com/Gemorroj/xBBCode">xBBCode</a>.'; $xbbcode = new Xbbcode(); $xbbcode->setAutoLinks(true); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); $xbbcode = new Xbbcode(); $xbbcode->setAutoLinks(false); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); $text = 'test [url]https://github.com/Gemorroj/xBBCode[/url].'; $result = 'test <a class="bb" href="https://github.com/Gemorroj/xBBCode">https://github.com/Gemorroj/xBBCode</a>.'; $xbbcode = new Xbbcode(); $xbbcode->setAutoLinks(true); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); $xbbcode = new Xbbcode(); $xbbcode->setAutoLinks(false); $xbbcode->parse($text); $this->assertEquals($result, $xbbcode->getHtml()); }