diff options
author | Marc Alexander <admin@m-a-styles.de> | 2014-11-21 23:49:54 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2014-11-21 23:49:54 +0100 |
commit | f648fe88d5bb2a6661d008724f255bb6df2799ca (patch) | |
tree | 335ade7a0deb7fa41ac5ff60c011c4bb17186925 /tests | |
parent | 9649d78fa4cb2583936bbef255d390dfcbb7b28c (diff) | |
download | forums-f648fe88d5bb2a6661d008724f255bb6df2799ca.tar forums-f648fe88d5bb2a6661d008724f255bb6df2799ca.tar.gz forums-f648fe88d5bb2a6661d008724f255bb6df2799ca.tar.bz2 forums-f648fe88d5bb2a6661d008724f255bb6df2799ca.tar.xz forums-f648fe88d5bb2a6661d008724f255bb6df2799ca.zip |
[ticket/security-171] Modify tests for new file_downloader class
SECURITY-171
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mock/file_downloader.php | 27 | ||||
-rw-r--r-- | tests/version/version_helper_remote_test.php | 16 |
2 files changed, 31 insertions, 12 deletions
diff --git a/tests/mock/file_downloader.php b/tests/mock/file_downloader.php new file mode 100644 index 0000000000..d8951cebf6 --- /dev/null +++ b/tests/mock/file_downloader.php @@ -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; + } +} diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index 8eff1dd520..23634cdf0a 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -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; -} |