aboutsummaryrefslogtreecommitdiffstats
path: root/tests/notification/notification_test.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/notification/notification_test.php')
-rw-r--r--tests/notification/notification_test.php85
1 files changed, 55 insertions, 30 deletions
diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php
index e1788e8670..ec42aa193c 100644
--- a/tests/notification/notification_test.php
+++ b/tests/notification/notification_test.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.
*
*/
@@ -21,28 +25,28 @@ class phpbb_notification_test extends phpbb_tests_notification_base
public function test_get_notification_type_id()
{
// They should be inserted the first time
- $post_type_id = $this->notifications->get_notification_type_id('post');
- $quote_type_id = $this->notifications->get_notification_type_id('quote');
+ $post_type_id = $this->notifications->get_notification_type_id('notification.type.post');
+ $quote_type_id = $this->notifications->get_notification_type_id('notification.type.quote');
$test_type_id = $this->notifications->get_notification_type_id('test');
- $this->assertEquals(array(
+ self::assertEquals(array(
'test' => $test_type_id,
- 'quote' => $quote_type_id,
- 'post' => $post_type_id,
+ 'notification.type.quote' => $quote_type_id,
+ 'notification.type.post' => $post_type_id,
),
$this->notifications->get_notification_type_ids(array(
'test',
- 'quote',
- 'post',
+ 'notification.type.quote',
+ 'notification.type.post',
)
));
- $this->assertEquals($quote_type_id, $this->notifications->get_notification_type_id('quote'));
+ self::assertEquals($quote_type_id, $this->notifications->get_notification_type_id('notification.type.quote'));
try
{
- $this->assertEquals(false, $this->notifications->get_notification_type_id('fail'));
+ self::assertEquals(false, $this->notifications->get_notification_type_id('fail'));
- $this->fail('Non-existent type should throw an exception');
+ self::fail('Non-existent type should throw an exception');
}
catch (Exception $e) {}
}
@@ -51,15 +55,15 @@ class phpbb_notification_test extends phpbb_tests_notification_base
{
$subscription_types = $this->notifications->get_subscription_types();
- $this->assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types);
- $this->assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types);
+ self::assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types);
+ self::assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types);
- $this->assertArrayHasKey('bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']);
- $this->assertArrayHasKey('post', $subscription_types['NOTIFICATION_GROUP_POSTING']);
- $this->assertArrayHasKey('quote', $subscription_types['NOTIFICATION_GROUP_POSTING']);
- $this->assertArrayHasKey('topic', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ self::assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ self::assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ self::assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ self::assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']);
- $this->assertArrayHasKey('pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
+ self::assertArrayHasKey('notification.type.pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
//get_subscription_types
//get_subscription_methods
@@ -67,20 +71,41 @@ class phpbb_notification_test extends phpbb_tests_notification_base
public function test_subscriptions()
{
- $this->notifications->delete_subscription('post', 0, '', 2);
+ $expected_subscriptions = array(
+ 'notification.type.post' => array('notification.method.board'),
+ 'notification.type.topic' => array('notification.method.board'),
+ 'notification.type.quote' => array('notification.method.board'),
+ 'notification.type.bookmark' => array('notification.method.board'),
+ 'test' => array('notification.method.board'),
+ 'notification.type.pm' => array('notification.method.board'),
+ );
+
+ $subscriptions = $this->notifications->get_global_subscriptions(2);
+ foreach ($expected_subscriptions as $item_type => $methods)
+ {
+ self::assertArrayHasKey($item_type, $subscriptions);
+ $this->assert_array_content_equals($methods, $subscriptions[$item_type]);
+ }
+
+ foreach ($subscriptions as $item_type => $methods)
+ {
+ $this->assert_array_content_equals($methods, $expected_subscriptions[$item_type]);
+ }
+
+ $this->notifications->delete_subscription('notification.type.post', 0, 'notification.method.board', 2);
- $this->assertArrayNotHasKey('post', $this->notifications->get_global_subscriptions(2));
+ self::assertArrayNotHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2));
- $this->notifications->add_subscription('post', 0, '', 2);
+ $this->notifications->add_subscription('notification.type.post', 0, 'notification.method.board', 2);
- $this->assertArrayHasKey('post', $this->notifications->get_global_subscriptions(2));
+ self::assertArrayHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2));
}
public function test_notifications()
{
$this->db->sql_query('DELETE FROM phpbb_notification_types');
- $types = array('quote', 'bookmark', 'post', 'test');
+ $types = array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test');
foreach ($types as $id => $type)
{
$this->db->sql_query('INSERT INTO phpbb_notification_types ' .
@@ -99,11 +124,11 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'user_id' => 0,
)));
- $this->assertEquals(array(
+ self::assertEquals(array(
'notifications' => array(),
'unread_count' => 0,
'total_count' => 0,
- ), $this->notifications->load_notifications(array(
+ ), $this->notifications->load_notifications('notification.method.board', array(
'count_unread' => true,
)));
@@ -125,7 +150,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_time' => 1349413323,
));
- $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'test'), array(
+ $this->notifications->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'), array(
'post_id' => '4',
'topic_id' => '2',
'post_time' => 1349413324,
@@ -141,7 +166,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'user_id' => 0,
)));
- $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'test'), array(
+ $this->notifications->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'), array(
'post_id' => '5',
'topic_id' => '2',
'post_time' => 1349413325,
@@ -233,7 +258,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_time' => 1234, // change time
));
- $this->notifications->update_notifications(array('quote', 'bookmark', 'post', 'test'), array(
+ $this->notifications->update_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'), array(
'post_id' => '5',
'topic_id' => '2',
'poster_id' => 2,