mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/217] Silence errors in tests, not code.
Use a mock user object for testing bbcode. PHPBB3-217
This commit is contained in:
parent
d44b6ba5ca
commit
2d1e426ba7
3 changed files with 25 additions and 1 deletions
|
@ -975,7 +975,7 @@ class bbcode_firstpass extends bbcode
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this a link to somewhere inside this board? If so then remove the session id from the url
|
// Is this a link to somewhere inside this board? If so then remove the session id from the url
|
||||||
if (strpos($url, @generate_board_url()) !== false && strpos($url, 'sid=') !== false)
|
if (strpos($url, generate_board_url()) !== false && strpos($url, 'sid=') !== false)
|
||||||
{
|
{
|
||||||
$url = preg_replace('/(&|\?)sid=[0-9a-f]{32}&/', '\1', $url);
|
$url = preg_replace('/(&|\?)sid=[0-9a-f]{32}&/', '\1', $url);
|
||||||
$url = preg_replace('/(&|\?)sid=[0-9a-f]{32}$/', '', $url);
|
$url = preg_replace('/(&|\?)sid=[0-9a-f]{32}$/', '', $url);
|
||||||
|
|
|
@ -11,6 +11,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
||||||
require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php';
|
require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php';
|
||||||
require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php';
|
require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php';
|
||||||
|
require_once dirname(__FILE__) . '/../mock_user.php';
|
||||||
|
|
||||||
class phpbb_url_bbcode_test extends phpbb_test_case
|
class phpbb_url_bbcode_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
|
@ -30,6 +31,9 @@ class phpbb_url_bbcode_test extends phpbb_test_case
|
||||||
*/
|
*/
|
||||||
public function test_url($message)
|
public function test_url($message)
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
$user = new phpbb_mock_user;
|
||||||
|
|
||||||
$bbcode = new bbcode_firstpass();
|
$bbcode = new bbcode_firstpass();
|
||||||
$bbcode->message = $message;
|
$bbcode->message = $message;
|
||||||
$bbcode->bbcode_init(false);
|
$bbcode->bbcode_init(false);
|
||||||
|
|
20
tests/mock_user.php
Normal file
20
tests/mock_user.php
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2011 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock user class.
|
||||||
|
* This class is used when tests invoke phpBB code expecting to have a global
|
||||||
|
* user object, to avoid instantiating the actual user object.
|
||||||
|
* It has a minimum amount of functionality, just to make tests work.
|
||||||
|
*/
|
||||||
|
class phpbb_mock_user
|
||||||
|
{
|
||||||
|
public $host = "testhost";
|
||||||
|
public $page = array('root_script_path' => '/');
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue