[ticket/security-171] Modify tests for new file_downloader class

SECURITY-171
This commit is contained in:
Marc Alexander 2014-11-21 23:49:54 +01:00
parent 9649d78fa4
commit f648fe88d5
2 changed files with 31 additions and 12 deletions

View file

@ -0,0 +1,27 @@
<?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.
*
*/
class phpbb_mock_file_downloader extends \phpbb\file_downloader
{
public $data;
public function set($data)
{
$this->data = $data;
}
public function get($host, $directory, $filename, $port = 80, $timeout = 6)
{
return $this->data;
}
}

View file

@ -11,11 +11,9 @@
*
*/
namespace phpbb;
class version_helper_remote_test extends \phpbb_test_case
{
static $remote_data = '';
protected $file_downloader;
protected $cache;
protected $version_helper;
@ -37,10 +35,12 @@ class version_helper_remote_test extends \phpbb_test_case
->method('get')
->with($this->anything())
->will($this->returnValue(false));
$this->file_downloader = new phpbb_mock_file_downloader();
$this->version_helper = new \phpbb\version_helper(
$this->cache,
$config,
$this->file_downloader,
new \phpbb\user('\phpbb\datetime')
);
$this->user = new \phpbb\user('\phpbb\datetime');
@ -153,7 +153,7 @@ class version_helper_remote_test extends \phpbb_test_case
*/
public function test_get_versions($input, $valid_data, $expected_return = '')
{
self::$remote_data = $input;
$this->file_downloader->set($input);;
if (!$valid_data)
{
@ -171,11 +171,3 @@ class version_helper_remote_test extends \phpbb_test_case
$this->assertEquals($expected_return, $return);
}
}
/**
* Mock function for get_remote_file()
*/
function get_remote_file($host, $path, $file, $errstr, $errno)
{
return \phpbb\version_helper_remote_test::$remote_data;
}