mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/11762] Use the === operator to distinguish "0" from ""
PHPBB3-11762
This commit is contained in:
parent
b7f97cae79
commit
8a02db317e
2 changed files with 38 additions and 2 deletions
|
@ -413,7 +413,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
|
||||||
{
|
{
|
||||||
static $bbcode;
|
static $bbcode;
|
||||||
|
|
||||||
if (!$text)
|
if ($text === '')
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
|
||||||
$uid = $bitfield = '';
|
$uid = $bitfield = '';
|
||||||
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
|
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
|
||||||
|
|
||||||
if (!$text)
|
if ($text === '')
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
36
tests/text_processing/generate_text_for_display.php
Normal file
36
tests/text_processing/generate_text_for_display.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2011 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;
|
||||||
|
|
||||||
|
$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));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue