aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/di/create_container_test.php32
-rw-r--r--tests/functional/disapprove_test.php319
-rw-r--r--tests/functional/notification_test.php9
-rw-r--r--tests/functional/ucp_profile_test.php33
-rw-r--r--tests/log/function_view_log_test.php2
-rw-r--r--tests/mock/cache.php2
-rw-r--r--tests/mock/user.php5
-rw-r--r--tests/notification/fixtures/submit_post_topic.xml134
-rw-r--r--tests/notification/submit_post_base.php2
-rw-r--r--tests/notification/submit_post_type_topic_test.php149
-rw-r--r--tests/session/testable_factory.php4
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php2
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php4
-rw-r--r--tests/wrapper/gmgetdate_test.php37
14 files changed, 701 insertions, 33 deletions
diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php
index a3a1ad3597..46d97ba8ba 100644
--- a/tests/di/create_container_test.php
+++ b/tests/di/create_container_test.php
@@ -59,19 +59,43 @@ namespace phpbb\db\driver
{
class container_mock extends \phpbb\db\driver\driver
{
- public function sql_connect()
+ public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
}
- public function sql_query()
+ public function sql_query($query = '', $cache_ttl = 0)
{
}
- public function sql_fetchrow()
+ public function sql_fetchrow($query_id = false)
{
}
- public function sql_freeresult()
+ public function sql_freeresult($query_id = false)
+ {
+ }
+
+ function sql_server_info($raw = false, $use_cache = true)
+ {
+ }
+
+ function sql_affectedrows()
+ {
+ }
+
+ function sql_rowseek($rownum, &$query_id)
+ {
+ }
+
+ function sql_nextid()
+ {
+ }
+
+ function sql_escape($msg)
+ {
+ }
+
+ function sql_like_expression($expression)
{
}
}
diff --git a/tests/functional/disapprove_test.php b/tests/functional/disapprove_test.php
new file mode 100644
index 0000000000..ea594b1062
--- /dev/null
+++ b/tests/functional/disapprove_test.php
@@ -0,0 +1,319 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_disapprove_test extends phpbb_functional_test_case
+{
+ protected $data = array();
+
+ public function test_setup_forums()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
+ $form = $crawler->selectButton('addforum')->form(array(
+ 'forum_name' => 'Disapprove Test #1',
+ ));
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form(array(
+ 'forum_perm_from' => 2,
+ ));
+ $crawler = self::submit($form);
+
+ // Set flood interval to 0
+ $this->set_flood_interval(0);
+ }
+
+ public function test_create_posts()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Disapprove Test #1',
+ ),
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 0,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 0,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => 0,
+ ), 'initial comparison');
+
+ // Test creating topic #1
+ $post = $this->create_topic($this->data['forums']['Disapprove Test #1'], 'Disapprove Test Topic #1', 'This is a test topic posted by the testing framework.');
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+
+ $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text());
+ $this->data['topics']['Disapprove Test Topic #1'] = (int) $post['topic_id'];
+ $this->data['posts']['Disapprove Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Disapprove Test Topic #1'],
+ ), 'after creating topic #1');
+
+ $this->logout();
+ $this->create_user('disapprove_testuser');
+ $this->add_user_group('NEWLY_REGISTERED', array('disapprove_testuser'));
+ $this->login('disapprove_testuser');
+
+ // Test creating a reply
+ $post2 = $this->create_post($this->data['forums']['Disapprove Test #1'], $post['topic_id'], 'Re: Disapprove Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}");
+ $this->assertNotContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 1,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Disapprove Test Topic #1'],
+ ), 'after replying');
+
+ // Test creating topic #2
+ $post = $this->create_topic($this->data['forums']['Disapprove Test #1'], 'Disapprove Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
+ $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Disapprove Test #1']}&sid={$this->sid}");
+
+ $this->assertNotContains('Disapprove Test Topic #2', $crawler->filter('html')->text());
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Disapprove Test Topic #1'],
+ ), 'after creating topic #2');
+
+ $this->logout();
+ }
+
+ public function test_reset_flood_interval()
+ {
+ $this->login();
+ $this->admin_login();
+
+ // Set flood interval back to 15
+ $this->set_flood_interval(15);
+ }
+
+ public function test_disapprove_post()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Disapprove Test #1',
+ ),
+ 'topics' => array(
+ 'Disapprove Test Topic #1',
+ 'Disapprove Test Topic #2',
+ ),
+ 'posts' => array(
+ 'Disapprove Test Topic #1',
+ 'Re: Disapprove Test Topic #1-#2',
+ 'Disapprove Test Topic #2',
+ ),
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Disapprove Test Topic #1'],
+ ), 'before disapproving post');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}");
+ $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text());
+ $this->assertContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
+
+ $form = $crawler->selectButton($this->lang('DISAPPROVE'))->form();
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton($this->lang('YES'))->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('POST_DISAPPROVED_SUCCESS', $crawler->text());
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 1,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Disapprove Test Topic #1'],
+ ), 'after disapproving post');
+
+ $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
+ $link_url = $link->getUri();
+ $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Disapprove Test #1'] . '&t=' . $this->data['topics']['Disapprove Test Topic #1'], $link_url);
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}");
+ $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text());
+ $this->assertNotContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text());
+ }
+
+ public function test_disapprove_topic()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Disapprove Test #1',
+ ),
+ 'topics' => array(
+ 'Disapprove Test Topic #1',
+ 'Disapprove Test Topic #2',
+ ),
+ 'posts' => array(
+ 'Disapprove Test Topic #1',
+ 'Disapprove Test Topic #2',
+ ),
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 1,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Disapprove Test Topic #1'],
+ ), 'before disapproving topic');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #2']}&sid={$this->sid}");
+ $this->assertContains('Disapprove Test Topic #2', $crawler->filter('html')->text());
+
+ $form = $crawler->selectButton($this->lang('DISAPPROVE'))->form();
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton($this->lang('YES'))->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('TOPIC_DISAPPROVED_SUCCESS', $crawler->text());
+
+ $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Disapprove Test Topic #1'],
+ ), 'after disapproving topic');
+
+ $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link();
+ $link_url = $link->getUri();
+ $this->assertContains('viewforum.php?f=' . $this->data['forums']['Disapprove Test #1'], $link_url);
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #2']}&sid={$this->sid}", array(), false);
+ self::assert_response_html(404);
+ $this->assertNotContains('Disapprove Test Topic #2', $crawler->filter('html')->text());
+ }
+
+ protected function assert_forum_details($forum_id, $details, $additional_error_message = '')
+ {
+ $this->db = $this->get_db();
+
+ $sql = 'SELECT ' . implode(', ', array_keys($details)) . '
+ FROM phpbb_forums
+ WHERE forum_id = ' . (int) $forum_id;
+ $result = $this->db->sql_query($sql);
+ $data = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}");
+ }
+
+ protected function set_flood_interval($flood_interval)
+ {
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+
+ $values["config[flood_interval]"] = $flood_interval;
+ $form->setValues($values);
+ $crawler = self::submit($form);
+ $this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
+ }
+
+ protected function load_ids($data)
+ {
+ $this->db = $this->get_db();
+
+ if (!empty($data['forums']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_forums
+ WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['forum_name'], $data['forums']))
+ {
+ $this->data['forums'][$row['forum_name']] = (int) $row['forum_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ if (!empty($data['topics']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_topics
+ WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['topic_title'], $data['topics']))
+ {
+ $this->data['topics'][$row['topic_title']] = (int) $row['topic_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ if (!empty($data['posts']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_posts
+ WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['post_subject'], $data['posts']))
+ {
+ $this->data['posts'][$row['post_subject']] = (int) $row['post_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+ }
+}
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index 9ae37842fe..18e8a4ecc0 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -59,20 +59,17 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
$this->create_user('notificationtestuser');
$this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser'));
$this->login('notificationtestuser');
- $crawler = self::request('GET', 'index.php');
- $this->assertContains('notificationtestuser', $crawler->filter('#username_logged_in')->text());
// Post a new post that needs approval
$this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}");
$this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text());
- // logout
- $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
-
- // admin login
+ // Login as admin
+ $this->logout();
$this->login();
$this->add_lang('ucp');
+
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications');
// At least one notification should exist
diff --git a/tests/functional/ucp_profile_test.php b/tests/functional/ucp_profile_test.php
new file mode 100644
index 0000000000..e0e6255f79
--- /dev/null
+++ b/tests/functional/ucp_profile_test.php
@@ -0,0 +1,33 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case
+{
+ public function test_submitting_profile_info()
+ {
+ $this->add_lang('ucp');
+ $this->login();
+
+ $crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=profile_info');
+ $this->assertContainsLang('UCP_PROFILE_PROFILE_INFO', $crawler->filter('#cp-main h2')->text());
+
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'pf_phpbb_location' => 'Bertie“s Empire',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('PROFILE_UPDATED', $crawler->filter('#message')->text());
+
+ $crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=profile_info');
+ $form = $crawler->selectButton('Submit')->form();
+ $this->assertEquals('Bertie“s Empire', $form->get('pf_phpbb_location')->getValue());
+ }
+}
diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php
index 017484e8a7..9148d23bb4 100644
--- a/tests/log/function_view_log_test.php
+++ b/tests/log/function_view_log_test.php
@@ -44,7 +44,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'topic_id' => 0,
'viewforum' => '',
- 'action' => 'installed: 3.1.0-dev',
+ 'action' => 'LOG_INSTALL_INSTALLED 3.1.0-dev',
),
2 => array(
'id' => 2,
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index 83bbb8ef30..9e5914b934 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -140,7 +140,7 @@ class phpbb_mock_cache implements \phpbb\cache\driver\driver_interface
/**
* {@inheritDoc}
*/
- public function sql_save(\phpbb\db\driver\driver $db, $query, $query_result, $ttl)
+ public function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl)
{
return $query_result;
}
diff --git a/tests/mock/user.php b/tests/mock/user.php
index bd547b3973..e57e86ae2f 100644
--- a/tests/mock/user.php
+++ b/tests/mock/user.php
@@ -46,4 +46,9 @@ class phpbb_mock_user
}
return false;
}
+
+ public function lang()
+ {
+ return implode(' ', func_get_args());
+ }
}
diff --git a/tests/notification/fixtures/submit_post_topic.xml b/tests/notification/fixtures/submit_post_topic.xml
new file mode 100644
index 0000000000..5e179d9b99
--- /dev/null
+++ b/tests/notification/fixtures/submit_post_topic.xml
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_forums_watch">
+ <column>forum_id</column>
+ <column>user_id</column>
+ <column>notify_status</column>
+ <row>
+ <value>1</value>
+ <value>6</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>7</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>8</value>
+ <value>0</value>
+ </row>
+ </table>
+ <table name="phpbb_notifications">
+ <column>notification_type_id</column>
+ <column>user_id</column>
+ <column>item_id</column>
+ <column>item_parent_id</column>
+ <column>notification_read</column>
+ <column>notification_data</column>
+ <row>
+ <value>1</value>
+ <value>8</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_notification_types">
+ <column>notification_type_id</column>
+ <column>notification_type_name</column>
+ <column>notification_type_enabled</column>
+ <row>
+ <value>1</value>
+ <value>topic</value>
+ <value>1</value>
+ </row>
+ </table>
+ <table name="phpbb_posts">
+ <column>post_id</column>
+ <column>topic_id</column>
+ <column>forum_id</column>
+ <column>post_text</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_topics">
+ <column>topic_id</column>
+ <column>forum_id</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ </row>
+ </table>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <row>
+ <value>2</value>
+ <value>poster</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>noauth</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>7</value>
+ <value>default</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>8</value>
+ <value>notified</value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_user_notifications">
+ <column>item_type</column>
+ <column>item_id</column>
+ <column>user_id</column>
+ <column>method</column>
+ <column>notify</column>
+ <row>
+ <value>topic</value>
+ <value>0</value>
+ <value>2</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>topic</value>
+ <value>0</value>
+ <value>6</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>topic</value>
+ <value>0</value>
+ <value>7</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>topic</value>
+ <value>0</value>
+ <value>8</value>
+ <value></value>
+ <value>1</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 10d676c687..fbfd034381 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -101,7 +101,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
// Notification Types
- $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'approve_topic', 'approve_post');
+ $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'topic_in_queue', 'approve_topic', 'approve_post');
$notification_types_array = array();
foreach ($notification_types as $type)
{
diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php
new file mode 100644
index 0000000000..29f67c9c78
--- /dev/null
+++ b/tests/notification/submit_post_type_topic_test.php
@@ -0,0 +1,149 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+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';
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ global $auth, $phpbb_log;
+
+ // Add additional permissions
+ $auth->expects($this->any())
+ ->method('acl_get_list')
+ ->with($this->anything(),
+ $this->stringContains('_'),
+ $this->greaterThan(0))
+ ->will($this->returnValueMap(array(
+ array(
+ array(6, 7, 8),
+ 'f_read',
+ 1,
+ array(
+ 1 => array(
+ 'f_read' => array(7, 8),
+ ),
+ ),
+ ),
+ )));
+
+ $phpbb_log = $this->getMock('\phpbb\log\null');
+ }
+
+ /**
+ * submit_post() Notifications test
+ *
+ * submit_post() $mode = 'post'
+ * Notification item_type = 'topic'
+ */
+ public function submit_post_data()
+ {
+ return array(
+ /**
+ * Normal post
+ *
+ * User => State description
+ * 2 => Poster, should NOT receive a notification
+ * 6 => Forum subscribed, but no-auth reading, should NOT receive a notification
+ * 7 => Forum subscribed, should receive a notification
+ * 8 => Forum subscribed, but already notified, should NOT receive a new notification
+ */
+ array(
+ array(),
+ array(
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1),
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ array('user_id' => 8, 'item_id' => 2, 'item_parent_id' => 1),
+ ),
+ ),
+
+ /**
+ * Unapproved post
+ *
+ * No new notifications
+ */
+ array(
+ array('force_approved_state' => false),
+ array(
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ array(
+ array('user_id' => 8, 'item_id' => 1, 'item_parent_id' => 1),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider submit_post_data
+ */
+ public function test_submit_post($additional_post_data, $expected_before, $expected_after)
+ {
+ $sql = 'SELECT user_id, item_id, item_parent_id
+ FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATION_TYPES_TABLE . " nt
+ WHERE nt.notification_type_name = '" . $this->item_type . "'
+ AND n.notification_type_id = nt.notification_type_id
+ ORDER BY user_id ASC, item_id ASC";
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_before, $this->db->sql_fetchrowset($result));
+ $this->db->sql_freeresult($result);
+
+ $poll_data = array();
+ $post_data = array_merge($this->post_data, $additional_post_data);
+ submit_post('post', '', 'poster-name', POST_NORMAL, $poll_data, $post_data, false, false);
+
+ // Check whether the notifications got added successfully
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result),
+ 'Check whether the notifications got added successfully');
+ $this->db->sql_freeresult($result);
+
+ if (isset($additional_post_data['force_approved_state']) && $additional_post_data['force_approved_state'] === false)
+ {
+ return;
+ }
+
+ $reply_data = array_merge($this->post_data, array(
+ 'topic_id' => 2,
+ ));
+ $url = submit_post('reply', '', 'poster-name', POST_NORMAL, $poll_data, $reply_data, false, false);
+ $reply_id = 3;
+ $this->assertStringEndsWith('p' . $reply_id, $url, 'Post ID of reply is not ' . $reply_id);
+
+ // Check whether the notifications are still correct after a reply has been added
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result),
+ 'Check whether the notifications are still correct after a reply has been added');
+ $this->db->sql_freeresult($result);
+
+ $result = $this->db->sql_query(
+ 'SELECT *
+ FROM ' . POSTS_TABLE . '
+ WHERE post_id = ' . $reply_id);
+ $reply_edit_data = array_merge($this->post_data, $this->db->sql_fetchrow($result), array(
+ 'force_approved_state' => false,
+ 'post_edit_reason' => 'PHPBB3-12370',
+ ));
+ submit_post('edit', '', 'poster-name', POST_NORMAL, $poll_data, $reply_edit_data, false, false);
+
+ // Check whether the notifications are still correct after the reply has been edit
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result),
+ 'Check whether the notifications are still correct after the reply has been edit');
+ $this->db->sql_freeresult($result);
+ }
+}
diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php
index a58e208efc..c968012edf 100644
--- a/tests/session/testable_factory.php
+++ b/tests/session/testable_factory.php
@@ -63,10 +63,10 @@ class phpbb_session_testable_factory
/**
* Retrieve the configured session class instance
*
- * @param \phpbb\db\driver\driver $dbal The database connection to use for session data
+ * @param \phpbb\db\driver\driver_interface $dbal The database connection to use for session data
* @return phpbb_mock_session_testable A session instance
*/
- public function get_session(\phpbb\db\driver\driver $dbal)
+ public function get_session(\phpbb\db\driver\driver_interface $dbal)
{
// set up all the global variables used by session
global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container;
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 5d8dae4a30..f6429b1ccb 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -321,7 +321,7 @@ class phpbb_database_test_connection_manager
* Compile the correct schema filename (as per create_schema_files) and
* load it into the database.
*/
- protected function load_schema_from_file($directory, \phpbb\db\driver\driver $db)
+ protected function load_schema_from_file($directory, \phpbb\db\driver\driver_interface $db)
{
$schema = $this->dbms['SCHEMA'];
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index c0e58d1104..1f372fff0c 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -150,7 +150,7 @@ class phpbb_functional_test_case extends phpbb_test_case
{
global $phpbb_root_path, $phpEx;
// so we don't reopen an open connection
- if (!($this->db instanceof \phpbb\db\driver\driver))
+ if (!($this->db instanceof \phpbb\db\driver\driver_interface))
{
$dbms = self::$config['dbms'];
$this->db = new $dbms();
@@ -300,7 +300,7 @@ class phpbb_functional_test_case extends phpbb_test_case
// because that step will create a config.php file if phpBB has the
// permission to do so. We have to create the config file on our own
// in order to get the DEBUG constants defined.
- $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, true);
+ $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true);
$config_created = file_put_contents($config_file, $config_php_data) !== false;
if (!$config_created)
{
diff --git a/tests/wrapper/gmgetdate_test.php b/tests/wrapper/gmgetdate_test.php
index a838cfdba9..2f6c74b434 100644
--- a/tests/wrapper/gmgetdate_test.php
+++ b/tests/wrapper/gmgetdate_test.php
@@ -11,26 +11,28 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_wrapper_gmgetdate_test extends phpbb_test_case
{
- public function test_gmgetdate()
+ public static function phpbb_gmgetdate_data()
{
- $this->run_gmgetdate_assertion();
- $this->run_test_with_timezone('UTC');
- $this->run_test_with_timezone('Europe/Berlin');
- $this->run_test_with_timezone('America/Los_Angeles');
- $this->run_test_with_timezone('Antarctica/South_Pole');
+ return array(
+ array(''),
+ array('UTC'),
+ array('Europe/Berlin'),
+ array('America/Los_Angeles'),
+ array('Antarctica/South_Pole'),
+ );
}
- protected function run_test_with_timezone($timezone_identifier)
+ /**
+ * @dataProvider phpbb_gmgetdate_data
+ */
+ public function test_phpbb_gmgetdate($timezone_identifier)
{
- $current_timezone = date_default_timezone_get();
-
- date_default_timezone_set($timezone_identifier);
- $this->run_gmgetdate_assertion();
- date_default_timezone_set($current_timezone);
- }
+ if ($timezone_identifier)
+ {
+ $current_timezone = date_default_timezone_get();
+ date_default_timezone_set($timezone_identifier);
+ }
- protected function run_gmgetdate_assertion()
- {
$expected = time();
$date_array = phpbb_gmgetdate($expected);
@@ -45,5 +47,10 @@ class phpbb_wrapper_gmgetdate_test extends phpbb_test_case
);
$this->assertEquals($expected, $actual);
+
+ if (isset($current_timezone))
+ {
+ date_default_timezone_set($current_timezone);
+ }
}
}