aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mock/file_downloader.php27
-rw-r--r--tests/version/version_helper_remote_test.php16
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;
-}