[ticket/301] Cover InvalidArgumentException in phpbb_fetch_posts

B3P-301
This commit is contained in:
Marc Alexander
2014-07-09 20:05:08 +02:00
parent 0a276c6ec6
commit 63be896ca4

View File

@@ -26,6 +26,7 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
$user->data['user_id'] = 2; $user->data['user_id'] = 2;
$user->timezone = new \DateTimeZone('UTC'); $user->timezone = new \DateTimeZone('UTC');
$user->add_lang('common'); $user->add_lang('common');
$user->add_lang('../../ext/board3/portal/language/en/portal');
$phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists')); $cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists'));
$cache->expects($this->any()) $cache->expects($this->any())
@@ -93,23 +94,31 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
'attachments', 'attachments',
'forum_name', 'forum_name',
)), )),
array('announcements', array(), true), array('announcements', array(), 5, true),
array('news', array(), 0),
array('foobar', array(), 5, false, '\InvalidArgumentException'),
); );
} }
/** /**
* @dataProvider data_phpbb_fetch_news * @dataProvider data_phpbb_fetch_news
*/ */
public function test_phpbb_fetch_news($type, $expected_columns, $empty = false) public function test_phpbb_fetch_news($type, $expected_columns, $number_of_posts = 5, $empty = false, $expected_exception = false)
{ {
$module_id = 5; $module_id = 5;
$forum_from = ''; $forum_from = '';
$permissions = false; $permissions = false;
$number_of_posts = 5;
$text_length = 150; $text_length = 150;
$time = time(); $time = time();
$start = 0;
$invert = false;
$fetch_posts = phpbb_fetch_posts($module_id, $forum_from, $permissions, $number_of_posts, $text_length, $time, $type); if ($expected_exception)
{
$this->setExpectedException($expected_exception);
}
$fetch_posts = phpbb_fetch_posts($module_id, $forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start, $invert);
if (!$empty) if (!$empty)
{ {