Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ticket/690] Update test for phpBB 3.2.0 and PHP 7.1 compatibility #691

Merged
merged 6 commits into from
Jan 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ matrix:
env: DB=mysqli
- php: 7.0
env: DB=mysqli
- php: 7.1
env: DB=mysqli
allow_failures:
- php: hhvm
fast_finish: true
Expand All @@ -37,7 +39,7 @@ env:
- COVERAGE="1" # Should we send coverage?
- EPV="1" # Should we run EPV (Extension Pre Validator) on your code?
- SPELLCHECK="1" # Should the php files be checked for obvious spelling errors?
- PHPBB_BRANCH="master"
- PHPBB_BRANCH="3.2.x"

branches:
except:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}],
"require": {
"php": ">=5.3.9",
"nickvergessen/phpbb-tool-trimmessage": "1.3.*"
"marc1706/phpbb-text-shortener": "^0.1.0"
},
"require-dev": {
"phpbb/epv": "dev-master"
Expand Down
59 changes: 36 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions modules/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ public function get_template_side($module_id)

foreach ($events as $key => $cur_event)
{
$cur_event['start_time'] = (int) $cur_event['start_time'];
$cur_event['end_time'] = (int) $cur_event['end_time'];

if (($cur_event['start_time'] + $this->time->getOffset()) >= $today_timestamp ||
($cur_event['end_time'] + $this->time->getOffset()) >= $today_timestamp ||
(($cur_event['start_time'] + $this->time->getOffset() + self::TIME_DAY) >= $today_timestamp && $cur_event['all_day']))
Expand Down
2 changes: 1 addition & 1 deletion modules/welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function manage_welcome($value, $key, $module_id)
default:
if (!isset($welcome_message))
{
$welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $this->config['board3_welcome_message_uid_' . $module_id], '');
$welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $this->config['board3_welcome_message_uid_' . $module_id], 0);
}

$this->template->assign_vars(array(
Expand Down
13 changes: 8 additions & 5 deletions portal/fetch_posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function __construct($auth, $cache, $config, $db, $modules_helper, $user)
public function get_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0, $invert = false)
{
$posts = array();
$post_time = $this->get_setting_based_data($time == 0, '', 'AND t.topic_time > ' . (time() - $time * 86400));
$post_time = $this->get_setting_based_data($time == 0, '', 'AND t.topic_time > ' . (time() - (int) $time * 86400));
$forum_from = $this->get_setting_based_data(strpos($forum_from, ',') !== false, explode(',', $forum_from), $this->get_setting_based_data($forum_from != '', array($forum_from), array()));
$topic_icons = array(0);
$have_icons = 0;
Expand Down Expand Up @@ -298,7 +298,9 @@ public function fill_posts_array($row, $text_length, $i, &$have_icons, &$posts,
// Format message
$message = $this->format_message($row, $text_length, $posts[$i]['striped']);

$row['bbcode_options'] = $this->get_setting_based_data($row['enable_bbcode'], OPTION_FLAG_BBCODE, 0) + $this->get_setting_based_data($row['enable_smilies'], OPTION_FLAG_SMILIES, 0) + $this->get_setting_based_data($row['enable_magic_url'], OPTION_FLAG_LINKS, 0);
$row['bbcode_options'] = (int) $this->get_setting_based_data($row['enable_bbcode'], OPTION_FLAG_BBCODE, 0)
+ (int) $this->get_setting_based_data($row['enable_smilies'], OPTION_FLAG_SMILIES, 0)
+ (int) $this->get_setting_based_data($row['enable_magic_url'], OPTION_FLAG_LINKS, 0);
$message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);

if (!empty($attachments))
Expand Down Expand Up @@ -649,10 +651,11 @@ protected function format_message($row, $text_length, &$posts_striped)
*/
public function shorten_message($message, $bbcode_uid, $length)
{
if (class_exists('\Nickvergessen\TrimMessage\TrimMessage'))
if (class_exists('\Marc1706\TextShortener\Shortener'))
{
$trim = new \Nickvergessen\TrimMessage\TrimMessage($message, $bbcode_uid, $length);
$message = $trim->message();
$trim = new \Marc1706\TextShortener\Shortener();
$message = $trim->setText($message)
->shortenText($length);
unset($trim);
}

Expand Down
4 changes: 1 addition & 3 deletions tests/functional/portal_announcement_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public function test_after_announce()

public function test_shortened_message()
{
$this->markTestIncomplete('Trim message tool no longer works correctly for new posts in 3.2.x');

// Create topic as announcement
$data = $this->create_topic(2, 'Portal-announce-global', str_repeat('This is a global announcement for the portal', 6), array(
'topic_type' => POST_GLOBAL,
Expand All @@ -71,7 +69,7 @@ public function test_shortened_message()
{
// no errors should appear on portal
$crawler = self::request('GET', 'app.php/portal');
$this->assertContains('This is a global announc [...]', $crawler->text());
$this->assertContains('This is a global announc ...', $crawler->text());
}
}
}
3 changes: 1 addition & 2 deletions tests/unit/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public function setup_listener()
$manager = new \phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
$finder = new \phpbb\finder(
new \phpbb\filesystem\filesystem(),
dirname(__FILE__) . '/',
new \phpbb_mock_cache()
dirname(__FILE__) . '/'
);
$finder->set_extensions(array_keys($manager->all_enabled()));
$request = new \phpbb_mock_request();
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/includes/modules_helper_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getDataSet()

public function setUp()
{
global $phpbb_root_path, $phpEx;
global $phpbb_root_path, $phpEx, $phpbb_dispatcher;

parent::setUp();

Expand All @@ -37,6 +37,7 @@ public function setUp()
$controller_helper->add_route('board3_portal_controller', 'portal');

$this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, $controller_helper, $request);
$phpbb_dispatcher = new \phpbb_mock_event_dispatcher();
}

public function data_get_disallowed_forums()
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/portal/fetch_posts_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
require_once(dirname(__FILE__) . '/../../../../../../includes/functions.php');
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
require_once(dirname(__FILE__) . '/../../../vendor/nickvergessen/phpbb-tool-trimmessage/src/Nickvergessen/TrimMessage/TrimMessage.php');
require_once(dirname(__FILE__) . '/../../../vendor/nickvergessen/phpbb-tool-trimmessage/src/Nickvergessen/TrimMessage/PhpbbBbcodes.php');
require_once(dirname(__FILE__) . '/../../../vendor/marc1706/phpbb-text-shortener/src/Shortener.php');
require_once(dirname(__FILE__) . '/../../../vendor/marc1706/phpbb-text-shortener/src/Helper.php');
require_once(dirname(__FILE__) . '/../../../vendor/marc1706/phpbb-text-shortener/src/TextIterator.php');


class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\database_test_case
Expand Down