Merge branch 'develop-ascraeus' into develop

* develop-ascraeus:
  [ticket/12422] Add tests
  [ticket/12422] Fix debug warning in log search
This commit is contained in:
Joas Schilling 2014-04-22 19:48:50 +02:00
commit 33e03324d1
3 changed files with 62 additions and 3 deletions

View file

@ -643,9 +643,23 @@ class log implements \phpbb\log\log_interface
$operations = array(); $operations = array();
foreach ($this->user->lang as $key => $value) foreach ($this->user->lang as $key => $value)
{ {
if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) if (substr($key, 0, 4) == 'LOG_')
{ {
$operations[] = $key; if (is_array($value))
{
foreach ($value as $plural_value)
{
if (preg_match($keywords_pattern, $plural_value))
{
$operations[] = $key;
break;
}
}
}
else if (preg_match($keywords_pattern, $value))
{
$operations[] = $key;
}
} }
} }

View file

@ -119,6 +119,18 @@
<value>LOG_USER</value> <value>LOG_USER</value>
<value>a:1:{i:0;s:5:"guest";}</value> <value>a:1:{i:0;s:5:"guest";}</value>
</row> </row>
<row>
<value>10</value>
<value>3</value>
<value>1</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_SINGULAR_PLURAL</value>
<value>a:1:{i:0;i:2;}</value>
</row>
</table> </table>
<table name="phpbb_users"> <table name="phpbb_users">
<column>user_id</column> <column>user_id</column>

View file

@ -206,6 +206,25 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'viewforum' => '', 'viewforum' => '',
'action' => 'LOG_USER guest', 'action' => 'LOG_USER guest',
), ),
10 => array(
'id' => 10,
'reportee_id' => 0,
'reportee_username' => '',
'reportee_username_full'=> '',
'user_id' => 1,
'username' => 'Anonymous',
'username_full' => 'Anonymous',
'ip' => '127.0.0.1',
'time' => 1,
'forum_id' => 0,
'topic_id' => 0,
'viewforum' => '',
'action' => 'LOG_SINGULAR_PLURAL 2',
),
); );
$test_cases = array( $test_cases = array(
@ -277,10 +296,20 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user', 0, 5, 0, 0, 0, 2, 'user', 0, 5, 0, 0, 0, 2,
), ),
array( array(
'expected' => array(8, 9), 'expected' => array(8, 9, 10),
'expected_returned' => 0, 'expected_returned' => 0,
'users', 0, 'users', 0,
), ),
array(
'expected' => array(1),
'expected_returned' => 0,
'admin', false, 5, 0, 0, 0, 0, 0, 'l.log_id ASC', 'install',
),
array(
'expected' => array(10),
'expected_returned' => 0,
'user', false, 5, 0, 0, 0, 0, 0, 'l.log_id ASC', 'plural',
),
); );
foreach ($test_cases as $case => $case_data) foreach ($test_cases as $case => $case_data)
@ -333,6 +362,10 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'LOG_INSTALL_INSTALLED' => 'installed: %s', 'LOG_INSTALL_INSTALLED' => 'installed: %s',
'LOG_USER' => 'User<br /> %s', 'LOG_USER' => 'User<br /> %s',
'LOG_MOD2' => 'Mod2', 'LOG_MOD2' => 'Mod2',
'LOG_SINGULAR_PLURAL' => array(
1 => 'singular',
2 => 'plural (%d)',
),
); );
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);