diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/RUNNING_TESTS.md | 12 | ||||
| -rw-r--r-- | tests/avatar/manager_test.php | 54 | ||||
| -rw-r--r-- | tests/cache/apcu_driver_test.php | 58 | ||||
| -rw-r--r-- | tests/dbal/db_tools_test.php | 37 | ||||
| -rw-r--r-- | tests/session/extract_page_test.php | 16 | ||||
| -rw-r--r-- | tests/text_formatter/s9e/factory_test.php | 25 | ||||
| -rw-r--r-- | tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html | 75 | ||||
| -rw-r--r-- | tests/text_processing/generate_text_for_display_test.php | 17 | ||||
| -rw-r--r-- | tests/text_processing/tickets_data/PHPBB3-15261.html | 1 | ||||
| -rw-r--r-- | tests/text_processing/tickets_data/PHPBB3-15261.txt | 1 | ||||
| -rw-r--r-- | tests/text_processing/tickets_data/PHPBB3-15261.xml | 14 | ||||
| -rw-r--r-- | tests/text_processing/tickets_data/PHPBB3-15348.html | 1 | ||||
| -rw-r--r-- | tests/text_processing/tickets_data/PHPBB3-15348.txt | 1 | ||||
| -rw-r--r-- | tests/text_processing/tickets_data/PHPBB3-15348.xml | 33 | ||||
| -rw-r--r-- | tests/version/version_helper_remote_test.php | 105 | 
15 files changed, 409 insertions, 41 deletions
| diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index b082197166..c9941d61e5 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -30,7 +30,9 @@ Some of the functionality in phpBB and/or the test suite uses additional  PHP extensions. If these extensions are not loaded, respective tests  will be skipped: -- apc (APC cache driver) +- apc (APC cache driver, php5 only) +- apcu (APCu cache driver - native API, php7+) +- apcu_bc, apcu (APCu cache driver - APC API, php7+)  - bz2 (compress tests)  - mysql, pdo_mysql (MySQL database driver)  - mysqli, pdo_mysql (MySQLi database driver) @@ -117,6 +119,14 @@ directory (above phpBB):      $ phpBB/vendor/bin/phpunit +To generate an xml log file, run: + +    $ phpBB/vendor/bin/phpunit --log-junit tests/tmp/log/log.xml + +If you are getting a memory exhausted error after running a few tests, you can try running: + +    $ phpBB/vendor/bin/phpunit -d memory_limit=2048M +  Slow tests  -------------- diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 924f1319a2..9e826a3a59 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -384,4 +384,58 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case  			'avatar_height'	=> 0,  		), $row);  	} + +	public function data_remote_avatar_url() +	{ +		return array( +			array('127.0.0.1:91?foo.jpg', 80, 80, array('AVATAR_URL_INVALID')), +			array(gethostbyname('secure.gravatar.com') . '/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), +			array('secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80), +			array(gethostbyname('secure.gravatar.com') . ':120/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), +			array('secure.gravatar.com:80/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), +			array('secure.gravatar.com:80?55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), +			array('secure.gravatar.com?55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), // should be a 404 +			array('2001:db8:0:0:0:0:2:1/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), +			array('secure.gravatar.com/2001:db8:0:0:0:0:2:1/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), +			array('secure.gravatar.com/127.0.0.1:80/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), +		); +	} + +	/** +	 * @dataProvider data_remote_avatar_url +	 */ +	public function test_remote_avatar_url($url, $width, $height, $expected_error = array()) +	{ +		global $phpbb_root_path, $phpEx; + +		if (!function_exists('get_preg_expression')) +		{ +			require($phpbb_root_path . 'includes/functions.' . $phpEx); +		} + +		$this->config['server_name'] = 'foobar.com'; + +		/** @var \phpbb\avatar\driver\remote $remote_avatar */ +		$remote_avatar = $this->manager->get_driver('avatar.driver.remote', false); + +		$request = new phpbb_mock_request(array(), array( +			'avatar_remote_url'		=> $url, +			'avatar_remote_width'	=> $width, +			'avatar_remote_height'	=> $height, +		)); + +		$row = array(); +		$error = array(); + +		$return = $remote_avatar->process_form($request, null, $this->user, $row, $error); +		if (count($expected_error) > 0) +		{ +			$this->assertFalse($return); +		} +		else +		{ +			$this->assertNotEquals(false, $return); +		} +		$this->assertSame($expected_error, $error); +	}  } diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php new file mode 100644 index 0000000000..9de1d82a15 --- /dev/null +++ b/tests/cache/apcu_driver_test.php @@ -0,0 +1,58 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +// Important: apc.enable_cli=1 must be in php.ini. +// http://forums.devshed.com/php-development-5/apc-problem-561290.html +// http://php.net/manual/en/apc.configuration.php + +require_once dirname(__FILE__) . '/common_test_case.php'; + +class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case +{ +	protected static $config; +	protected $driver; + +	public function getDataSet() +	{ +		return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); +	} + +	static public function setUpBeforeClass() +	{ +		if (!extension_loaded('apcu')) +		{ +			self::markTestSkipped('APCu extension is not loaded'); +		} + +		$php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + +		if (!$php_ini->getBool('apc.enabled')) +		{ +			self::markTestSkipped('APCu is not enabled. Make sure apc.enabled=1 in php.ini'); +		} + +		if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli')) +		{ +			self::markTestSkipped('APCu is not enabled for CLI. Set apc.enable_cli=1 in php.ini'); +		} +	} + +	protected function setUp() +	{ +		parent::setUp(); + +		$this->driver = new \phpbb\cache\driver\apcu; + +		$this->driver->purge(); +	} +} diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index b884b4ab95..f9243e7266 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -421,4 +421,41 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case  		$this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2')));  		$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));  	} + +	public function test_create_index_with_long_name() +	{ +		// This constant is being used for checking table prefix. +		$table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) + +		if (strlen($table_prefix) > 20) +		{ +			$this->markTestIncomplete('The table prefix length is too long for proper testing of index shortening function.'); +		} + +		$table_suffix = str_repeat('a', 25 - strlen($table_prefix)); +		$table_name = $table_prefix . $table_suffix; + +		$this->tools->sql_create_table($table_name, $this->table_data); + +		// Index name and table suffix and table prefix have > 30 chars in total. +		// Index name and table suffix have <= 30 chars in total. +		$long_index_name = str_repeat('i', 30 - strlen($table_suffix)); +		$this->assertFalse($this->tools->sql_index_exists($table_name, $long_index_name)); +		$this->assertTrue($this->tools->sql_create_index($table_name, $long_index_name, array('c_timestamp'))); +		$this->assertTrue($this->tools->sql_index_exists($table_name, $long_index_name)); + +		// Index name and table suffix have > 30 chars in total. +		$very_long_index_name = str_repeat('i', 30); +		$this->assertFalse($this->tools->sql_index_exists($table_name, $very_long_index_name)); +		$this->assertTrue($this->tools->sql_create_index($table_name, $very_long_index_name, array('c_timestamp'))); +		$this->assertTrue($this->tools->sql_index_exists($table_name, $very_long_index_name)); + +		$this->tools->sql_table_drop($table_name); + +		// Index name has > 30 chars - that should not be possible. +		$too_long_index_name = str_repeat('i', 31); +		$this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name)); +		$this->setExpectedTriggerError(E_USER_ERROR); +		$this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp')); +	}  } diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index 88eb7b2c1a..f8aa3d27a5 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -136,6 +136,22 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case  					'forum' => 0,  				),  			), +			array( +				'./community', +				'/app.php', +				'', +				'/', +				'/kb', +				array( +					'page_name' => 'app.php/kb', +					'page_dir' => '..', +					'query_string' => '', +					'script_path' => '/', +					'root_script_path' => '/community/', +					'page' => '../app.php/kb', +					'forum' => 0, +				), +			),  		);  	} diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 3d3ea8b794..82b1b0043b 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -32,9 +32,15 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case  		return __DIR__ . '/../../tmp/';  	} -	public function get_factory() +	public function get_factory($styles_path = null)  	{  		global $config, $phpbb_root_path, $request, $user; + +		if (!isset($styles_path)) +		{ +			$styles_path = $phpbb_root_path . 'styles/'; +		} +  		$this->cache = new phpbb_mock_cache;  		$dal = new \phpbb\textformatter\data_access(  			$this->new_dbal(), @@ -42,7 +48,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case  			'phpbb_smilies',  			'phpbb_styles',  			'phpbb_words', -			$phpbb_root_path . 'styles/' +			$styles_path  		);  		$factory = new \phpbb\textformatter\s9e\factory(  			$dal, @@ -68,10 +74,8 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case  		return $factory;  	} -	public function test_get_configurator() +	public function run_configurator_assertions($configurator)  	{ -		$configurator = $this->get_factory()->get_configurator(); -  		$this->assertInstanceOf('s9e\\TextFormatter\\Configurator', $configurator);  		$this->assertTrue(isset($configurator->plugins['Autoemail'])); @@ -97,6 +101,17 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case  		$this->assertTrue(isset($configurator->Emoticons[':D']));  	} +	public function test_get_configurator() +	{ +		$configurator = $this->get_factory()->get_configurator(); +		$this->run_configurator_assertions($configurator); + +		// Test with twigified bbcode.html +		$configurator = $this->get_factory(__DIR__ . '/fixtures/styles/')->get_configurator(); +		$this->run_configurator_assertions($configurator); + +	} +  	public function test_regenerate()  	{  		extract($this->get_factory()->regenerate()); diff --git a/tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html new file mode 100644 index 0000000000..22be395499 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles/prosilver/template/bbcode.html @@ -0,0 +1,75 @@ +{% for ulist_open in loops.ulist_open %}<ul style="list-style-type: {{ LIST_TYPE }}">{% endfor %} +{% for ulist_open_default in loops.ulist_open_default %}<ul>{% endfor %} +{% for ulist_close in loops.ulist_close %}</ul>{% endfor %} + +{% for olist_open in loops.olist_open %}<ol style="list-style-type: {{ LIST_TYPE }}">{% endfor %} +{% for olist_close in loops.olist_close %}</ol>{% endfor %} + +{% for listitem in loops.listitem %}<li>{% endfor %} +{% for listitem_close in loops.listitem_close %}</li>{% endfor %} + +{% for quote_username_open in loops.quote_username_open %}<blockquote><div><cite>{{ USERNAME }} {{ lang('WROTE') }}{{ lang('COLON') }}</cite>{% endfor %} +{% for quote_open in loops.quote_open %}<blockquote class="uncited"><div>{% endfor %} +{% for quote_close in loops.quote_close %}</div></blockquote>{% endfor %} +{% for quote_extended in loops.quote_extended %} +<blockquote> +	<xsl:if test="not(@author)"> +		<xsl:attribute name="class">uncited</xsl:attribute> +	</xsl:if> +	<div> +		<xsl:if test="@author"> +			<cite> +				<xsl:choose> +					<xsl:when test="@url"> +						<a href="{@url}" class="postlink"><xsl:value-of select="@author"/></a> +					</xsl:when> +					<xsl:when test="@profile_url"> +						<a href="{@profile_url}"><xsl:value-of select="@author"/></a> +					</xsl:when> +					<xsl:otherwise> +						<xsl:value-of select="@author"/> +					</xsl:otherwise> +				</xsl:choose> +				<xsl:text> </xsl:text> +				<xsl:value-of select="$L_WROTE"/> +				<xsl:value-of select="$L_COLON"/> +				<xsl:if test="@post_url"> +					<xsl:text> </xsl:text> +					<a href="{@post_url}" data-post-id="{@post_id}" onclick="if(document.getElementById(hash.substr(1)))href=hash">↑</a> +				</xsl:if> +				<xsl:if test="@date"> +					<div class="responsive-hide"><xsl:value-of select="@date"/></div> +				</xsl:if> +			</cite> +		</xsl:if> +		<xsl:apply-templates/> +	</div> +</blockquote> +{% endfor %} + +{% for code_open in loops.code_open %}<div class="codebox"><p>{{ lang('CODE') }}{{ lang('COLON') }} <a href="#" onclick="selectCode(this); return false;">{{ lang('SELECT_ALL_CODE') }}</a></p><pre><code>{% endfor %} +{% for code_close in loops.code_close %}</code></pre></div>{% endfor %} + +{% for inline_attachment_open in loops.inline_attachment_open %}<div class="inline-attachment">{% endfor %} +{% for inline_attachment_close in loops.inline_attachment_close %}</div>{% endfor %} + +{% for b_open in loops.b_open %}<strong class="text-strong">{% endfor %} +{% for b_close in loops.b_close %}</strong>{% endfor %} + +{% for u_open in loops.u_open %}<span style="text-decoration: underline">{% endfor %} +{% for u_close in loops.u_close %}</span>{% endfor %} + +{% for i_open in loops.i_open %}<em class="text-italics">{% endfor %} +{% for i_close in loops.i_close %}</em>{% endfor %} + +{% for color in loops.color %}<span style="color: {{ COLOR }}">{{ TEXT }}</span>{% endfor %} + +{% for size in loops.size %}<span style="font-size: {{ SIZE }}%; line-height: 116%;">{{ TEXT }}</span>{% endfor %} + +{% for img in loops.img %}<img src="{{ URL }}" class="postimage" alt="{{ lang('IMAGE') }}" />{% endfor %} + +{% for url in loops.url %}<a href="{{ URL }}" class="postlink">{{ DESCRIPTION }}</a>{% endfor %} + +{% for email in loops.email %}<a href="mailto:{{ EMAIL }}">{{ DESCRIPTION }}</a>{% endfor %} + +{% for flash in loops.flash %}<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0" width="{{ WIDTH }}" height="{{ HEIGHT }}"><param name="movie" value="{{ URL }}" /><param name="play" value="false" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><embed src="{{ URL }}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="{{ WIDTH }}" height="{{ HEIGHT }}" play="false" loop="false" quality="high" allowscriptaccess="never" allownetworking="internal"></embed></object>{% endfor %} diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 9c7152a008..86bc803c98 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -29,7 +29,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca  	*/  	public function test_legacy($original, $expected, $uid = '', $bitfield = '', $flags = 0, $censor_text = true)  	{ -		global $cache, $user; +		global $auth, $cache, $config, $user;  		global $phpbb_root_path, $phpEx; @@ -63,7 +63,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca  	public function test_censor_is_restored()  	{ -		global $phpbb_container; +		global $auth, $user, $config, $phpbb_container;  		$phpbb_container = new phpbb_mock_container_builder; @@ -72,7 +72,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca  		$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);  		$lang = new \phpbb\language\language($lang_loader);  		$user = new \phpbb\user($lang, '\phpbb\datetime'); -		$user->optionset('viewcensors', false); +		// Do not ignore word censoring by user (switch censoring on in UCP) +		$user->optionset('viewcensors', true);  		$config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -102,6 +103,14 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca  		$this->assertSame('apple', $renderer->render($original));  		$this->assertSame('banana', generate_text_for_display($original, '', '', 0, true));  		$this->assertSame('apple', $renderer->render($original), 'The original setting was not restored'); + +		// Test user option switch to ignore censoring +		$renderer->set_viewcensors(true); +		// 1st: censoring is still on in UCP +		$this->assertSame('banana', generate_text_for_display($original, '', '', 0, true)); +		// 2nd: switch censoring off in UCP +		$user->optionset('viewcensors', false); +		$this->assertSame('apple', generate_text_for_display($original, '', '', 0, true));  	}  	/** @@ -109,7 +118,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca  	*/  	public function test_text_formatter($original, $expected, $censor_text = true, $setup = null)  	{ -		global $phpbb_container; +		global $auth, $user, $config, $phpbb_container;  		$phpbb_container = new phpbb_mock_container_builder; diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.html b/tests/text_processing/tickets_data/PHPBB3-15261.html new file mode 100644 index 0000000000..b563052b47 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.html @@ -0,0 +1 @@ +foo **** baz
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.txt b/tests/text_processing/tickets_data/PHPBB3-15261.txt new file mode 100644 index 0000000000..a8c4a05c10 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.txt @@ -0,0 +1 @@ +foo <bar> baz
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15261.xml b/tests/text_processing/tickets_data/PHPBB3-15261.xml new file mode 100644 index 0000000000..c0d0f395a1 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15261.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> +	<table name="phpbb_words"> +		<column>word_id</column> +		<column>word</column> +		<column>replacement</column> + +		<row> +			<value>1</value> +			<value><*></value> +			<value>****</value> +		</row> +	</table> +</dataset> diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.html b/tests/text_processing/tickets_data/PHPBB3-15348.html new file mode 100644 index 0000000000..e65925ec28 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.html @@ -0,0 +1 @@ +<img class="smilies" src="phpBB/images/smilies/icon_e_surprised.gif" width="15" height="17" alt=":o" title="First half of :ok:"> <img class="smilies" src="phpBB/images/smilies/icon_lol.gif" width="15" height="17" alt="k:" title="Second half of :ok:"> <img alt=":ok:" class="emoji smilies" draggable="false" src="//cdn.jsdelivr.net/emojione/assets/svg/1f197.svg">
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.txt b/tests/text_processing/tickets_data/PHPBB3-15348.txt new file mode 100644 index 0000000000..d6b971702c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.txt @@ -0,0 +1 @@ +:o k: :ok:
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15348.xml b/tests/text_processing/tickets_data/PHPBB3-15348.xml new file mode 100644 index 0000000000..0c88c8824f --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15348.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> +	<table name="phpbb_smilies"> +		<column>smiley_id</column> +		<column>code</column> +		<column>emotion</column> +		<column>smiley_url</column> +		<column>smiley_width</column> +		<column>smiley_height</column> +		<column>smiley_order</column> +		<column>display_on_posting</column> +		<row> +			<value>13</value> +			<value>:o</value> +			<value>First half of :ok:</value> +			<value>icon_e_surprised.gif</value> +			<value>15</value> +			<value>17</value> +			<value>14</value> +			<value>1</value> +		</row> +		<row> +			<value>99</value> +			<value>k:</value> +			<value>Second half of :ok:</value> +			<value>icon_lol.gif</value> +			<value>15</value> +			<value>17</value> +			<value>22</value> +			<value>1</value> +		</row> +	</table> +</dataset> diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index fa383d487f..35c3d92a3a 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -51,8 +51,8 @@ class version_helper_remote_test extends \phpbb_test_case  	public function provider_get_versions()  	{  		return array( -			array('', false), -			array('foobar', false), +			array('', false, '', 'VERSIONCHECK_FAIL'), +			array('foobar', false, '', 'VERSIONCHECK_FAIL'),  			array('{      "stable": {          "1.0": { @@ -93,7 +93,7 @@ class version_helper_remote_test extends \phpbb_test_case              "security": false          }      } -}', false), +}', false, '', 'VERSIONCHECK_FAIL'),  			array('{      "stable": {          "1.0": { @@ -104,26 +104,7 @@ class version_helper_remote_test extends \phpbb_test_case              "security": "<script>alert(\'foo\');</script>"          }      } -}', true, array ( -				'stable' => array ( -					'1.0' => array ( -						'current' => '1.0.1<script>alert(\'foo\');</script>', -						'download' => 'https://www.phpbb.com/customise/db/download/104136<script>alert(\'foo\');</script>', -						'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/<script>alert(\'foo\');</script>', -						'eol' => '<script>alert(\'foo\');</script>', -						'security' => '<script>alert(\'foo\');</script>', -					), -				), -				'unstable' => array ( -					'1.0' => array ( -						'current' => '1.0.1<script>alert(\'foo\');</script>', -						'download' => 'https://www.phpbb.com/customise/db/download/104136<script>alert(\'foo\');</script>', -						'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/<script>alert(\'foo\');</script>', -						'eol' => '<script>alert(\'foo\');</script>', -						'security' => '<script>alert(\'foo\');</script>', -					), -				), -			)), +}', false, null, 'VERSIONCHECK_INVALID_VERSION'),  			array('{      "unstable": {          "1.0": { @@ -134,25 +115,87 @@ class version_helper_remote_test extends \phpbb_test_case              "security": "<script>alert(\'foo\');</script>"          }      } +}', false, null, 'VERSIONCHECK_INVALID_VERSION'), +			array('{ +    "unstable": { +        "1.0<script>alert(\'foo\');</script>": { +            "current": "1.0.1", +            "download": "https://www.phpbb.com/customise/db/download/104136", +            "announcement": "https://www.phpbb.com/customise/db/extension/boardrules/", +            "eol": "", +            "security": "" +        } +    } +}', false, array('stable' => array(), 'unstable' => array()), 'VERSIONCHECK_INVALID_VERSION'), +			array('{ +	"\"\n<script>alert(\'foo\');</script>\n": "test", +    "stable": { +        "1.0": { +            "current": "1.0.1", +            "download": "https://www.phpbb.com/customise/db/download/104136", +            "announcement": "https://www.phpbb.com/customise/db/extension/boardrules/", +            "eol": null, +            "security": false +        } +    }  }', true, array ( +				'stable' => array ( +					'1.0' => array ( +						'current' => '1.0.1', +						'download' => 'https://www.phpbb.com/customise/db/download/104136', +						'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/', +						'eol' => NULL, +						'security' => false, +					), +				),  				'unstable' => array (  					'1.0' => array ( -						'current' => '1.0.1<script>alert(\'foo\');</script>', -						'download' => 'https://www.phpbb.com/customise/db/download/104136<script>alert(\'foo\');</script>', -						'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/<script>alert(\'foo\');</script>', -						'eol' => '<script>alert(\'foo\');</script>', -						'security' => '<script>alert(\'foo\');</script>', +						'current' => '1.0.1', +						'download' => 'https://www.phpbb.com/customise/db/download/104136', +						'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/', +						'eol' => NULL, +						'security' => false,  					),  				), -				'stable' => array(),  			)), +			array('{ +    "unstable": { +        "1.0": { +            "current": "1.0.1", +            "download": "https://www.phpbb.com/customise/db/download/104136", +            "announcement": "https://www.phpbb.com/customise/db/extension/boardrules/", +            "eol": null, +            "security": false, +            "foobar": "<script>alert(\'test\');<script>" +        } +    } +}', true, array('stable' => array(), 'unstable' => array('1.0' => array( +				'current' => '1.0.1', +				'download'	=> 'https://www.phpbb.com/customise/db/download/104136', +				'announcement'	=> 'https://www.phpbb.com/customise/db/extension/boardrules/', +				'security'	=> false, +			))), 'VERSIONCHECK_INVALID_ENTRY'), +			array('{ +    "unstable": { +        "1.0": { +            "current<script>alert(\'foo\');</script>": "1.0.1", +            "download2": "https://www.phpbb.com/customise/db/download/104136", +            "bannouncement": "https://www.phpbb.com/customise/db/extension/boardrules/", +            "eol": null, +            "security": false, +            "foobar": "<script>alert(\'test\');<script>" +        } +    } +}', true, array('stable' => array(), 'unstable' => array('1.0' => array( +				'security'	=> false, +			))), 'VERSIONCHECK_INVALID_ENTRY'),  		);  	}  	/**  	 * @dataProvider provider_get_versions  	 */ -	public function test_get_versions($input, $valid_data, $expected_return = '') +	public function test_get_versions($input, $valid_data, $expected_return = '', $expected_exception = '')  	{  		$this->file_downloader->set($input); @@ -161,7 +204,7 @@ class version_helper_remote_test extends \phpbb_test_case  			try {  				$return = $this->version_helper->get_versions();  			} catch (\phpbb\exception\runtime_exception $e) { -				$this->assertEquals((string)$e->getMessage(), 'VERSIONCHECK_FAIL'); +				$this->assertEquals((string)$e->getMessage(), $expected_exception);  			}  		}  		else | 
