diff options
Diffstat (limited to 'tests/mock')
-rw-r--r-- | tests/mock/auth_provider.php | 16 | ||||
-rw-r--r-- | tests/mock/cache.php | 12 | ||||
-rw-r--r-- | tests/mock/container_builder.php | 25 | ||||
-rw-r--r-- | tests/mock/controller_helper.php | 20 | ||||
-rw-r--r-- | tests/mock/event_dispatcher.php | 23 | ||||
-rw-r--r-- | tests/mock/extension_manager.php | 15 | ||||
-rw-r--r-- | tests/mock/file_downloader.php | 27 | ||||
-rw-r--r-- | tests/mock/filespec.php | 16 | ||||
-rw-r--r-- | tests/mock/filesystem_extension_manager.php | 10 | ||||
-rw-r--r-- | tests/mock/fileupload.php | 19 | ||||
-rw-r--r-- | tests/mock/lang.php | 10 | ||||
-rw-r--r-- | tests/mock/metadata_manager.php | 12 | ||||
-rw-r--r-- | tests/mock/migrator.php | 55 | ||||
-rw-r--r-- | tests/mock/notification_manager.php | 18 | ||||
-rw-r--r-- | tests/mock/notification_type_post.php | 40 | ||||
-rw-r--r-- | tests/mock/notifications_auth.php | 10 | ||||
-rw-r--r-- | tests/mock/null_cache.php | 10 | ||||
-rw-r--r-- | tests/mock/phpbb_di_container_builder.php | 20 | ||||
-rw-r--r-- | tests/mock/request.php | 50 | ||||
-rw-r--r-- | tests/mock/router.php | 27 | ||||
-rw-r--r-- | tests/mock/search.php | 10 | ||||
-rw-r--r-- | tests/mock/session_testable.php | 12 | ||||
-rw-r--r-- | tests/mock/sql_insert_buffer.php | 10 | ||||
-rw-r--r-- | tests/mock/user.php | 15 |
24 files changed, 406 insertions, 76 deletions
diff --git a/tests/mock/auth_provider.php b/tests/mock/auth_provider.php index 734e682ee9..abf0e4fdfb 100644 --- a/tests/mock/auth_provider.php +++ b/tests/mock/auth_provider.php @@ -1,11 +1,15 @@ <?php /** - * - * @package testing - * @copyright (c) 2013 phpBB Group - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 - * - */ +* +* 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. +* +*/ /** * Mock auth provider class with basic functions to help test sessions. diff --git a/tests/mock/cache.php b/tests/mock/cache.php index 83bbb8ef30..5fa3d28147 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ @@ -140,7 +144,7 @@ class phpbb_mock_cache implements \phpbb\cache\driver\driver_interface /** * {@inheritDoc} */ - public function sql_save(\phpbb\db\driver\driver $db, $query, $query_result, $ttl) + public function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) { return $query_result; } diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index 734d3e1741..134589b0b8 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ use Symfony\Component\DependencyInjection\ContainerInterface; @@ -48,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); @@ -176,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 new file mode 100644 index 0000000000..0116dced49 --- /dev/null +++ b/tests/mock/controller_helper.php @@ -0,0 +1,20 @@ +<?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_controller_helper extends \phpbb\controller\helper +{ + public function get_current_url() + { + return ''; + } +} diff --git a/tests/mock/event_dispatcher.php b/tests/mock/event_dispatcher.php index 8887b16163..fa8b4a1036 100644 --- a/tests/mock/event_dispatcher.php +++ b/tests/mock/event_dispatcher.php @@ -1,15 +1,28 @@ <?php /** * -* @package testing -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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_event_dispatcher +class phpbb_mock_event_dispatcher extends \phpbb\event\dispatcher { - public function trigger_event($eventName, $data) + /** + * Constructor. + * + * Overwrite the constructor to get rid of ContainerInterface param instance + */ + public function __construct() + { + } + + public function trigger_event($eventName, $data = array()) { return array(); } diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php index 7049cbdc50..2ce61c5149 100644 --- a/tests/mock/extension_manager.php +++ b/tests/mock/extension_manager.php @@ -1,19 +1,24 @@ <?php /** * -* @package testing -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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_extension_manager extends \phpbb\extension\manager { - public function __construct($phpbb_root_path, $extensions = array()) + public function __construct($phpbb_root_path, $extensions = array(), $container = null) { $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; } } 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/mock/filespec.php b/tests/mock/filespec.php index 9d2a5c84de..7ea750afbe 100644 --- a/tests/mock/filespec.php +++ b/tests/mock/filespec.php @@ -1,11 +1,15 @@ <?php /** - * - * @package testing - * @copyright (c) 2012 phpBB Group - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 - * - */ +* +* 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. +* +*/ /** * Mock filespec class with some basic values to help with testing the diff --git a/tests/mock/filesystem_extension_manager.php b/tests/mock/filesystem_extension_manager.php index c5a51bbb3f..fa1b1c06bc 100644 --- a/tests/mock/filesystem_extension_manager.php +++ b/tests/mock/filesystem_extension_manager.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ diff --git a/tests/mock/fileupload.php b/tests/mock/fileupload.php index cbcbf4a6ab..5a0afc6cd3 100644 --- a/tests/mock/fileupload.php +++ b/tests/mock/fileupload.php @@ -1,11 +1,15 @@ <?php /** - * - * @package testing - * @copyright (c) 2012 phpBB Group - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 - * - */ +* +* 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. +* +*/ /** * Mock fileupload class with some basic values to help with testing the @@ -15,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/lang.php b/tests/mock/lang.php index ac814b45db..bebbe5a29b 100644 --- a/tests/mock/lang.php +++ b/tests/mock/lang.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2010 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ diff --git a/tests/mock/metadata_manager.php b/tests/mock/metadata_manager.php index b6489acfa4..2443fad560 100644 --- a/tests/mock/metadata_manager.php +++ b/tests/mock/metadata_manager.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ @@ -11,11 +15,13 @@ class phpbb_mock_metadata_manager extends \phpbb\extension\metadata_manager { public function set_metadata($metadata) { + array_walk_recursive($metadata, array($this, 'sanitize_json')); $this->metadata = $metadata; } public function merge_metadata($metadata) { + array_walk_recursive($metadata, array($this, 'sanitize_json')); $this->metadata = array_merge($this->metadata, $metadata); } } diff --git a/tests/mock/migrator.php b/tests/mock/migrator.php new file mode 100644 index 0000000000..293f115335 --- /dev/null +++ b/tests/mock/migrator.php @@ -0,0 +1,55 @@ +<?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_migrator extends \phpbb\db\migrator +{ + public function __construct() + { + } + + public function load_migration_state() + { + } + + public function set_migrations($class_names) + { + } + + public function update() + { + } + + public function revert($migration) + { + } + + public function unfulfillable($name) + { + } + + public function finished() + { + } + + public function migration_state($migration) + { + } + + public function populate_migrations($migrations) + { + } + + public function create_migrations_table() + { + } +} diff --git a/tests/mock/notification_manager.php b/tests/mock/notification_manager.php index 47fe30730f..952c0db489 100644 --- a/tests/mock/notification_manager.php +++ b/tests/mock/notification_manager.php @@ -1,9 +1,13 @@ <?php /** * -* @package notifications -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ @@ -17,7 +21,6 @@ if (!defined('IN_PHPBB')) /** * Notifications service class -* @package notifications */ class phpbb_mock_notification_manager { @@ -29,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 new file mode 100644 index 0000000000..4116fecf5e --- /dev/null +++ b/tests/mock/notification_type_post.php @@ -0,0 +1,40 @@ +<?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. +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +class phpbb_mock_notification_type_post extends \phpbb\notification\type\post +{ + 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; + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->notification_types_table = $notification_types_table; + $this->user_notifications_table = $user_notifications_table; + } +} diff --git a/tests/mock/notifications_auth.php b/tests/mock/notifications_auth.php index 2d387d8c00..1106c3004f 100644 --- a/tests/mock/notifications_auth.php +++ b/tests/mock/notifications_auth.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ diff --git a/tests/mock/null_cache.php b/tests/mock/null_cache.php index 7bd33b441b..5b801adf11 100644 --- a/tests/mock/null_cache.php +++ b/tests/mock/null_cache.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ diff --git a/tests/mock/phpbb_di_container_builder.php b/tests/mock/phpbb_di_container_builder.php new file mode 100644 index 0000000000..59cdf0bb2b --- /dev/null +++ b/tests/mock/phpbb_di_container_builder.php @@ -0,0 +1,20 @@ +<?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_phpbb_di_container_builder extends \phpbb\di\container_builder +{ + protected function get_container_filename() + { + return $this->phpbb_root_path . '../../tmp/container.' . $this->php_ext; + } +} diff --git a/tests/mock/request.php b/tests/mock/request.php index 60ba725abd..e7217a94a9 100644 --- a/tests/mock/request.php +++ b/tests/mock/request.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ @@ -11,6 +15,8 @@ class phpbb_mock_request implements \phpbb\request\request_interface { protected $data; + protected $super_globals_disabled = false; + public function __construct($get = array(), $post = array(), $cookie = array(), $server = array(), $request = false, $files = array()) { $this->data[\phpbb\request\request_interface::GET] = $get; @@ -19,6 +25,8 @@ class phpbb_mock_request implements \phpbb\request\request_interface $this->data[\phpbb\request\request_interface::REQUEST] = ($request === false) ? $post + $get : $request; $this->data[\phpbb\request\request_interface::SERVER] = $server; $this->data[\phpbb\request\request_interface::FILES] = $files; + + $this->disable_super_globals(); } public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST) @@ -79,6 +87,21 @@ class phpbb_mock_request implements \phpbb\request\request_interface return $this->data[$super_global]; } + public function super_globals_disabled() + { + return $this->super_globals_disabled; + } + + public function disable_super_globals() + { + $this->super_globals_disabled = true; + } + + public function enable_super_globals() + { + $this->super_globals_disabled = false; + } + /* custom methods */ public function set_header($header_name, $value) @@ -91,4 +114,25 @@ class phpbb_mock_request implements \phpbb\request\request_interface { $this->data[$super_global] = array_merge($this->data[$super_global], $values); } + + public function escape($var, $multibyte) + { + $type_cast_helper = new \phpbb\request\type_cast_helper(); + if (is_array($var)) + { + $result = array(); + foreach ($var as $key => $value) + { + $type_cast_helper->set_var($key, $key, gettype($key), $multibyte); + $result[$key] = $this->escape($value, $multibyte); + } + $var = $result; + } + else + { + $type_cast_helper->set_var($var, $var, 'string', $multibyte); + } + + return $var; + } } 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/search.php b/tests/mock/search.php index 6739719216..f30876b4da 100644 --- a/tests/mock/search.php +++ b/tests/mock/search.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php index d81ae3163e..29dd2a5bff 100644 --- a/tests/mock/session_testable.php +++ b/tests/mock/session_testable.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ @@ -20,7 +24,7 @@ class phpbb_mock_session_testable extends \phpbb\session { private $_cookies = array(); - public function set_cookie($name, $data, $time) + public function set_cookie($name, $data, $time, $httponly = true) { $this->_cookies[$name] = array($data, $time); } diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php index aa7c54dddd..c751764d45 100644 --- a/tests/mock/sql_insert_buffer.php +++ b/tests/mock/sql_insert_buffer.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ diff --git a/tests/mock/user.php b/tests/mock/user.php index bd547b3973..9888337a9e 100644 --- a/tests/mock/user.php +++ b/tests/mock/user.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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. * */ @@ -46,4 +50,9 @@ class phpbb_mock_user } return false; } + + public function lang() + { + return implode(' ', func_get_args()); + } } |