aboutsummaryrefslogtreecommitdiffstats
path: root/tests/notification
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2014-08-17 14:43:17 +0200
committerTristan Darricau <github@nicofuma.fr>2014-08-17 16:19:23 +0200
commitb18fe1203aafb41d8e9e18a776bf415fa060bf4b (patch)
tree5a02491b9dbb08421a594c5651045e4a64073a57 /tests/notification
parentfe8096753566f4beb708e9070d8789eebdd1e70b (diff)
downloadforums-b18fe1203aafb41d8e9e18a776bf415fa060bf4b.tar
forums-b18fe1203aafb41d8e9e18a776bf415fa060bf4b.tar.gz
forums-b18fe1203aafb41d8e9e18a776bf415fa060bf4b.tar.bz2
forums-b18fe1203aafb41d8e9e18a776bf415fa060bf4b.tar.xz
forums-b18fe1203aafb41d8e9e18a776bf415fa060bf4b.zip
[ticket/12990] Fix unit tests
PHPBB3-12990
Diffstat (limited to 'tests/notification')
-rw-r--r--tests/notification/base.php35
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.bookmark.xml (renamed from tests/notification/fixtures/submit_post_bookmark.xml)12
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.post.xml (renamed from tests/notification/fixtures/submit_post_post.xml)16
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml (renamed from tests/notification/fixtures/submit_post_post_in_queue.xml)16
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.quote.xml (renamed from tests/notification/fixtures/submit_post_quote.xml)12
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.topic.xml (renamed from tests/notification/fixtures/submit_post_topic.xml)10
-rw-r--r--tests/notification/group_request_test.php4
-rw-r--r--tests/notification/manager_helper.php3
-rw-r--r--tests/notification/notification_test.php50
-rw-r--r--tests/notification/submit_post_type_bookmark_test.php2
-rw-r--r--tests/notification/submit_post_type_post_in_queue_test.php2
-rw-r--r--tests/notification/submit_post_type_post_test.php2
-rw-r--r--tests/notification/submit_post_type_quote_test.php2
-rw-r--r--tests/notification/submit_post_type_topic_test.php2
14 files changed, 85 insertions, 83 deletions
diff --git a/tests/notification/base.php b/tests/notification/base.php
index bfa9d2a1a4..c97b7c24e2 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -21,21 +21,21 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
{
return array(
'test',
- 'approve_post',
- 'approve_topic',
- 'bookmark',
- 'disapprove_post',
- 'disapprove_topic',
- 'pm',
- 'post',
- 'post_in_queue',
- 'quote',
- 'report_pm',
- 'report_pm_closed',
- 'report_post',
- 'report_post_closed',
- 'topic',
- 'topic_in_queue',
+ 'notification.type.approve_post',
+ 'notification.type.approve_topic',
+ 'notification.type.bookmark',
+ 'notification.type.disapprove_post',
+ 'notification.type.disapprove_topic',
+ 'notification.type.pm',
+ 'notification.type.post',
+ 'notification.type.post_in_queue',
+ 'notification.type.quote',
+ 'notification.type.report_pm',
+ 'notification.type.report_pm_closed',
+ 'notification.type.report_post',
+ 'notification.type.report_post_closed',
+ 'notification.type.topic',
+ 'notification.type.topic_in_queue',
);
}
@@ -92,10 +92,11 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$types = array();
foreach ($this->get_notification_types() as $type)
{
- $class = $this->build_type('phpbb\notification\type\\' . $type);
+ $type_parts = explode('.', $type);
+ $class = $this->build_type('phpbb\notification\type\\' . array_pop($type_parts));
$types[$type] = $class;
- $this->container->set('notification.type.' . $type, $class);
+ $this->container->set($type, $class);
}
$this->notifications->set_var('notification_types', $types);
diff --git a/tests/notification/fixtures/submit_post_bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
index 525d0484e0..a1413e2cf8 100644
--- a/tests/notification/fixtures/submit_post_bookmark.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
@@ -50,7 +50,7 @@
<column>notification_type_enabled</column>
<row>
<value>1</value>
- <value>bookmark</value>
+ <value>notification.type.bookmark</value>
<value>1</value>
</row>
</table>
@@ -123,35 +123,35 @@
<column>method</column>
<column>notify</column>
<row>
- <value>bookmark</value>
+ <value>notification.type.bookmark</value>
<value>0</value>
<value>2</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>bookmark</value>
+ <value>notification.type.bookmark</value>
<value>0</value>
<value>3</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>bookmark</value>
+ <value>notification.type.bookmark</value>
<value>0</value>
<value>4</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>bookmark</value>
+ <value>notification.type.bookmark</value>
<value>0</value>
<value>5</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>bookmark</value>
+ <value>notification.type.bookmark</value>
<value>0</value>
<value>6</value>
<value></value>
diff --git a/tests/notification/fixtures/submit_post_post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml
index a38ca77ea0..ed75787c70 100644
--- a/tests/notification/fixtures/submit_post_post.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.post.xml
@@ -50,7 +50,7 @@
<column>notification_type_enabled</column>
<row>
<value>1</value>
- <value>post</value>
+ <value>notification.type.post</value>
<value>1</value>
</row>
</table>
@@ -153,49 +153,49 @@
<column>method</column>
<column>notify</column>
<row>
- <value>post</value>
+ <value>notification.type.post</value>
<value>0</value>
<value>2</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>post</value>
+ <value>notification.type.post</value>
<value>0</value>
<value>3</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>post</value>
+ <value>notification.type.post</value>
<value>0</value>
<value>4</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>post</value>
+ <value>notification.type.post</value>
<value>0</value>
<value>5</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>post</value>
+ <value>notification.type.post</value>
<value>0</value>
<value>6</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>post</value>
+ <value>notification.type.post</value>
<value>0</value>
<value>7</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>post</value>
+ <value>notification.type.post</value>
<value>0</value>
<value>8</value>
<value></value>
diff --git a/tests/notification/fixtures/submit_post_post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
index 28cb69be36..2dea8e34dd 100644
--- a/tests/notification/fixtures/submit_post_post_in_queue.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
@@ -22,7 +22,7 @@
<column>notification_type_enabled</column>
<row>
<value>1</value>
- <value>post_in_queue</value>
+ <value>notification.type.post_in_queue</value>
<value>1</value>
</row>
</table>
@@ -107,49 +107,49 @@
<column>method</column>
<column>notify</column>
<row>
- <value>needs_approval</value>
+ <value>notification.type.needs_approval</value>
<value>0</value>
<value>2</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>needs_approval</value>
+ <value>notification.type.needs_approval</value>
<value>0</value>
<value>3</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>needs_approval</value>
+ <value>notification.type.needs_approval</value>
<value>0</value>
<value>4</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>needs_approval</value>
+ <value>notification.type.needs_approval</value>
<value>0</value>
<value>5</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>needs_approval</value>
+ <value>notification.type.needs_approval</value>
<value>0</value>
<value>6</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>needs_approval</value>
+ <value>notification.type.needs_approval</value>
<value>0</value>
<value>7</value>
<value></value>
<value>0</value>
</row>
<row>
- <value>needs_approval</value>
+ <value>notification.type.needs_approval</value>
<value>0</value>
<value>9</value>
<value></value>
diff --git a/tests/notification/fixtures/submit_post_quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml
index 2b11992e54..dd5bc620cd 100644
--- a/tests/notification/fixtures/submit_post_quote.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml
@@ -22,7 +22,7 @@
<column>notification_type_enabled</column>
<row>
<value>1</value>
- <value>quote</value>
+ <value>notification.type.quote</value>
<value>1</value>
</row>
</table>
@@ -95,35 +95,35 @@
<column>method</column>
<column>notify</column>
<row>
- <value>quote</value>
+ <value>notification.type.quote</value>
<value>0</value>
<value>2</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>quote</value>
+ <value>notification.type.quote</value>
<value>0</value>
<value>3</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>quote</value>
+ <value>notification.type.quote</value>
<value>0</value>
<value>4</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>quote</value>
+ <value>notification.type.quote</value>
<value>0</value>
<value>5</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>quote</value>
+ <value>notification.type.quote</value>
<value>0</value>
<value>6</value>
<value></value>
diff --git a/tests/notification/fixtures/submit_post_topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml
index 5e179d9b99..1ba8d05699 100644
--- a/tests/notification/fixtures/submit_post_topic.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml
@@ -42,7 +42,7 @@
<column>notification_type_enabled</column>
<row>
<value>1</value>
- <value>topic</value>
+ <value>notification.type.topic</value>
<value>1</value>
</row>
</table>
@@ -103,28 +103,28 @@
<column>method</column>
<column>notify</column>
<row>
- <value>topic</value>
+ <value>notification.type.topic</value>
<value>0</value>
<value>2</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>topic</value>
+ <value>notification.type.topic</value>
<value>0</value>
<value>6</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>topic</value>
+ <value>notification.type.topic</value>
<value>0</value>
<value>7</value>
<value></value>
<value>1</value>
</row>
<row>
- <value>topic</value>
+ <value>notification.type.topic</value>
<value>0</value>
<value>8</value>
<value></value>
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index 14ed4ff62c..afbc586601 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -25,8 +25,8 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
return array_merge(
parent::get_notification_types(),
array(
- 'group_request',
- 'group_request_approved',
+ 'notification.type.group_request',
+ 'notification.type.group_request_approved',
)
);
}
diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php
index 24030f5775..75b7275d3a 100644
--- a/tests/notification/manager_helper.php
+++ b/tests/notification/manager_helper.php
@@ -43,7 +43,8 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager
*/
public function get_item_type_class($item_type, $data = array())
{
- $item_type = 'phpbb\notification\type\\' . $item_type;
+ $item_parts = explode('.', $item_type);
+ $item_type = 'phpbb\notification\type\\' . array_pop($item_parts);
$item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table);
diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php
index 27ea8ddb44..79fa5338c4 100644
--- a/tests/notification/notification_test.php
+++ b/tests/notification/notification_test.php
@@ -25,22 +25,22 @@ 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(
'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'));
+ $this->assertEquals($quote_type_id, $this->notifications->get_notification_type_id('notification.type.quote'));
try
{
@@ -58,12 +58,12 @@ class phpbb_notification_test extends phpbb_tests_notification_base
$this->assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types);
$this->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']);
+ $this->assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ $this->assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ $this->assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ $this->assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']);
- $this->assertArrayHasKey('pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
+ $this->assertArrayHasKey('notification.type.pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
//get_subscription_types
//get_subscription_methods
@@ -72,12 +72,12 @@ class phpbb_notification_test extends phpbb_tests_notification_base
public function test_subscriptions()
{
$expected_subscriptions = array(
- 'post' => array(''),
- 'topic' => array(''),
- 'quote' => array(''),
- 'bookmark' => array(''),
+ 'notification.type.post' => array(''),
+ 'notification.type.topic' => array(''),
+ 'notification.type.quote' => array(''),
+ 'notification.type.bookmark' => array(''),
'test' => array(''),
- 'pm' => array(''),
+ 'notification.type.pm' => array(''),
);
$subscriptions = $this->notifications->get_global_subscriptions(2);
@@ -92,20 +92,20 @@ class phpbb_notification_test extends phpbb_tests_notification_base
$this->assert_array_content_equals($methods, $expected_subscriptions[$item_type]);
}
- $this->notifications->delete_subscription('post', 0, '', 2);
+ $this->notifications->delete_subscription('notification.type.post', 0, '', 2);
- $this->assertArrayNotHasKey('post', $this->notifications->get_global_subscriptions(2));
+ $this->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, '', 2);
- $this->assertArrayHasKey('post', $this->notifications->get_global_subscriptions(2));
+ $this->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 ' .
@@ -150,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,
@@ -166,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,
@@ -258,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,
diff --git a/tests/notification/submit_post_type_bookmark_test.php b/tests/notification/submit_post_type_bookmark_test.php
index 6d7747c2ba..7c3b9f938f 100644
--- a/tests/notification/submit_post_type_bookmark_test.php
+++ b/tests/notification/submit_post_type_bookmark_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php';
class phpbb_notification_submit_post_type_bookmark_test extends phpbb_notification_submit_post_base
{
- protected $item_type = 'bookmark';
+ protected $item_type = 'notification.type.bookmark';
public function setUp()
{
diff --git a/tests/notification/submit_post_type_post_in_queue_test.php b/tests/notification/submit_post_type_post_in_queue_test.php
index 6bd9c8c93f..1390e92d96 100644
--- a/tests/notification/submit_post_type_post_in_queue_test.php
+++ b/tests/notification/submit_post_type_post_in_queue_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php';
class phpbb_notification_submit_post_type_post_in_queue_test extends phpbb_notification_submit_post_base
{
- protected $item_type = 'post_in_queue';
+ protected $item_type = 'notification.type.post_in_queue';
public function setUp()
{
diff --git a/tests/notification/submit_post_type_post_test.php b/tests/notification/submit_post_type_post_test.php
index 5007424690..037c326bc0 100644
--- a/tests/notification/submit_post_type_post_test.php
+++ b/tests/notification/submit_post_type_post_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php';
class phpbb_notification_submit_post_type_post_test extends phpbb_notification_submit_post_base
{
- protected $item_type = 'post';
+ protected $item_type = 'notification.type.post';
public function setUp()
{
diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php
index 94979fd154..61e3840773 100644
--- a/tests/notification/submit_post_type_quote_test.php
+++ b/tests/notification/submit_post_type_quote_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php';
class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_submit_post_base
{
- protected $item_type = 'quote';
+ protected $item_type = 'notification.type.quote';
public function setUp()
{
diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php
index 52e9353c7c..c095fbc4ba 100644
--- a/tests/notification/submit_post_type_topic_test.php
+++ b/tests/notification/submit_post_type_topic_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php';
class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_submit_post_base
{
- protected $item_type = 'topic';
+ protected $item_type = 'notification.type.topic';
public function setUp()
{