diff options
Diffstat (limited to 'tests/text_processing')
| -rw-r--r-- | tests/text_processing/censor_text_test.php | 16 | ||||
| -rw-r--r-- | tests/text_processing/generate_text_for_display_test.php | 14 | ||||
| -rw-r--r-- | tests/text_processing/make_clickable_test.php | 57 | 
3 files changed, 72 insertions, 15 deletions
| diff --git a/tests/text_processing/censor_text_test.php b/tests/text_processing/censor_text_test.php index f0e13638a5..983a5ba2d3 100644 --- a/tests/text_processing/censor_text_test.php +++ b/tests/text_processing/censor_text_test.php @@ -1,16 +1,18 @@  <?php  /**  * -* @package testing -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */  require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';  require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; -require_once dirname(__FILE__) . '/../mock/user.php'; -require_once dirname(__FILE__) . '/../mock/cache.php';  class phpbb_text_processing_censor_text_test extends phpbb_test_case  { @@ -19,7 +21,7 @@ class phpbb_text_processing_censor_text_test extends phpbb_test_case  		global $cache, $user;  		$cache = new phpbb_mock_cache;  		$user = new phpbb_mock_user; -		 +  		$user->optionset('viewcensors', false);  		return array( @@ -61,7 +63,7 @@ class phpbb_text_processing_censor_text_test extends phpbb_test_case  			array('badword1 badword2 badword3 badword4', 'replacement1 replacement2 replacement3 replacement4'),  			array('badword1 badword2 badword3 badword4d', 'replacement1 replacement2 replacement3 badword4d'),  			array('abadword1 badword2 badword3 badword4', 'replacement1 replacement2 replacement3 replacement4'), -			 +  			array("new\nline\ntest", "new\nline\ntest"),  			array("tab\ttest\t", "tab\ttest\t"),  			array('öäü', 'öäü'), diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index a157fe7d9a..057416da33 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package testing -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -16,7 +20,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca  {  	public function setUp()  	{ -		global $cache, $user; +		global $cache, $user, $phpbb_dispatcher;  		parent::setUp(); @@ -24,6 +28,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca  		$user = new phpbb_mock_user;  		$user->optionset('viewcensors', false); + +		$phpbb_dispatcher = new phpbb_mock_event_dispatcher();  	}  	public function test_empty_string() diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php index db0812319d..95e304dd97 100644 --- a/tests/text_processing/make_clickable_test.php +++ b/tests/text_processing/make_clickable_test.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file.  *  */ @@ -12,7 +16,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';  class phpbb_text_processing_make_clickable_test extends phpbb_test_case  { -	static public function make_clickable_data() +	public function make_clickable_data()  	{  		// value => whether it should work  		$prefix_texts = array( @@ -100,5 +104,50 @@ class phpbb_text_processing_make_clickable_test extends phpbb_test_case  		$this->assertEquals($expected, $result, $label);  	} +	public function make_clickable_mixed_serverurl_data() +	{ +		$urls = array( +			'http://thisdomain.org' => array('tag' => 'm', 'url' => false, 'text' => false), +			'http://thisdomain.org/' => array('tag' => 'm', 'url' => false, 'text' => false), +			'http://thisdomain.org/1' => array('tag' => 'm', 'url' => false, 'text' => false), +			'http://thisdomain.org/path/some?query=abc#test' => array('tag' => 'm', 'url' => false, 'text' => false), + +			'https://www.phpbb.com' => array('tag' => 'm', 'url' => false, 'text' => false), +			'https://www.phpbb.com/' => array('tag' => 'm', 'url' => false, 'text' => false), +			'https://www.phpbb.com/1' => array('tag' => 'l', 'url' => false, 'text' => '1'), +			'https://www.phpbb.com/path/some?query=abc#test' => array('tag' => 'l', 'url' => false, 'text' => 'path/some?query=abc#test'), +		); + +		$test_data = array(); + +		// run the test for each combination +		foreach ($urls as $url => $url_type) +		{ +			// false means it's the same as the url, less typing +			$url_type['url'] = ($url_type['url']) ? $url_type['url'] : $url; +			$url_type['text'] = ($url_type['text']) ? $url_type['text'] : $url; + +			$class = ($url_type['tag'] === 'l') ? 'postlink-local' : 'postlink'; + +			// replace the url with the desired output format +			$output = '<!-- ' . $url_type['tag'] . ' --><a class="' . $class . '" href="' . $url_type['url'] . '">' . $url_type['text'] . '</a><!-- ' . $url_type['tag'] . ' -->'; + +			$test_data[] = array($url, $output); +		} + +		return $test_data; +	} + +	/** +	* @dataProvider make_clickable_mixed_serverurl_data +	*/ +	public function test_make_clickable_mixed_serverurl($input, $expected) +	{ +		$result = make_clickable($input, 'https://www.phpbb.com'); + +		$label = 'Making text clickable: ' . $input; +		$this->assertEquals($expected, $result, $label); +	} +  } | 
