[ticket/301] Extend phpbb_fetch_posts coverage to 100%
B3P-301
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
|
||||
|
||||
class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
@@ -19,18 +20,15 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
global $auth, $cache, $phpbb_container, $phpbb_dispatcher, $user;
|
||||
global $auth, $cache, $config, $phpbb_container, $phpbb_dispatcher, $template, $user;
|
||||
|
||||
$auth = new \phpbb\auth\auth();
|
||||
$phpbb_container = new \phpbb_mock_container_builder();
|
||||
$phpbb_container->set('board3.portal.modules_helper', new \board3\portal\includes\modules_helper($auth));
|
||||
$user = new \phpbb\user();
|
||||
$user->data['user_id'] = 2;
|
||||
$user->timezone = new \DateTimeZone('UTC');
|
||||
$user->add_lang('common');
|
||||
$user->add_lang('../../ext/board3/portal/language/en/portal');
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put'));
|
||||
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions'));
|
||||
$cache->expects($this->any())
|
||||
->method('obtain_word_list')
|
||||
->with()
|
||||
@@ -40,6 +38,19 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
|
||||
->with($this->anything())
|
||||
->will($this->returnValue(false));
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_content.php');
|
||||
$config = new \phpbb\config\config(array('allow_attachments' => 1));
|
||||
$auth = new \phpbb\auth\auth();
|
||||
$userdata = array(
|
||||
'user_id' => 2,
|
||||
);
|
||||
$auth->acl($userdata);
|
||||
// Pretend to allow downloads
|
||||
$auth->acl[0][0] = true;
|
||||
// Pretend to allow downloads in forum 1
|
||||
$auth->acl[1][0] = true;
|
||||
$phpbb_container = new \phpbb_mock_container_builder();
|
||||
$phpbb_container->set('board3.portal.modules_helper', new \board3\portal\includes\modules_helper($auth));
|
||||
$template = $this->getMock('\phpbb\template', array('set_filenames', 'destroy_block_vars', 'assign_block_vars', 'assign_display'));
|
||||
}
|
||||
|
||||
public function getDataSet()
|
||||
@@ -102,13 +113,62 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
|
||||
)),
|
||||
array('announcements', array(), array('topic_icons', 'topic_count'), 5, ''),
|
||||
array('news', array(), array(), 0),
|
||||
array('foobar', array(), array(), 5, '', false, false, false, '\InvalidArgumentException'),
|
||||
array('news', array(), array(), 5, '', true, true),
|
||||
array('foobar', array(), array(), 5, '', false, false, false, 150, '\InvalidArgumentException'),
|
||||
array('news', array(
|
||||
'forum_id',
|
||||
'topic_id',
|
||||
'topic_last_post_time',
|
||||
'topic_replies',
|
||||
'topic_replies_real',
|
||||
'topic_type',
|
||||
'topic_status',
|
||||
'topic_posted',
|
||||
'attachment',
|
||||
'forum_name',
|
||||
'topic_title',
|
||||
'username',
|
||||
'username_full',
|
||||
'username_full_last',
|
||||
'user_type',
|
||||
'user_id',
|
||||
'topic_time',
|
||||
'post_text',
|
||||
'topic_views',
|
||||
'icon_id',
|
||||
'poll',
|
||||
'attachments',
|
||||
'forum_name',
|
||||
), array(), 5, '', false, true),
|
||||
array('announcements', array(), array('topic_icons', 'topic_count'), 5, '3'),
|
||||
array('announcements', array(), array(), 5, '1,2', true, true),
|
||||
array('announcements', array(), array('topic_icons', 'topic_count'), 5, '1,2', false, true),
|
||||
array('news', array(), array(), 5, '1,2', true, false, true),
|
||||
array('announcements', array(), array(), 5, '', true, true),
|
||||
array('announcements', array(), array('topic_icons', 'topic_count'), 5, '', false, true),
|
||||
array('announcements', array(), array(), 5, '1,2', true, true, true),
|
||||
array('news', array(
|
||||
'forum_id',
|
||||
'topic_id',
|
||||
'topic_last_post_time',
|
||||
'topic_replies',
|
||||
'topic_replies_real',
|
||||
'topic_type',
|
||||
'topic_status',
|
||||
'topic_posted',
|
||||
'attachment',
|
||||
'forum_name',
|
||||
'topic_title',
|
||||
'username',
|
||||
'username_full',
|
||||
'username_full_last',
|
||||
'user_type',
|
||||
'user_id',
|
||||
'topic_time',
|
||||
'post_text',
|
||||
'topic_views',
|
||||
'icon_id',
|
||||
'poll',
|
||||
'attachments',
|
||||
'forum_name',
|
||||
), array(), 5, '', false, true, false, 5),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,10 +176,9 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
|
||||
* @dataProvider data_phpbb_fetch_news
|
||||
*/
|
||||
public function test_phpbb_fetch_news($type, $expected_columns, $expected_main_columns = array(), $number_of_posts = 5, $forum_from = '', $empty = false, $permissions = false,
|
||||
$invert = false, $expected_exception = false)
|
||||
$invert = false, $text_length = 150, $expected_exception = false)
|
||||
{
|
||||
$module_id = 5;
|
||||
$text_length = 150;
|
||||
$time = time();
|
||||
$start = 0;
|
||||
|
||||
@@ -179,4 +238,14 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
|
||||
$fetch_posts = phpbb_fetch_posts(5, '', false, 5, 150, time(), 'announcements');
|
||||
$this->assertEmpty($fetch_posts);
|
||||
}
|
||||
|
||||
public function test_no_allowed_forums()
|
||||
{
|
||||
global $auth;
|
||||
|
||||
$auth = new \phpbb\auth\auth();
|
||||
|
||||
$fetch_posts = phpbb_fetch_posts(5, '2', true, 5, 150, time(), 'announcements');
|
||||
$this->assertSame(array(), $fetch_posts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_acl_options">
|
||||
<column>auth_option_id</column>
|
||||
<column>auth_option</column>
|
||||
<column>is_global</column>
|
||||
<column>is_local</column>
|
||||
<column>founder_only</column>
|
||||
<row>
|
||||
<value>93</value>
|
||||
<value>u_download</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>7</value>
|
||||
<value>f_download</value>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_attachments">
|
||||
<column>attach_id</column>
|
||||
<column>post_msg_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>poster_id</column>
|
||||
<column>physical_filename</column>
|
||||
<column>real_filename</column>
|
||||
<column>attach_comment</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>foobar</value>
|
||||
<value>foobar</value>
|
||||
<value>foobar</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_topics">
|
||||
<column>forum_id</column>
|
||||
<column>topic_id</column>
|
||||
@@ -25,14 +64,14 @@
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>1404830663</value>
|
||||
<value>1404830663</value>
|
||||
<value>test post</value>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
<value></value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value>2</value>
|
||||
@@ -64,6 +103,20 @@
|
||||
<value>2</value>
|
||||
<value>1404830663</value>
|
||||
<value>foobar post</value>
|
||||
<value>1</value>
|
||||
<value>foobar</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1404830663</value>
|
||||
<value>foobar post</value>
|
||||
<value>0</value>
|
||||
<value>foobar</value>
|
||||
<value>1</value>
|
||||
|
||||
Reference in New Issue
Block a user