aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml11
-rwxr-xr-xgit-tools/commit-msg-hook-range.sh29
-rw-r--r--phpBB/adm/style/editor.js2
-rw-r--r--phpBB/feed.php79
-rw-r--r--phpBB/includes/db/db_tools.php2
-rw-r--r--phpBB/includes/functions_module.php6
-rw-r--r--phpBB/includes/functions_profile_fields.php2
-rw-r--r--phpBB/includes/search/fulltext_native.php39
-rw-r--r--phpBB/language/en/acp/board.php2
-rw-r--r--phpBB/language/en/common.php3
-rw-r--r--phpBB/search.php6
-rw-r--r--phpBB/styles/prosilver/template/editor.js2
-rw-r--r--phpBB/styles/subsilver2/template/editor.js2
-rw-r--r--tests/profile/get_profile_value_test.php42
14 files changed, 173 insertions, 54 deletions
diff --git a/.travis.yml b/.travis.yml
index f576f1c800..1e5f453c76 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,9 +8,7 @@ php:
- 5.6
env:
- - DB=mariadb
- DB=mysql
- - DB=postgres
before_script:
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi"
@@ -25,4 +23,11 @@ before_script:
script:
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then phpunit --configuration travis/phpunit-$DB-travis.xml; else phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml; fi"
- - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH...FETCH_HEAD; fi"
+ - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi"
+
+matrix:
+ include:
+ - php: 5.4
+ env: DB=mariadb
+ - php: 5.4
+ env: DB=postgres
diff --git a/git-tools/commit-msg-hook-range.sh b/git-tools/commit-msg-hook-range.sh
index 66628c1d17..2b408c3e79 100755
--- a/git-tools/commit-msg-hook-range.sh
+++ b/git-tools/commit-msg-hook-range.sh
@@ -5,26 +5,47 @@
#
# Calls the git commit-msg hook on all non-merge commits in a given commit range.
#
-set -e
if [ "$#" -ne 1 ];
then
- echo "Expected one argument (commit range, e.g. eef1b586...1666476b)."
+ echo "Expected one argument (commit range, e.g. phpbb/develop..ticket/12345)."
exit
fi
DIR=$(dirname "$0")
-COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg"
-
COMMIT_RANGE="$1"
+COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg"
+COMMIT_MSG_HOOK_FATAL=$(git config --bool phpbb.hooks.commit-msg.fatal 2> /dev/null)
+git config phpbb.hooks.commit-msg.fatal true
+EXIT_STATUS=0
for COMMIT_HASH in $(git rev-list --no-merges "$COMMIT_RANGE")
do
+ echo "Inspecting commit message of commit $COMMIT_HASH"
+
# The git commit-msg hook takes a path to a file containing a commit
# message. So we have to extract the commit message into a file first,
# which then also needs to be deleted after our work is done.
COMMIT_MESSAGE_PATH="$DIR/commit_msg.$COMMIT_HASH"
git log -n 1 --pretty=format:%B "$COMMIT_HASH" > "$COMMIT_MESSAGE_PATH"
+
+ # Invoke hook on commit message file.
"$COMMIT_MSG_HOOK_PATH" "$COMMIT_MESSAGE_PATH"
+
+ # If any commit message hook complains with a non-zero exit status, we
+ # will send a non-zero exit status upstream.
+ if [ $? -ne 0 ]
+ then
+ EXIT_STATUS=1
+ fi
+
rm "$COMMIT_MESSAGE_PATH"
done
+
+# Restore phpbb.hooks.commit-msg.fatal config
+if [ -n "$COMMIT_MSG_HOOK_FATAL" ]
+then
+ git config phpbb.hooks.commit-msg.fatal "$COMMIT_MSG_HOOK_FATAL"
+fi
+
+exit $EXIT_STATUS
diff --git a/phpBB/adm/style/editor.js b/phpBB/adm/style/editor.js
index 217aa699e2..cad01aa9f2 100644
--- a/phpBB/adm/style/editor.js
+++ b/phpBB/adm/style/editor.js
@@ -292,7 +292,7 @@ function mozWrap(txtarea, open, close)
*/
function storeCaret(textEl)
{
- if (textEl.createTextRange)
+ if (textEl.createTextRange && document.selection)
{
textEl.caretPos = document.selection.createRange().duplicate();
}
diff --git a/phpBB/feed.php b/phpBB/feed.php
index 9816f0f303..04bb0f40ea 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -71,6 +71,9 @@ if ($feed === false)
trigger_error('NO_FEED');
}
+// Get attachments for this feed
+$feed->fetch_attachments();
+
// Open Feed
$feed->open();
@@ -106,7 +109,7 @@ while ($row = $feed->get_item())
'title' => censor_text($title),
'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '',
'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '',
- 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options)),
+ 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $feed->attachments[$row['post_id']] : array()))),
'statistics' => '',
);
@@ -272,8 +275,16 @@ function feed_format_date($time)
/**
* Generate text content
+*
+* @param string $content is feed text content
+* @param string $uid is bbcode_uid
+* @param string $bitfield is bbcode bitfield
+* @param int $options bbcode flag options
+* @param int $forum_id is the forum id
+* @param array $post_attachments is an array containing the attachments and their respective info
+* @return string the html content to be printed for the feed
**/
-function feed_generate_content($content, $uid, $bitfield, $options)
+function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments)
{
global $user, $config, $phpbb_root_path, $phpEx, $board_url;
@@ -322,8 +333,15 @@ function feed_generate_content($content, $uid, $bitfield, $options)
// Remove some specials html tag, because somewhere there are a mod to allow html tags ;)
$content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' <strong>$1</strong> ', $content);
+ // Parse inline images to display with the feed
+ if (!empty($post_attachments))
+ {
+ $update_count = array();
+ parse_attachments($forum_id, $content, $post_attachments, $update_count);
+ }
+
// Remove Comments from inline attachments [ia]
- $content = preg_replace('#<div class="(inline-attachment|attachtitle)">(.*?)<!-- ia(.*?) -->(.*?)<!-- ia(.*?) -->(.*?)</div>#si','$4',$content);
+ $content = preg_replace('#<dd>(.*?)</dd>#','',$content);
// Replace some entities with their unicode counterpart
$entities = array(
@@ -341,6 +359,9 @@ function feed_generate_content($content, $uid, $bitfield, $options)
// Other control characters
$content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content);
+ // Convert attachments' relative path to absolute path
+ $content = str_replace($phpbb_root_path . 'download/file.' . $phpEx, $board_url . '/download/file.' . $phpEx, $content);
+
return $content;
}
@@ -660,6 +681,7 @@ class phpbb_feed_base
class phpbb_feed_post_base extends phpbb_feed_base
{
var $num_items = 'feed_limit_post';
+ var $attachments = array();
function set_keys()
{
@@ -693,6 +715,45 @@ class phpbb_feed_post_base extends phpbb_feed_base
. (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : '');
}
}
+
+ function fetch_attachments()
+ {
+ global $db;
+
+ $sql_array = array(
+ 'SELECT' => 'a.*',
+ 'FROM' => array(
+ ATTACHMENTS_TABLE => 'a'
+ ),
+ 'WHERE' => 'a.in_message = 0 ',
+ 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC',
+ );
+
+ if (isset($this->topic_id))
+ {
+ $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id;
+ }
+ else if (isset($this->forum_id))
+ {
+ $sql_array['LEFT_JOIN'] = array(
+ array(
+ 'FROM' => array(TOPICS_TABLE => 't'),
+ 'ON' => 'a.topic_id = t.topic_id',
+ )
+ );
+ $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id;
+ }
+
+ $sql = $db->sql_build_query('SELECT', $sql_array);
+ $result = $db->sql_query($sql);
+
+ // Set attachments in feed items
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $this->attachments[$row['post_msg_id']][] = $row;
+ }
+ $db->sql_freeresult($result);
+ }
}
/**
@@ -795,7 +856,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base
// Get the actual data
$this->sql = array(
'SELECT' => 'f.forum_id, f.forum_name, ' .
- 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
+ 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' .
'u.username, u.user_id',
'FROM' => array(
USERS_TABLE => 'u',
@@ -927,7 +988,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base
}
$this->sql = array(
- 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
+ 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' .
'u.username, u.user_id',
'FROM' => array(
POSTS_TABLE => 'p',
@@ -1092,7 +1153,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base
global $auth, $db;
$this->sql = array(
- 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
+ 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' .
'u.username, u.user_id',
'FROM' => array(
POSTS_TABLE => 'p',
@@ -1257,7 +1318,7 @@ class phpbb_feed_news extends phpbb_feed_topic_base
$this->sql = array(
'SELECT' => 'f.forum_id, f.forum_name,
t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, t.topic_last_post_time,
- p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url',
+ p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment',
'FROM' => array(
TOPICS_TABLE => 't',
POSTS_TABLE => 'p',
@@ -1330,7 +1391,7 @@ class phpbb_feed_topics extends phpbb_feed_topic_base
$this->sql = array(
'SELECT' => 'f.forum_id, f.forum_name,
t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, t.topic_last_post_time,
- p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url',
+ p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment',
'FROM' => array(
TOPICS_TABLE => 't',
POSTS_TABLE => 'p',
@@ -1427,7 +1488,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base
'SELECT' => 'f.forum_id, f.forum_name,
t.topic_id, t.topic_title, t.topic_replies, t.topic_replies_real, t.topic_views,
t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time,
- p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url',
+ p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment',
'FROM' => array(
TOPICS_TABLE => 't',
POSTS_TABLE => 'p',
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php
index f63ff18cbe..e394b1ffa0 100644
--- a/phpBB/includes/db/db_tools.php
+++ b/phpBB/includes/db/db_tools.php
@@ -477,7 +477,7 @@ class phpbb_db_tools
// here lies an array, filled with information compiled on the column's data
$prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data);
- if (isset($prepared_column['auto_increment']) && strlen($column_name) > 26) // "${column_name}_gen"
+ if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen"
{
trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR);
}
diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php
index d0e7c8cfc8..0cc2425b28 100644
--- a/phpBB/includes/functions_module.php
+++ b/phpBB/includes/functions_module.php
@@ -436,21 +436,21 @@ class p_master
if ($this->active_module === false)
{
- trigger_error('Module not accessible', E_USER_ERROR);
+ trigger_error('MODULE_NOT_ACCESS', E_USER_ERROR);
}
if (!class_exists("{$this->p_class}_$this->p_name"))
{
if (!file_exists("$module_path/{$this->p_class}_$this->p_name.$phpEx"))
{
- trigger_error("Cannot find module $module_path/{$this->p_class}_$this->p_name.$phpEx", E_USER_ERROR);
+ trigger_error($user->lang('MODULE_NOT_FIND', "$module_path/{$this->p_class}_$this->p_name.$phpEx"), E_USER_ERROR);
}
include("$module_path/{$this->p_class}_$this->p_name.$phpEx");
if (!class_exists("{$this->p_class}_$this->p_name"))
{
- trigger_error("Module file $module_path/{$this->p_class}_$this->p_name.$phpEx does not contain correct class [{$this->p_class}_$this->p_name]", E_USER_ERROR);
+ trigger_error($user->lang('MODULE_FILE_INCORRECT_CLASS', "$module_path/{$this->p_class}_$this->p_name.$phpEx", "{$this->p_class}_$this->p_name"), E_USER_ERROR);
}
if (!empty($mode))
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index 8573533c2c..a2c0656ca4 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -532,7 +532,7 @@ class custom_profile
switch ($this->profile_types[$field_type])
{
case 'int':
- if ($value === '' && !$ident_ary['data']['field_show_novalue'])
+ if (($value === '' || $value === null) && !$ident_ary['data']['field_show_novalue'])
{
return NULL;
}
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index dc961f3c8a..29c5a72874 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -231,7 +231,12 @@ class fulltext_native extends search_backend
}
$db->sql_freeresult($result);
}
- unset($exact_words);
+
+ // Handle +, - without preceeding whitespace character
+ $match = array('#(\S)\+#', '#(\S)-#');
+ $replace = array('$1 +', '$1 +');
+
+ $keywords = preg_replace($match, $replace, $keywords);
// now analyse the search query, first split it using the spaces
$query = explode(' ', $keywords);
@@ -357,39 +362,21 @@ class fulltext_native extends search_backend
$this->{$mode . '_ids'}[] = $words[$word];
}
}
- // throw an error if we shall not ignore unexistant words
- else if (!$ignore_no_id)
+ else
{
if (!isset($common_ids[$word]))
{
$len = utf8_strlen($word);
- if ($len >= $this->word_length['min'] && $len <= $this->word_length['max'])
- {
- trigger_error(sprintf($user->lang['WORD_IN_NO_POST'], $word));
- }
- else
+ if ($len < $this->word_length['min'] || $len > $this->word_length['max'])
{
$this->common_words[] = $word;
}
}
}
- else
- {
- $len = utf8_strlen($word);
- if ($len < $this->word_length['min'] || $len > $this->word_length['max'])
- {
- $this->common_words[] = $word;
- }
- }
- }
-
- // we can't search for negatives only
- if (!sizeof($this->must_contain_ids))
- {
- return false;
}
- if (!empty($this->search_query))
+ // Return true if all words are not common words
+ if (sizeof($exact_words) - sizeof($this->common_words) > 0)
{
return true;
}
@@ -428,6 +415,12 @@ class fulltext_native extends search_backend
return false;
}
+ // we can't search for negatives only
+ if (empty($this->must_contain_ids))
+ {
+ return false;
+ }
+
$must_contain_ids = $this->must_contain_ids;
$must_not_contain_ids = $this->must_not_contain_ids;
$must_exclude_one_ids = $this->must_exclude_one_ids;
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index ccd12fcb6a..f9a40c2bc7 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -44,7 +44,7 @@ $lang = array_merge($lang, array(
'DEFAULT_LANGUAGE' => 'Default language',
'DEFAULT_STYLE' => 'Default style',
'DISABLE_BOARD' => 'Disable board',
- 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users. You can also enter a short (255 character) message to display if you wish.',
+ 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users who are neither administrators nor moderators. You can also enter a short (255 character) message to display if you wish.',
'OVERRIDE_STYLE' => 'Override user style',
'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s style with the default.',
'SITE_DESC' => 'Site description',
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index f37f6d3b30..62c18c109c 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -341,6 +341,9 @@ $lang = array_merge($lang, array(
'MODERATE' => 'Moderate',
'MODERATOR' => 'Moderator',
'MODERATORS' => 'Moderators',
+ 'MODULE_NOT_ACCESS' => 'Module not accessible',
+ 'MODULE_NOT_FIND' => 'Cannot find module %s',
+ 'MODULE_FILE_INCORRECT_CLASS' => 'Module file %s does not contain correct class [%s]',
'MONTH' => 'Month',
'MOVE' => 'Move',
'MSNM' => 'MSNM/WLM',
diff --git a/phpBB/search.php b/phpBB/search.php
index ad9c371f63..0f13dbbfa0 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -540,12 +540,6 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}
- // For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options.
- if (!sizeof($id_ary) && !$search_id)
- {
- trigger_error('NO_SEARCH_RESULTS');
- }
-
$sql_where = '';
if (sizeof($id_ary))
diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js
index c16b0ef703..42be70be92 100644
--- a/phpBB/styles/prosilver/template/editor.js
+++ b/phpBB/styles/prosilver/template/editor.js
@@ -347,7 +347,7 @@ function mozWrap(txtarea, open, close)
*/
function storeCaret(textEl)
{
- if (textEl.createTextRange)
+ if (textEl.createTextRange && document.selection)
{
textEl.caretPos = document.selection.createRange().duplicate();
}
diff --git a/phpBB/styles/subsilver2/template/editor.js b/phpBB/styles/subsilver2/template/editor.js
index 151cf53ff1..103a271a71 100644
--- a/phpBB/styles/subsilver2/template/editor.js
+++ b/phpBB/styles/subsilver2/template/editor.js
@@ -351,7 +351,7 @@ function mozWrap(txtarea, open, close)
*/
function storeCaret(textEl)
{
- if (textEl.createTextRange)
+ if (textEl.createTextRange && document.selection)
{
textEl.caretPos = document.selection.createRange().duplicate();
}
diff --git a/tests/profile/get_profile_value_test.php b/tests/profile/get_profile_value_test.php
new file mode 100644
index 0000000000..a5f37a85ce
--- /dev/null
+++ b/tests/profile/get_profile_value_test.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_profile_fields.php';
+
+class phpbb_profile_get_profile_value_test extends phpbb_test_case
+{
+ static public function get_profile_value_int_data()
+ {
+ return array(
+ array(FIELD_INT, '10', true, 10),
+ array(FIELD_INT, '0', true, 0),
+ array(FIELD_INT, '', true, 0),
+ array(FIELD_INT, null, true, 0),
+ array(FIELD_INT, '10', false, 10),
+ array(FIELD_INT, '0', false, 0),
+ array(FIELD_INT, '', false, null),
+ array(FIELD_INT, null, false, null),
+ );
+ }
+
+ /**
+ * @dataProvider get_profile_value_int_data
+ */
+ public function test_get_profile_value_int($type, $value, $show_novalue, $expected)
+ {
+ $cp = new custom_profile;
+ $this->assertSame($expected, $cp->get_profile_value(array(
+ 'value' => $value,
+ 'data' => array(
+ 'field_type' => $type,
+ 'field_show_novalue' => $show_novalue,
+ ),
+ )));
+ }
+}