SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/tests/bbcodeTest.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. use Sprout\Helpers\BbCode;
  15.  
  16.  
  17. class bbcodeTest extends PHPUnit_Framework_TestCase
  18. {
  19.  
  20. public function testBold()
  21. {
  22. $this->assertTrue(BbCode::inline('aaa') === 'aaa');
  23. $this->assertTrue(BbCode::inline('aa[b]a[/b]') === 'aa<b>a</b>');
  24. $this->assertTrue(BbCode::inline('aa[b]a') === 'aa[b]a');
  25. $this->assertTrue(BbCode::inline('aa[b]a[/b]', array('b')) === 'aa<b>a</b>');
  26. $this->assertTrue(BbCode::inline('aa[b]a[/b]', array()) === 'aa[b]a[/b]');
  27. }
  28.  
  29. public function testUrl()
  30. {
  31. $this->assertTrue(BbCode::inline('aaa') === 'aaa');
  32. $this->assertTrue(BbCode::inline('aa[url=http://example.com]a[/url]') === 'aa<a href="http://example.com">a</a>');
  33. $this->assertTrue(BbCode::inline('aa[url=http://example.com]a') === 'aa[url=http://example.com]a');
  34. $this->assertTrue(BbCode::inline('aa[url http://example.com]a') === 'aa[url http://example.com]a');
  35. $this->assertTrue(BbCode::inline('aa[url http://example.com]a[/url]') === 'aa[url http://example.com]a[/url]');
  36. $this->assertTrue(BbCode::inline('aa[url]a') === 'aa[url]a');
  37. $this->assertTrue(BbCode::inline('aa[url=http://example.com]a[/url]', array('url')) === 'aa<a href="http://example.com">a</a>');
  38. $this->assertTrue(BbCode::inline('aa[url]a[/url]', array()) === 'aa[url]a[/url]');
  39. }
  40.  
  41. }
  42.