aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorv12mike <v12mike@ingenious.co.nz>2019-11-04 09:21:27 -0500
committerMarc Alexander <admin@m-a-styles.de>2019-11-21 13:44:22 +0100
commit0f57f3d90d1983c49bde1d56b6018a761f92264b (patch)
tree9d457a0b124b8df77411bdbd5715050d3262c8f2 /tests
parent4d156837332707542bed6899cbf872c441f7bd96 (diff)
downloadforums-0f57f3d90d1983c49bde1d56b6018a761f92264b.tar
forums-0f57f3d90d1983c49bde1d56b6018a761f92264b.tar.gz
forums-0f57f3d90d1983c49bde1d56b6018a761f92264b.tar.bz2
forums-0f57f3d90d1983c49bde1d56b6018a761f92264b.tar.xz
forums-0f57f3d90d1983c49bde1d56b6018a761f92264b.zip
[ticket/9837] Display unapproved posts to their authors
Coding guidelines fixes PHPBB3-9837
Diffstat (limited to 'tests')
-rw-r--r--tests/content_visibility/get_visibility_sql_test.php38
-rw-r--r--tests/functional/visibility_unapproved_posts_test.php113
2 files changed, 76 insertions, 75 deletions
diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php
index def4ed3718..6026778487 100644
--- a/tests/content_visibility/get_visibility_sql_test.php
+++ b/tests/content_visibility/get_visibility_sql_test.php
@@ -24,8 +24,8 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
// data set 0: display_unapproved_posts=false, moderator, can see all posts
array(
'phpbb_posts',
- 0,
- false,
+ 0,
+ false,
'post', 1, '',
array(
array('m_approve', 1, true),
@@ -37,11 +37,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 4),
),
),
- // data set 1: display_unapproved_posts=false, normal user, cannot see any unapproved posts
+ // data set 1: display_unapproved_posts=false, normal user, cannot see any unapproved posts
array(
'phpbb_posts',
0,
- false,
+ false,
'post', 1, '',
array(
),
@@ -53,7 +53,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array(
'phpbb_topics',
0,
- false,
+ false,
'topic', 1, '',
array(
array('m_approve', 1, true),
@@ -65,22 +65,22 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('topic_id' => 4),
),
),
- // data set 3: display_unapproved_posts=false, normal user, cannot see unapproved posts topic
+ // data set 3: display_unapproved_posts=false, normal user, cannot see unapproved posts topic
array(
'phpbb_topics',
0,
- false,
+ false,
'topic', 1, '',
array(),
array(
array('topic_id' => 2),
),
),
- // data set 4: display_unapproved_posts=true, guest user, cannot see unapproved posts
+ // data set 4: display_unapproved_posts=true, guest user, cannot see unapproved posts
array(
'phpbb_posts',
1,
- true,
+ true,
'post', 1, '',
array(
),
@@ -88,22 +88,22 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 2),
),
),
- // data set 5: display_unapproved_posts=true, guest user, cannot see unapproved posts topic
+ // data set 5: display_unapproved_posts=true, guest user, cannot see unapproved posts topic
array(
'phpbb_topics',
1,
- true,
+ true,
'topic', 1, '',
array(),
array(
array('topic_id' => 2),
),
),
- // data set 6: display_unapproved_posts=true, normal user, can see own unapproved posts
+ // data set 6: display_unapproved_posts=true, normal user, can see own unapproved posts
array(
'phpbb_posts',
- 0,
- true,
+ 0,
+ true,
'post', 1, '',
array(),
array(
@@ -111,11 +111,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 2),
),
),
- // data set 7: display_unapproved_posts=true, normal user, can see own unapproved posts topic
+ // data set 7: display_unapproved_posts=true, normal user, can see own unapproved posts topic
array(
'phpbb_topics',
0,
- true,
+ true,
'topic', 1, '',
array(),
array(
@@ -152,11 +152,13 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
- $result = $db->sql_query('SELECT ' . $mode . '_id
+ $sql = 'SELECT ' . $mode . '_id
FROM ' . $table . '
WHERE ' . $content_visibility->get_visibility_sql($mode, $forum_id, $table_alias) . '
- ORDER BY ' . $mode . '_id ASC');
+ ORDER BY ' . $mode . '_id ASC';
+ $result = $db->sql_query($sql);
$this->assertEquals($expected, $db->sql_fetchrowset($result));
+ $db->sql_freeresult($result);
}
}
diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php
index 4e220ddda2..f29e081977 100644
--- a/tests/functional/visibility_unapproved_posts_test.php
+++ b/tests/functional/visibility_unapproved_posts_test.php
@@ -16,7 +16,7 @@
*/
class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_case
{
- protected $data = array();
+ protected $data = [];
public function test_setup_forums()
{
@@ -24,13 +24,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->admin_login();
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
- $form = $crawler->selectButton('addforum')->form(array(
+ $form = $crawler->selectButton('addforum')->form([
'forum_name' => 'Unapproved Posts Test #1',
- ));
+ ]);
$crawler = self::submit($form);
- $form = $crawler->selectButton('update')->form(array(
+ $form = $crawler->selectButton('update')->form([
'forum_perm_from' => 2,
- ));
+ ]);
$crawler = self::submit($form);
// Set flood interval to 0
@@ -40,13 +40,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
public function test_create_posts()
{
$this->login();
- $this->load_ids(array(
- 'forums' => array(
+ $this->load_ids([
+ 'forums' => [
'Unapproved Posts Test #1',
- ),
- ));
+ ],
+ ]);
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 0,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
@@ -54,7 +54,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => 0,
- ), 'initial comparison');
+ ], 'initial comparison');
// Test creating topic #1
$post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #1', 'This is a test topic posted by the testing framework.');
@@ -64,7 +64,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->data['topics']['Unapproved Posts Test Topic #1'] = (int) $post['topic_id'];
$this->data['posts']['Unapproved Posts 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']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
@@ -72,20 +72,20 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'after creating topic #1');
+ ], 'after creating topic #1');
$this->logout();
$this->create_user('unapproved_posts_test_user#1');
- $this->add_user_group('NEWLY_REGISTERED', array('unapproved_posts_test_user#1'));
+ $this->add_user_group('NEWLY_REGISTERED', ['unapproved_posts_test_user#1']);
$this->login('unapproved_posts_test_user#1');
// Test creating a reply
- $post2 = $this->create_post($this->data['forums']['Unapproved Posts Test #1'], $post['topic_id'], 'Re: Unapproved Posts Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
+ $post2 = $this->create_post($this->data['forums']['Unapproved Posts Test #1'], $post['topic_id'], 'Re: Unapproved Posts Test Topic #1-#2', 'This is a test post posted by the testing framework.', [], 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 1,
'forum_posts_softdeleted' => 0,
@@ -93,15 +93,15 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'after replying');
+ ], 'after replying');
// Test creating topic #2
- $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
+ $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #2', 'This is a test topic posted by the testing framework.', [], 'POST_STORED_MOD');
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
@@ -109,31 +109,31 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'after creating topic #2');
+ ], 'after creating topic #2');
$this->logout();
}
public function test_view_unapproved_post_disabled()
{
- // user who created post
+ // user who created post
$this->login('unapproved_posts_test_user#1');
- $this->load_ids(array(
- 'forums' => array(
+ $this->load_ids([
+ 'forums' => [
'Unapproved Posts Test #1',
- ),
- 'topics' => array(
+ ],
+ 'topics' => [
'Unapproved Posts Test Topic #1',
'Unapproved Posts Test Topic #2',
- ),
- 'posts' => array(
+ ],
+ 'posts' => [
'Unapproved Posts Test Topic #1',
'Re: Unapproved Posts Test Topic #1-#2',
'Unapproved Posts Test Topic #2',
- ),
- ));
+ ],
+ ]);
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
@@ -141,19 +141,19 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'before approving post');
+ ], 'before approving post');
$this->add_lang('posting');
$this->add_lang('viewtopic');
$this->add_lang('mcp');
- //should be able to see topic 1 but not unapproved post
+ // should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should not be able to see topic 2
+ // should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
@@ -162,17 +162,15 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->create_user('unapproved_posts_test_user#2');
$this->login('unapproved_posts_test_user#2');
- $this->add_lang('posting');
- $this->add_lang('viewtopic');
- $this->add_lang('mcp');
+ $this->add_lang('posting', 'viewtopic', 'mcp');
- //should be able to see topic 1 but not unapproved post
+ // should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should not be able to see topic 2
+ // should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
}
@@ -181,24 +179,24 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
{
$this->config_display_unapproved_posts_state(true);
- // user who created post
+ // user who created post
$this->login('unapproved_posts_test_user#1');
- $this->load_ids(array(
- 'forums' => array(
+ $this->load_ids([
+ 'forums' => [
'Unapproved Posts Test #1',
- ),
- 'topics' => array(
+ ],
+ 'topics' => [
'Unapproved Posts Test Topic #1',
'Unapproved Posts Test Topic #2',
- ),
- 'posts' => array(
+ ],
+ 'posts' => [
'Unapproved Posts Test Topic #1',
'Re: Unapproved Posts Test Topic #1-#2',
'Unapproved Posts Test Topic #2',
- ),
- ));
+ ],
+ ]);
- $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], array(
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 2,
'forum_posts_softdeleted' => 0,
@@ -206,22 +204,23 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
'forum_topics_unapproved' => 1,
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
- ), 'before approving post');
+ ], 'before approving post');
$this->add_lang('posting');
$this->add_lang('viewtopic');
$this->add_lang('mcp');
- //should be able to see topic 1 and unapproved post
+ // should be able to see topic 1 and unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should be able to see topic 2
+ // should be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
- //should be able to see post in topic 2
+
+ // should be able to see post in topic 2
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #2']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('#page-body')->text());
$this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
@@ -234,13 +233,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
$this->add_lang('viewtopic');
$this->add_lang('mcp');
- //should be able to see topic 1 but not unapproved post
+ // should be able to see topic 1 but not unapproved post
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}");
$this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text());
$this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text());
$this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text());
- //should not be able to see topic 2
+ // should not be able to see topic 2
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}");
$this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text());
$this->logout();
@@ -274,12 +273,12 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
protected function set_flood_interval($flood_interval)
{
- $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+ $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;
+ $values['config[flood_interval]'] = $flood_interval;
$form->setValues($values);
$crawler = self::submit($form);
$this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
@@ -291,7 +290,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_
if (!empty($data['forums']))
{
- $sql = 'SELECT *
+ $sql = 'SELECT forum_id, forum_name
FROM phpbb_forums
WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
$result = $this->db->sql_query($sql);