diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-08-03 15:35:34 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-08-03 15:35:34 +0200 |
commit | 33eb9ad53aca850586abe8d896cd718181d480c0 (patch) | |
tree | 689781914f0f2c90904ef832af3d97944b7f0235 | |
parent | b7f97cae792af90e9192570c17d6d91fc901e9ca (diff) | |
parent | 9db1728b4b976c99f5811e578619e37c69e306cd (diff) | |
download | forums-33eb9ad53aca850586abe8d896cd718181d480c0.tar forums-33eb9ad53aca850586abe8d896cd718181d480c0.tar.gz forums-33eb9ad53aca850586abe8d896cd718181d480c0.tar.bz2 forums-33eb9ad53aca850586abe8d896cd718181d480c0.tar.xz forums-33eb9ad53aca850586abe8d896cd718181d480c0.zip |
Merge remote-tracking branch 's9e/ticket/11762' into develop-olympus
* s9e/ticket/11762:
[ticket/11762] Added call to test class's parent::setUp().
[ticket/11762] Fixed test's filename
[ticket/11762] Use the === operator to distinguish "0" from ""
-rw-r--r-- | phpBB/includes/functions_content.php | 4 | ||||
-rw-r--r-- | tests/text_processing/generate_text_for_display_test.php | 38 |
2 files changed, 40 insertions, 2 deletions
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b7650ecd6a..6213d2fd24 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -413,7 +413,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags) { static $bbcode; - if (!$text) + if ($text === '') { return ''; } @@ -459,7 +459,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb $uid = $bitfield = ''; $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); - if (!$text) + if ($text === '') { return; } diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php new file mode 100644 index 0000000000..a157fe7d9a --- /dev/null +++ b/tests/text_processing/generate_text_for_display_test.php @@ -0,0 +1,38 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +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_generate_text_for_display_test extends phpbb_test_case +{ + public function setUp() + { + global $cache, $user; + + parent::setUp(); + + $cache = new phpbb_mock_cache; + + $user = new phpbb_mock_user; + $user->optionset('viewcensors', false); + } + + public function test_empty_string() + { + $this->assertSame('', generate_text_for_display('', '', '', 0)); + } + + public function test_zero_string() + { + $this->assertSame('0', generate_text_for_display('0', '', '', 0)); + } +} |