aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mock
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
commit8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch)
treee0db2bb4a012d5b06a633160b19f62f4868ecd28 /tests/mock
parent36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff)
parent2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff)
downloadforums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'tests/mock')
-rw-r--r--tests/mock/container_builder.php15
-rw-r--r--tests/mock/controller_helper.php14
-rw-r--r--tests/mock/extension_manager.php7
-rw-r--r--tests/mock/fileupload.php3
-rw-r--r--tests/mock/migrator.php4
-rw-r--r--tests/mock/notification_manager.php7
-rw-r--r--tests/mock/notification_type_post.php6
-rw-r--r--tests/mock/phpbb_di_container_builder.php18
-rw-r--r--tests/mock/request.php5
-rw-r--r--tests/mock/router.php27
-rw-r--r--tests/mock/session_testable.php2
-rw-r--r--tests/mock/sql_insert_buffer.php2
12 files changed, 78 insertions, 32 deletions
diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php
index 297e3a65e6..134589b0b8 100644
--- a/tests/mock/container_builder.php
+++ b/tests/mock/container_builder.php
@@ -52,7 +52,15 @@ class phpbb_mock_container_builder implements ContainerInterface
{
if ($this->has($id))
{
- return $this->services[$id];
+ $service = $this->services[$id];
+ if (is_array($service) && is_callable($service[0]))
+ {
+ return call_user_func_array($service[0], $service[1]);
+ }
+ else
+ {
+ return $service;
+ }
}
throw new Exception('Could not find service: ' . $id);
@@ -180,4 +188,9 @@ class phpbb_mock_container_builder implements ContainerInterface
public function isScopeActive($name)
{
}
+
+ public function isFrozen()
+ {
+ return false;
+ }
}
diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php
index ae3e7bf432..0116dced49 100644
--- a/tests/mock/controller_helper.php
+++ b/tests/mock/controller_helper.php
@@ -13,20 +13,6 @@
class phpbb_mock_controller_helper extends \phpbb\controller\helper
{
- public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
- {
- $this->template = $template;
- $this->user = $user;
- $this->config = $config;
- $this->symfony_request = $symfony_request;
- $this->request = $request;
- $this->filesystem = $filesystem;
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $php_ext;
- $provider->find_routing_files($manager->get_finder());
- $this->route_collection = $provider->find($phpbb_root_path_ext)->get_routes();
- }
-
public function get_current_url()
{
return '';
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
index 94268159a8..0d6d110647 100644
--- a/tests/mock/extension_manager.php
+++ b/tests/mock/extension_manager.php
@@ -15,12 +15,15 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager
{
public function __construct($phpbb_root_path, $extensions = array(), $container = null)
{
+ global $phpEx;
+
+ $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = 'php';
$this->extensions = $extensions;
- $this->filesystem = new \phpbb\filesystem();
+ $this->filesystem = new \phpbb\filesystem\filesystem();
$this->container = $container;
$this->config = new \phpbb\config\config(array());
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $this->user = new \phpbb\user($lang,'\phpbb\datetime');
}
}
diff --git a/tests/mock/fileupload.php b/tests/mock/fileupload.php
index 8cc4d77ea1..5a0afc6cd3 100644
--- a/tests/mock/fileupload.php
+++ b/tests/mock/fileupload.php
@@ -19,9 +19,10 @@ class phpbb_mock_fileupload
{
public $max_filesize = 100;
public $error_prefix = '';
+ public $valid_dimensions = true;
public function valid_dimensions($filespec)
{
- return true;
+ return $this->valid_dimensions;
}
}
diff --git a/tests/mock/migrator.php b/tests/mock/migrator.php
index 293f115335..4d1aca0a0a 100644
--- a/tests/mock/migrator.php
+++ b/tests/mock/migrator.php
@@ -21,10 +21,6 @@ class phpbb_mock_migrator extends \phpbb\db\migrator
{
}
- public function set_migrations($class_names)
- {
- }
-
public function update()
{
}
diff --git a/tests/mock/notification_manager.php b/tests/mock/notification_manager.php
index 6a590bc0ca..952c0db489 100644
--- a/tests/mock/notification_manager.php
+++ b/tests/mock/notification_manager.php
@@ -32,19 +32,18 @@ class phpbb_mock_notification_manager
);
}
- public function mark_notifications_read()
+ public function mark_notifications()
{
}
- public function mark_notifications_read_by_parent()
+ public function mark_notifications_by_parent()
{
}
- public function mark_notifications_read_by_id()
+ public function mark_notifications_by_id()
{
}
-
public function add_notifications()
{
return array();
diff --git a/tests/mock/notification_type_post.php b/tests/mock/notification_type_post.php
index 6d8f6dc504..4116fecf5e 100644
--- a/tests/mock/notification_type_post.php
+++ b/tests/mock/notification_type_post.php
@@ -21,11 +21,12 @@ if (!defined('IN_PHPBB'))
class phpbb_mock_notification_type_post extends \phpbb\notification\type\post
{
- public function __construct($user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
+ public function __construct($user_loader, $db, $cache, $language, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table)
{
$this->user_loader = $user_loader;
$this->db = $db;
$this->cache = $cache;
+ $this->language = $language;
$this->user = $user;
$this->auth = $auth;
$this->config = $config;
@@ -34,7 +35,6 @@ class phpbb_mock_notification_type_post extends \phpbb\notification\type\post
$this->php_ext = $php_ext;
$this->notification_types_table = $notification_types_table;
- $this->notifications_table = $notifications_table;
- $this->user_notifications_table = $user_notifications_table;
+ $this->user_notifications_table = $user_notifications_table;
}
}
diff --git a/tests/mock/phpbb_di_container_builder.php b/tests/mock/phpbb_di_container_builder.php
index 59cdf0bb2b..c78b41d8ec 100644
--- a/tests/mock/phpbb_di_container_builder.php
+++ b/tests/mock/phpbb_di_container_builder.php
@@ -17,4 +17,22 @@ class phpbb_mock_phpbb_di_container_builder extends \phpbb\di\container_builder
{
return $this->phpbb_root_path . '../../tmp/container.' . $this->php_ext;
}
+
+ /**
+ * Get the filename under which the dumped extensions autoloader will be stored.
+ *
+ * @return string Path for dumped extensions autoloader
+ */
+ protected function get_autoload_filename()
+ {
+ return $this->phpbb_root_path . '../../tmp/autoload.' . $this->php_ext;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function inject_dbal_driver()
+ {
+ return;
+ }
}
diff --git a/tests/mock/request.php b/tests/mock/request.php
index e7217a94a9..6a32ba0cf1 100644
--- a/tests/mock/request.php
+++ b/tests/mock/request.php
@@ -34,6 +34,11 @@ class phpbb_mock_request implements \phpbb\request\request_interface
$this->data[$super_global][$var_name] = $value;
}
+ public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST)
+ {
+ return $this->variable($var_name, $default, true, $super_global);
+ }
+
public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST)
{
return isset($this->data[$super_global][$var_name]) ? $this->data[$super_global][$var_name] : $default;
diff --git a/tests/mock/router.php b/tests/mock/router.php
new file mode 100644
index 0000000000..01faa338c5
--- /dev/null
+++ b/tests/mock/router.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_router extends \phpbb\routing\router
+{
+ public function get_matcher()
+ {
+ $this->create_new_url_matcher();
+ return parent::get_matcher();
+ }
+
+ public function get_generator()
+ {
+ $this->create_new_url_generator();
+ return parent::get_generator();
+ }
+}
diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php
index 29dd2a5bff..2f24978ba8 100644
--- a/tests/mock/session_testable.php
+++ b/tests/mock/session_testable.php
@@ -11,8 +11,6 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
/**
* Extends the session class to overwrite the setting of cookies.
*
diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php
index c751764d45..e57983684d 100644
--- a/tests/mock/sql_insert_buffer.php
+++ b/tests/mock/sql_insert_buffer.php
@@ -15,7 +15,7 @@ class phpbb_mock_sql_insert_buffer extends \phpbb\db\sql_insert_buffer
{
public function flush()
{
- return (sizeof($this->buffer)) ? true : false;
+ return (count($this->buffer)) ? true : false;
}
public function get_buffer()