mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/11413] Fix notification tests
Send types/methods the cache service, not the driver (not sure why the driver was sent before) PHPBB3-11413
This commit is contained in:
parent
7bda5a016a
commit
4cd0914f89
6 changed files with 86 additions and 34 deletions
|
@ -19,7 +19,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -37,7 +37,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -55,7 +55,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -73,7 +73,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -91,7 +91,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -109,7 +109,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -127,7 +127,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -145,7 +145,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -163,7 +163,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -181,7 +181,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -199,7 +199,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -217,7 +217,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -235,7 +235,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -253,7 +253,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -271,7 +271,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -289,7 +289,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
@ -304,7 +304,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user_loader
|
- @user_loader
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache
|
||||||
- @user
|
- @user
|
||||||
- @auth
|
- @auth
|
||||||
- @config
|
- @config
|
||||||
|
|
29
phpBB/includes/notification/exception.php
Normal file
29
phpBB/includes/notification/exception.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifications exception
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
*/
|
||||||
|
class phpbb_notification_exception extends \Exception
|
||||||
|
{
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->getMessage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -66,7 +66,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth
|
||||||
*
|
*
|
||||||
* @param phpbb_user_loader $user_loader
|
* @param phpbb_user_loader $user_loader
|
||||||
* @param phpbb_db_driver $db
|
* @param phpbb_db_driver $db
|
||||||
* @param phpbb_cache_driver_interface $cache
|
* @param phpbb_cache_service $cache
|
||||||
* @param phpbb_user $user
|
* @param phpbb_user $user
|
||||||
* @param phpbb_auth $auth
|
* @param phpbb_auth $auth
|
||||||
* @param phpbb_config $config
|
* @param phpbb_config $config
|
||||||
|
@ -74,7 +74,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth
|
||||||
* @param string $php_ext
|
* @param string $php_ext
|
||||||
* @return phpbb_notification_method_base
|
* @return phpbb_notification_method_base
|
||||||
*/
|
*/
|
||||||
public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$this->user_loader = $user_loader;
|
$this->user_loader = $user_loader;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
|
@ -96,7 +96,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
||||||
*
|
*
|
||||||
* @param phpbb_user_loader $user_loader
|
* @param phpbb_user_loader $user_loader
|
||||||
* @param phpbb_db_driver $db
|
* @param phpbb_db_driver $db
|
||||||
* @param phpbb_cache_driver_interface $cache
|
* @param phpbb_cache_service $cache
|
||||||
* @param phpbb_user $user
|
* @param phpbb_user $user
|
||||||
* @param phpbb_auth $auth
|
* @param phpbb_auth $auth
|
||||||
* @param phpbb_config $config
|
* @param phpbb_config $config
|
||||||
|
@ -107,7 +107,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
||||||
* @param string $user_notifications_table
|
* @param string $user_notifications_table
|
||||||
* @return phpbb_notification_type_base
|
* @return phpbb_notification_type_base
|
||||||
*/
|
*/
|
||||||
public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
|
public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
|
||||||
{
|
{
|
||||||
$this->user_loader = $user_loader;
|
$this->user_loader = $user_loader;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
|
@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
|
||||||
* Notifications service class
|
* Notifications service class
|
||||||
* @package notifications
|
* @package notifications
|
||||||
*/
|
*/
|
||||||
class phpbb_mock_notifications_notification_manager extends phpbb_notification_manager
|
class phpbb_notification_manager_helper extends phpbb_notification_manager
|
||||||
{
|
{
|
||||||
public function set_var($name, $value)
|
public function set_var($name, $value)
|
||||||
{
|
{
|
|
@ -7,6 +7,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/manager_helper.php';
|
||||||
|
|
||||||
class phpbb_notification_test extends phpbb_database_test_case
|
class phpbb_notification_test extends phpbb_database_test_case
|
||||||
{
|
{
|
||||||
protected $notifications, $db, $container, $user, $config, $auth, $cache;
|
protected $notifications, $db, $container, $user, $config, $auth, $cache;
|
||||||
|
@ -34,16 +36,23 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
$this->user = new phpbb_mock_user();
|
$this->user = new phpbb_mock_user();
|
||||||
$this->user_loader = new phpbb_user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
|
$this->user_loader = new phpbb_user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
|
||||||
$this->auth = new phpbb_mock_notifications_auth();
|
$this->auth = new phpbb_mock_notifications_auth();
|
||||||
$this->cache = new phpbb_mock_cache();
|
$this->cache = new phpbb_cache_service(
|
||||||
|
new phpbb_cache_driver_null(),
|
||||||
|
$this->config,
|
||||||
|
$this->db,
|
||||||
|
$phpbb_root_path,
|
||||||
|
$phpEx
|
||||||
|
);
|
||||||
|
|
||||||
$this->container = new phpbb_mock_container_builder();
|
$this->container = new phpbb_mock_container_builder();
|
||||||
|
|
||||||
$this->notifications = new phpbb_mock_notifications_notification_manager(
|
$this->notifications = new phpbb_notification_manager_helper(
|
||||||
array(),
|
array(),
|
||||||
array(),
|
array(),
|
||||||
$this->container,
|
$this->container,
|
||||||
$this->user_loader,
|
$this->user_loader,
|
||||||
$this->db,
|
$this->db,
|
||||||
|
$this->cache,
|
||||||
$this->user,
|
$this->user,
|
||||||
$phpbb_root_path,
|
$phpbb_root_path,
|
||||||
$phpEx,
|
$phpEx,
|
||||||
|
@ -121,6 +130,20 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
|
|
||||||
public function test_notifications()
|
public function test_notifications()
|
||||||
{
|
{
|
||||||
|
$this->db->sql_query('DELETE FROM phpbb_notification_types');
|
||||||
|
|
||||||
|
$types = array('quote', 'bookmark', 'post', 'test');
|
||||||
|
foreach ($types as $id => $type)
|
||||||
|
{
|
||||||
|
$this->db->sql_query('INSERT INTO phpbb_notification_types ' .
|
||||||
|
$this->db->sql_build_array('INSERT', array(
|
||||||
|
'notification_type_id' => ($id + 1),
|
||||||
|
'notification_type_name' => $type,
|
||||||
|
'notification_type_enabled' => 1,
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Used to test post notifications later
|
// Used to test post notifications later
|
||||||
$this->db->sql_query('INSERT INTO ' . TOPICS_WATCH_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
|
$this->db->sql_query('INSERT INTO ' . TOPICS_WATCH_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
|
||||||
'topic_id' => 2,
|
'topic_id' => 2,
|
||||||
|
@ -195,7 +218,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
1 => array(
|
1 => array(
|
||||||
'item_type' => 'test',
|
'notification_type_id' => 4,
|
||||||
'item_id' => 1,
|
'item_id' => 1,
|
||||||
'item_parent_id' => 1,
|
'item_parent_id' => 1,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -204,7 +227,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
'notification_data' => array(),
|
'notification_data' => array(),
|
||||||
),
|
),
|
||||||
2 => array(
|
2 => array(
|
||||||
'item_type' => 'test',
|
'notification_type_id' => 4,
|
||||||
'item_id' => 2,
|
'item_id' => 2,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -213,7 +236,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
'notification_data' => array(),
|
'notification_data' => array(),
|
||||||
),
|
),
|
||||||
3 => array(
|
3 => array(
|
||||||
'item_type' => 'test',
|
'notification_type_id' => 4,
|
||||||
'item_id' => 3,
|
'item_id' => 3,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -222,7 +245,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
'notification_data' => array(),
|
'notification_data' => array(),
|
||||||
),
|
),
|
||||||
4 => array(
|
4 => array(
|
||||||
'item_type' => 'post',
|
'notification_type_id' => 3,
|
||||||
'item_id' => 4,
|
'item_id' => 4,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -238,7 +261,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
5 => array(
|
5 => array(
|
||||||
'item_type' => 'bookmark',
|
'notification_type_id' => 2,
|
||||||
'item_id' => 5,
|
'item_id' => 5,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -301,7 +324,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
1 => array(
|
1 => array(
|
||||||
'item_type' => 'test',
|
'notification_type_id' => 4,
|
||||||
'item_id' => 1,
|
'item_id' => 1,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -310,7 +333,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
'notification_data' => array(),
|
'notification_data' => array(),
|
||||||
),
|
),
|
||||||
2 => array(
|
2 => array(
|
||||||
'item_type' => 'test',
|
'notification_type_id' => 4,
|
||||||
'item_id' => 2,
|
'item_id' => 2,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -319,7 +342,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
'notification_data' => array(),
|
'notification_data' => array(),
|
||||||
),
|
),
|
||||||
3 => array(
|
3 => array(
|
||||||
'item_type' => 'test',
|
'notification_type_id' => 4,
|
||||||
'item_id' => 3,
|
'item_id' => 3,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -328,7 +351,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
'notification_data' => array(),
|
'notification_data' => array(),
|
||||||
),
|
),
|
||||||
4 => array(
|
4 => array(
|
||||||
'item_type' => 'post',
|
'notification_type_id' => 3,
|
||||||
'item_id' => 4,
|
'item_id' => 4,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
@ -344,7 +367,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
5 => array(
|
5 => array(
|
||||||
'item_type' => 'bookmark',
|
'notification_type_id' => 2,
|
||||||
'item_id' => 5,
|
'item_id' => 5,
|
||||||
'item_parent_id' => 2,
|
'item_parent_id' => 2,
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue