aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-04-29 22:16:46 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-04-29 22:16:46 -0500
commit4cd0914f8976913de0ec46cc78c8ac5731415838 (patch)
treebfc2f8d8334d8d9175cb8e493b66cdb46752231e
parent7bda5a016a726711855fb7a749f9f3638e63d1e3 (diff)
downloadforums-4cd0914f8976913de0ec46cc78c8ac5731415838.tar
forums-4cd0914f8976913de0ec46cc78c8ac5731415838.tar.gz
forums-4cd0914f8976913de0ec46cc78c8ac5731415838.tar.bz2
forums-4cd0914f8976913de0ec46cc78c8ac5731415838.tar.xz
forums-4cd0914f8976913de0ec46cc78c8ac5731415838.zip
[ticket/11413] Fix notification tests
Send types/methods the cache service, not the driver (not sure why the driver was sent before) PHPBB3-11413
-rw-r--r--phpBB/config/notifications.yml34
-rw-r--r--phpBB/includes/notification/exception.php29
-rw-r--r--phpBB/includes/notification/method/base.php4
-rw-r--r--phpBB/includes/notification/type/base.php4
-rw-r--r--tests/notification/manager_helper.php (renamed from tests/mock/notifications_notification_manager.php)2
-rw-r--r--tests/notification/notification_test.php47
6 files changed, 86 insertions, 34 deletions
diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml
index 60aa63a854..c66527941e 100644
--- a/phpBB/config/notifications.yml
+++ b/phpBB/config/notifications.yml
@@ -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
diff --git a/phpBB/includes/notification/exception.php b/phpBB/includes/notification/exception.php
new file mode 100644
index 0000000000..a52d6fdc57
--- /dev/null
+++ b/phpBB/includes/notification/exception.php
@@ -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();
+ }
+}
diff --git a/phpBB/includes/notification/method/base.php b/phpBB/includes/notification/method/base.php
index 22418c9be8..bae85310b2 100644
--- a/phpBB/includes/notification/method/base.php
+++ b/phpBB/includes/notification/method/base.php
@@ -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;
diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php
index f56956d16a..983383ce2a 100644
--- a/phpBB/includes/notification/type/base.php
+++ b/phpBB/includes/notification/type/base.php
@@ -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;
diff --git a/tests/mock/notifications_notification_manager.php b/tests/notification/manager_helper.php
index c995afb9ab..8d2ce5e002 100644
--- a/tests/mock/notifications_notification_manager.php
+++ b/tests/notification/manager_helper.php
@@ -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)
{
diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php
index beccf55371..5746d0090e 100644
--- a/tests/notification/notification_test.php
+++ b/tests/notification/notification_test.php
@@ -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,