mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +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:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -37,7 +37,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -55,7 +55,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -73,7 +73,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -91,7 +91,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -109,7 +109,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -127,7 +127,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -145,7 +145,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -163,7 +163,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -181,7 +181,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -199,7 +199,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -217,7 +217,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -235,7 +235,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -253,7 +253,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -271,7 +271,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -289,7 +289,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @config
|
||||
|
@ -304,7 +304,7 @@ services:
|
|||
arguments:
|
||||
- @user_loader
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- @cache
|
||||
- @user
|
||||
- @auth
|
||||
- @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_db_driver $db
|
||||
* @param phpbb_cache_driver_interface $cache
|
||||
* @param phpbb_cache_service $cache
|
||||
* @param phpbb_user $user
|
||||
* @param phpbb_auth $auth
|
||||
* @param phpbb_config $config
|
||||
|
@ -74,7 +74,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth
|
|||
* @param string $php_ext
|
||||
* @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->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_db_driver $db
|
||||
* @param phpbb_cache_driver_interface $cache
|
||||
* @param phpbb_cache_service $cache
|
||||
* @param phpbb_user $user
|
||||
* @param phpbb_auth $auth
|
||||
* @param phpbb_config $config
|
||||
|
@ -107,7 +107,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
|||
* @param string $user_notifications_table
|
||||
* @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->db = $db;
|
||||
|
|
|
@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
|
|||
* Notifications service class
|
||||
* @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)
|
||||
{
|
|
@ -7,6 +7,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/manager_helper.php';
|
||||
|
||||
class phpbb_notification_test extends phpbb_database_test_case
|
||||
{
|
||||
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_loader = new phpbb_user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
|
||||
$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->notifications = new phpbb_mock_notifications_notification_manager(
|
||||
$this->notifications = new phpbb_notification_manager_helper(
|
||||
array(),
|
||||
array(),
|
||||
$this->container,
|
||||
$this->user_loader,
|
||||
$this->db,
|
||||
$this->cache,
|
||||
$this->user,
|
||||
$phpbb_root_path,
|
||||
$phpEx,
|
||||
|
@ -121,6 +130,20 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
|
||||
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
|
||||
$this->db->sql_query('INSERT INTO ' . TOPICS_WATCH_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
|
||||
'topic_id' => 2,
|
||||
|
@ -195,7 +218,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
|
||||
$expected = array(
|
||||
1 => array(
|
||||
'item_type' => 'test',
|
||||
'notification_type_id' => 4,
|
||||
'item_id' => 1,
|
||||
'item_parent_id' => 1,
|
||||
'user_id' => 0,
|
||||
|
@ -204,7 +227,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
'notification_data' => array(),
|
||||
),
|
||||
2 => array(
|
||||
'item_type' => 'test',
|
||||
'notification_type_id' => 4,
|
||||
'item_id' => 2,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -213,7 +236,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
'notification_data' => array(),
|
||||
),
|
||||
3 => array(
|
||||
'item_type' => 'test',
|
||||
'notification_type_id' => 4,
|
||||
'item_id' => 3,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -222,7 +245,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
'notification_data' => array(),
|
||||
),
|
||||
4 => array(
|
||||
'item_type' => 'post',
|
||||
'notification_type_id' => 3,
|
||||
'item_id' => 4,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -238,7 +261,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
),
|
||||
),
|
||||
5 => array(
|
||||
'item_type' => 'bookmark',
|
||||
'notification_type_id' => 2,
|
||||
'item_id' => 5,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -301,7 +324,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
|
||||
$expected = array(
|
||||
1 => array(
|
||||
'item_type' => 'test',
|
||||
'notification_type_id' => 4,
|
||||
'item_id' => 1,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -310,7 +333,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
'notification_data' => array(),
|
||||
),
|
||||
2 => array(
|
||||
'item_type' => 'test',
|
||||
'notification_type_id' => 4,
|
||||
'item_id' => 2,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -319,7 +342,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
'notification_data' => array(),
|
||||
),
|
||||
3 => array(
|
||||
'item_type' => 'test',
|
||||
'notification_type_id' => 4,
|
||||
'item_id' => 3,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -328,7 +351,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
'notification_data' => array(),
|
||||
),
|
||||
4 => array(
|
||||
'item_type' => 'post',
|
||||
'notification_type_id' => 3,
|
||||
'item_id' => 4,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
@ -344,7 +367,7 @@ class phpbb_notification_test extends phpbb_database_test_case
|
|||
),
|
||||
),
|
||||
5 => array(
|
||||
'item_type' => 'bookmark',
|
||||
'notification_type_id' => 2,
|
||||
'item_id' => 5,
|
||||
'item_parent_id' => 2,
|
||||
'user_id' => 0,
|
||||
|
|
Loading…
Add table
Reference in a new issue